summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/ClangUserExpression.cpp
Commit message (Collapse)AuthorAgeFilesLines
* I moved the responsibility for interacting with theSean Callanan2011-10-291-1/+1
| | | | | | | | | | | | AST importer on completing namespace mappings from ClangExpressionDeclMap to ClangASTSource. ClangASTSource now contains a TargetSP which it uses to lookup namespaces in all of a target's modules. I will use the TargetSP in the future to look up globals. llvm-svn: 143275
* Extended the lifetime of Clang parser objects to theSean Callanan2011-10-121-3/+2
| | | | | | | | | | | | | lifetime of ClangExpressionDeclMap. This allows ClangExpressionVariables found during parsing to be queried for their containing namespaces during expression execution. Other clients (like ClangFunction) explicitly delete this state, so they should not result in any memory leaks. llvm-svn: 141821
* Fixed a memory leak of ASTResultSynthesizers,Sean Callanan2011-10-081-4/+7
| | | | | | by attaching them to the ClangExpressionParser. llvm-svn: 141452
* Factored out handling of the source code for anSean Callanan2011-09-261-50/+17
| | | | | | | | | | expression into a separate class. This class encapsulates wrapping the function as needed. I am also moving from using booleans to indicate what the expression's language should be to using lldb::LanguageType instead. llvm-svn: 140545
* Converted the lldb_private::Process over to use the intrusiveGreg Clayton2011-09-221-19/+23
| | | | | | | | | | | | | | | | | | | | shared pointers. Changed the ExecutionContext over to use shared pointers for the target, process, thread and frame since these objects can easily go away at any time and any object that was holding onto an ExecutionContext was running the risk of using a bad object. Now that the shared pointers for target, process, thread and frame are just a single pointer (they all use the instrusive shared pointers) the execution context is much safer and still the same size. Made the shared pointers in the the ExecutionContext class protected and made accessors for all of the various ways to get at the pointers, references, and shared pointers. llvm-svn: 140298
* Fixed a problem where expressions would attempt toSean Callanan2011-09-201-27/+1
| | | | | | | | allocate memory in a process that did not support expression execution. Also improved detection of whether or not a process can execute expressions. llvm-svn: 140202
* Update declarations for all functions/methods that accept printf-styleJason Molenda2011-09-201-2/+2
| | | | | | | | stdarg formats to use __attribute__ format so the compiler can flag incorrect uses. Fix all incorrect uses. Most of these are innocuous, a few were resulting in crashes. llvm-svn: 140185
* Fixed a problem where the expression parser wouldSean Callanan2011-09-151-0/+3
| | | | | | | attempt to obtain information from the process even in cases where the process isn't available. llvm-svn: 139803
* This patch modifies the expression parser to allow itSean Callanan2011-09-151-66/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to execute expressions even in the absence of a process. This allows expressions to run in situations where the target cannot run -- e.g., to perform calculations based on type information, or to inspect a binary's static data. This modification touches the following files: lldb-private-enumerations.h Introduce a new enum specifying the policy for processing an expression. Some expressions should always be JITted, for example if they are functions that will be used over and over again. Some expressions should always be interpreted, for example if the target is unsafe to run. For most, it is acceptable to JIT them, but interpretation is preferable when possible. Target.[h,cpp] Have EvaluateExpression now accept the new enum. ClangExpressionDeclMap.[cpp,h] Add support for the IR interpreter and also make the ClangExpressionDeclMap more robust in the absence of a process. ClangFunction.[cpp,h] Add support for the new enum. IRInterpreter.[cpp,h] New implementation. ClangUserExpression.[cpp,h] Add support for the new enum, and for running expressions in the absence of a process. ClangExpression.h Remove references to the old DWARF-based method of evaluating expressions, because it has been superseded for now. ClangUtilityFunction.[cpp,h] Add support for the new enum. ClangExpressionParser.[cpp,h] Add support for the new enum, remove references to DWARF, and add support for checking whether the expression could be evaluated statically. IRForTarget.[h,cpp] Add support for the new enum, and add utility functions to support the interpreter. IRToDWARF.cpp Removed CommandObjectExpression.cpp Remove references to the obsolete -i option. Process.cpp Modify calls to ClangUserExpression::Evaluate to pass the correct enum (for dlopen/dlclose) SBValue.cpp Add support for the new enum. SBFrame.cpp Add support for he new enum. BreakpointOptions.cpp Add support for the new enum. llvm-svn: 139772
* Huge memory and performance improvements in the DWARF parser.Greg Clayton2011-09-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | Address ranges are now split up into two different tables: - one in DWARFDebugInfo that is compile unit specific - one in each DWARFCompileUnit that has exact function DIE offsets This helps keep the size of the aranges down since the main table will get uniqued and sorted and have consecutive ranges merged. We then only parse the compile unit one on demand once we have determined that a compile unit contains the address in question. We also now use the .debug_aranges section if there is one instead of always indexing the DWARF manually. NameToDIE now uses a UniqueCStringMap<dw_offset> map instead of a std::map. std::map is very bulky as each node has 3 pointers and the key and value types. This gets our NameToDIE entry down to 12 bytes each instead of 48 which saves us a lot of memory when we have very large DWARF. DWARFDebugAranges now has a smaller footprint for each range it contains to save on memory. llvm-svn: 139557
* Fixed a bug where the target for an expression wasSean Callanan2011-08-241-4/+4
| | | | | | | | not set if the containing function could not be found. This caused LLDB to crash later in expression parsing. llvm-svn: 138499
* Added support for persistent types to theSean Callanan2011-08-231-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | expression parser. You can use a persistent type like this: (lldb) expr struct $foo { int a; int b; }; (lldb) struct $foo i; i.a = 2; i.b = 3; i ($foo) $0 = { (int) a = 2 (int) b = 3 } typedefs work similarly. This patch affects the following files: test/expression_command/persistent_types/* A test case for persistent types, in particular structs and typedefs. ClangForward.h Added TypeDecl, needed to declare some functions in ASTResultSynthesizer.h ClangPersistentVariables.[h,cpp] Added a list of persistent types to the persistent variable store. ASTResultSynthesizer.[h,cpp] Made the AST result synthesizer iterate across TypeDecls in the expression, and record any persistent types found. Also made a minor documentation fix. ClangUserExpression.[h,cpp] Extended the user expression class to keep the state needed to report the persistent variable store for the target to the AST result synthesizers. Also introduced a new error code for expressions that executed normally but did not return a result. CommandObjectExpression.cpp Improved output for expressions (like declarations of new persistent types) that don't return a result. This is no longer treated as an error. llvm-svn: 138383
* Add EvaluateWithError static method. Fix a bug in handling constant ↵Jim Ingham2011-08-091-1/+13
| | | | | | expressions - we weren't setting the result even though the expression evaluation succeeded... llvm-svn: 137077
* This is an overhaul of the expression parser codeSean Callanan2011-08-051-27/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | that detects what context the current expression is meant to execute in. LLDB now properly consults the method declaration in the debug information rather than trying to hunt down the "this" or "self" pointer by name, which can be misleading. Other fixes include: - LLDB now properly detects that it is inside an inlined C++ member function. - LLDB now allows access to non-const members when in const code. - The functions in SymbolFile that locate the DeclContext containing a DIE have been renamed to reflect what they actually do. I have added new functions that find the DeclContext for the DIE itself. I have also introduced testcases for C++ and Objective-C. llvm-svn: 136999
* Improved the expression parser's detection of theSean Callanan2011-08-031-3/+7
| | | | | | | | | | | | current context. Previously, if there was a variable called "self" available, the expression parser assumed it was inside a method. But class methods in Objective-C also take a "self" parameter, of DWARF type "id". We now detect this properly, and only assume we're in an instance method if "self" is a pointer to an Objective-C object. llvm-svn: 136784
* Added checking to make sure that the target has aSean Callanan2011-08-011-1/+5
| | | | | | scratch AST context before attempting to parse. llvm-svn: 136631
* Patch by Matt Johnson to silence G++ warnings!Johnny Chen2011-07-191-4/+4
| | | | | | | | Used hand merge to apply the diffs. I did not apply the diffs for FormatManager.h and the diffs for memberwise initialization for ValueObject.cpp because they changed since. I will ask my colleague to apply them later. llvm-svn: 135508
* The implementation of categories is now synchronization safeEnrico Granata2011-07-191-1/+1
| | | | | | | | | | | | | | | | | | | | | Code cleanup: - The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...) are contained. The wrapper code always remains in Debugger.{h|cpp} - Several leftover fields, methods and comments from previous design choices have been removed type category subcommands (enable, disable, delete) now can take a list of category names as input - for type category enable, saying "enable A B C" is the same as saying enable C enable B enable A (the ordering is relevant in enabling categories, and it is expected that a user typing enable A B C wants to look into category A, then into B, then into C and not the other way round) - for the other two commands, the order is not really relevant (however, the same inverted ordering is used for consistency) llvm-svn: 135494
* Cleanup error output on expressions. Greg Clayton2011-06-241-1/+1
| | | | llvm-svn: 133834
* Use the dyld_mode, image_infos & image_infos_count passed into the shared ↵Jim Ingham2011-06-201-2/+2
| | | | | | | | library notification function to update libraries rather than reading the whole all_imaage_infos structure every time we get notified. llvm-svn: 133448
* This commit integrates support for the LLVM MCJITSean Callanan2011-05-231-2/+12
| | | | | | | | | | | | | | | | | | | | | | | into the mainline LLDB codebase. MCJIT introduces API improvements and better architectural support. This commit adds a new subsystem, the ProcessDataAllocator, which is responsible for performing static data allocations on behalf of the IR transformer. MCJIT currently does not support the relocations required to store the constant pool in the same allocation as the function body, so we allocate a heap region separately and redirect static data references from the expression to that heap region in a new IR modification pass. This patch also fixes bugs in the IR transformations that were exposed by the transition to the MCJIT. Finally, the patch also pulls in a more recent revision of LLVM so that the MCJIT is available for use. llvm-svn: 131923
* RunThreadPlan should set the plan to "not private" since it needs that,Jim Ingham2011-05-171-1/+1
| | | | | | and then reset it to the original value when done. llvm-svn: 131498
* Fixed the "mmap" to work on MacOSX/darwin by supplying the correct arguemnts.Greg Clayton2011-05-171-1/+5
| | | | | | | | | | | Modified ClangUserExpression and ClangUtilityFunction to display the actual error (if one is available) that made the JIT fail instead of a canned response. Fixed the restoring of all register values when the 'G' packet doesn't work to use the correct data. llvm-svn: 131454
* Fix the error message when an expression evaluation is interrupted by a ↵Jim Ingham2011-05-171-3/+16
| | | | | | | | | crash/breakpoint hit to give the reason for the interrupt. Also make sure it we don't want to unwind from the evaluation we print something if it is interrupted. llvm-svn: 131448
* Fixed a bug in which expression-local variables wereSean Callanan2011-05-091-9/+15
| | | | | | | | | | treated as being permanently resident in target memory. In fact, since the expression's stack frame is deleted and potentially re-used after the expression completes, the variables need to be treated as being freeze-dried. llvm-svn: 131104
* Made expressions that are just casts of pointer Sean Callanan2011-05-071-13/+8
| | | | | | | | | | | | variables be evaluated statically. Also fixed a bug that caused the results of statically-evaluated expressions to be materialized improperly. This bug also removes some duplicate code. llvm-svn: 131042
* Fix up how the ValueObjects manage their life cycle so that you can hand out ↵Jim Ingham2011-04-221-3/+3
| | | | | | | | | a shared pointer to a ValueObject or any of its dependent ValueObjects, and the whole cluster will stay around as long as that shared pointer stays around. llvm-svn: 130035
* Order of initialization lists.Stephen Wilson2011-04-111-2/+2
| | | | | | | | This patch fixes all of the warnings due to unordered initialization lists. Patch by Marco Minutoli. llvm-svn: 129290
* Convert ValueObject to explicitly maintain the Execution Context in which ↵Jim Ingham2011-03-311-4/+4
| | | | | | they were created, and then use that when they update themselves. That means all the ValueObject evaluate me type functions that used to require a Frame object now do not. I didn't remove the SBValue API's that take this now useless frame, but I added ones that don't require the frame, and marked the SBFrame taking ones as deprecated. llvm-svn: 128593
* Fixed the LLDB build so that we can have private types, private enums andGreg Clayton2011-03-241-15/+15
| | | | | | | | public types and public enums. This was done to keep the SWIG stuff from parsing all sorts of enums and types that weren't needed, and allows us to abstract our API better. llvm-svn: 128239
* Clean up a bit of the type getting code where lldb_private:Type now hasGreg Clayton2011-02-161-3/+2
| | | | | | | | | | | | | | clang_type_t GetClangFullType(); // Get a completely defined clang type clang_type_t GetClangLayoutType(); // Get a clang type that can be used for type layout clang_type_t GetClangForwardType(); // A type that can be completed if needed, but is more efficient. llvm-svn: 125691
* Made lldb_private::ArchSpec contain much more than just an architecture. ItGreg Clayton2011-02-151-14/+1
| | | | | | | | | | now, in addition to cpu type/subtype and architecture flavor, contains: - byte order (big endian, little endian) - address size in bytes - llvm::Triple for true target triple support and for more powerful plug-in selection. llvm-svn: 125602
* Endian patch from Kirk Beitz that allows better cross platform building.Greg Clayton2011-02-011-1/+1
| | | | llvm-svn: 124643
* Fixed a bug in the expression code which causedSean Callanan2011-01-241-3/+6
| | | | | | | | | | | it to interpret a "this" variable that was merely a pointer -- that is, not a class pointer -- as meaning that the current context was inside a C++ method. This bug would prevent expressions from evaluating correctly in regular C code if there was a pointer variable named "this" in scope. llvm-svn: 124117
* Make expressions clean up their JIT'ed code allocation.Greg Clayton2011-01-191-18/+18
| | | | llvm-svn: 123855
* Took the timeout for a ClangUserExpression down from a 10 second timeout toGreg Clayton2011-01-191-1/+1
| | | | | | | | | | | | | | 500 ms. Make MachThreadList more threadsafe. Added code to make sure the thread register state was properly flushed for x86_64. Fixed an missing return code for the current thread in the new thread suffix code. Improved debugserver logging. llvm-svn: 123815
* Make a few log messages come out in "log enable lldb step" as well as "log ↵Jim Ingham2011-01-181-2/+4
| | | | | | enable lldb expression". llvm-svn: 123784
* Thread safety changes in debugserver and also in the process GDB remote plugin.Greg Clayton2011-01-181-0/+7
| | | | | | | | | | | | | | I added support for asking if the GDB remote server supports thread suffixes for packets that should be thread specific (register read/write packets) because the way the GDB remote protocol does it right now is to have a notion of a current thread for register and memory reads/writes (set via the "$Hg%x" packet) and a current thread for running ("$Hc%x"). Now we ask the remote GDB server if it supports adding the thread ID to the register packets and we enable that feature in LLDB if supported. This stops us from having to send a bunch of packets that update the current thread ID to some value which is prone to error, or extra packets. llvm-svn: 123762
* Added support for the fragile ivars provided bySean Callanan2011-01-171-1/+1
| | | | | | | Apple's Objective-C 2.0 runtime. They are enabled if the Objective-C runtime has the proper version. llvm-svn: 123694
* Implemented a major overhaul of the way variables are handledSean Callanan2011-01-131-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | by LLDB. Instead of being materialized into the input structure passed to the expression, variables are left in place and pointers to them are materialzied into the structure. Variables not resident in memory (notably, registers) get temporary memory regions allocated for them. Persistent variables are the most complex part of this, because they are made in various ways and there are different expectations about their lifetime. Persistent variables now have flags indicating their status and what the expectations for longevity are. They can be marked as residing in target memory permanently -- this is the default for result variables from expressions entered on the command line and for explicitly declared persistent variables (but more on that below). Other result variables have their memory freed. Some major improvements resulting from this include being able to properly take the address of variables, better and cleaner support for functions that return references, and cleaner C++ support in general. One problem that remains is the problem of explicitly declared persistent variables; I have not yet implemented the code that makes references to them into indirect references, so currently materialization and dematerialization of these variables is broken. llvm-svn: 123371
* Added access to set the current stack frame within a thread so any commandGreg Clayton2010-12-171-0/+1
| | | | | | | | | | | | line commands can use the current thread/frame. Fixed an issue with expressions that get sandboxed in an objective C method where unichar wasn't being passed down. Added a "static size_t Scalar::GetMaxByteSize();" function in case we need to know the max supported by size of something within a Scalar object. llvm-svn: 122027
* Remove #include of non-existant lldb/Expression/ASTSplitConsumer.h Jason Molenda2010-12-161-1/+0
| | | | | | (from Sean's commit a minute ago) llvm-svn: 121954
* Implemented a feature where the expression parserSean Callanan2010-12-161-32/+47
| | | | | | | | | | | | | can avoid running the code in the target if the expression's result is known and the expression has no side effects. Right now this feature is quite conservative in its guess about side effects, and it only computes integer results, but the machinery to make it more sophisticated is there. llvm-svn: 121952
* Modified LLDB expressions to not have to JIT and run code just to see variableGreg Clayton2010-12-141-27/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | values or persistent expression variables. Now if an expression consists of a value that is a child of a variable, or of a persistent variable only, we will create a value object for it and make a ValueObjectConstResult from it to freeze the value (for program variables only, not persistent variables) and avoid running JITed code. For everything else we still parse up and JIT code and run it in the inferior. There was also a lot of clean up in the expression code. I made the ClangExpressionVariables be stored in collections of shared pointers instead of in collections of objects. This will help stop a lot of copy constructors on these large objects and also cleans up the code considerably. The persistent clang expression variables were moved over to the Target to ensure they persist across process executions. Added the ability for lldb_private::Target objects to evaluate expressions. We want to evaluate expressions at the target level in case we aren't running yet, or we have just completed running. We still want to be able to access the persistent expression variables between runs, and also evaluate constant expressions. Added extra logging to the dynamic loader plug-in for MacOSX. ModuleList objects can now dump their contents with the UUID, arch and full paths being logged with appropriate prefix values. Thread hardened the Communication class a bit by making the connection auto_ptr member into a shared pointer member and then making a local copy of the shared pointer in each method that uses it to make sure another thread can't nuke the connection object while it is being used by another thread. Added a new file to the lldb/test/load_unload test that causes the test a.out file to link to the libd.dylib file all the time. This will allow us to test using the DYLD_LIBRARY_PATH environment variable after moving libd.dylib somewhere else. llvm-svn: 121745
* Bugfixes for the new "self" pointer handling. Specifically,Sean Callanan2010-12-141-3/+15
| | | | | | | | the code to pass the _cmd pointer has been improved, and _cmd is now set to the value of _cmd for the current context, as opposed to being simply NULL. llvm-svn: 121739
* Added support for generating expressions that haveSean Callanan2010-12-131-12/+60
| | | | | | | | | | | | | | access to the members of the Objective-C self object. The approach we take is to generate the method as a @category on top of the self object, and to pass the "self" pointer to it. (_cmd is currently NULL.) Most changes are in ClangExpressionDeclMap, but the change that adds support to the ABIs to pass _cmd touches a fair amount of code. llvm-svn: 121722
* More logging for use in debugging the interactionsSean Callanan2010-12-071-4/+27
| | | | | | | between clients of the LLDB API and the expression parser. llvm-svn: 121193
* Logging improvements to help identify major events inSean Callanan2010-12-071-5/+36
| | | | | | | | | LLDB expression execution. We also now print the argument structure after execution, to allow us to verify that the expression did indeed execute correctly. llvm-svn: 121126
* Fixed object lifetimes in ClangExpressionDeclMapSean Callanan2010-12-031-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | so that it is not referring to potentially stale state during IR execution. This was done by introducing modular state (like ClangExpressionVariable) where groups of state variables have well-defined lifetimes: - m_parser_vars are specific to parsing, and only exist between calls to WillParse() and DidParse(). - m_struct_vars survive for the entire execution of the ClangExpressionDeclMap because they provide the template for a materialized set of expression variables. - m_material_vars are specific to a single instance of materialization, and only exist between calls to Materialize() and Dematerialize(). I also removed unnecessary references to long- lived state that really didn't need to be referred to at all, and also introduced several assert()s that helped me diagnose a few bugs (fixed too). llvm-svn: 120778
* Fixed ClangUserExpression's wrapping of expressionsSean Callanan2010-12-011-4/+27
| | | | | | | | | | | | | in C++ methods. There were two fixes involved: - For an object whose contents are not known, the expression should be treated as a non-member, and "this" should have no meaning. - For a const object, the method should be declared const as well. llvm-svn: 120606
OpenPOWER on IntegriCloud