summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/ClangExpressionDeclMap.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Overloading is not broken any more. No need forSean Callanan2010-10-291-8/+0
| | | | | | an #ifndef. llvm-svn: 117706
* Fixed a problem where function calls on i386 weren't Sean Callanan2010-10-261-1/+5
| | | | | | | | | being generated correctly. Also added a messy way to single-step through expressions that I will improve soon. llvm-svn: 117342
* Made many ConstString functions inlined in the header file.Greg Clayton2010-10-151-177/+250
| | | | | | | | | | | | | | | | | | | Changed all of our synthesized "___clang" functions, types and variables that get used in expressions over to have a prefix of "$_lldb". Now when we do name lookups we can easily switch off of the first '$' character to know if we should look through only our internal (when first char is '$') stuff, or when we should look through program variables, functions and types. Converted all of the clang expression code over to using "const ConstString&" values for names instead of "const char *" since there were many places that were converting the "const char *" names into ConstString names and them throwing them away. We now avoid making a lot of ConstString conversions and benefit from the quick comparisons in a few extra spots. Converted a lot of code from LLVM coding conventions into LLDB coding conventions. llvm-svn: 116634
* Skip checking for a bunch of built-ins when evaluating an expression.Greg Clayton2010-10-151-1/+1
| | | | llvm-svn: 116565
* Fixed an expression parsing issue where if you were stopped somewhere withoutGreg Clayton2010-10-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | debug information and you evaluated an expression, a crash would occur as a result of an unchecked pointer. Added the ability to get the expression path for a ValueObject. For a rectangle point child "x" the expression path would be something like: "rect.top_left.x". This will allow GUI and command lines to get ahold of the expression path for a value object without having to explicitly know about the hierarchy. This means the ValueObject base class now has a "ValueObject *m_parent;" member. All ValueObject subclasses now correctly track their lineage and are able to provide value expression paths as well. Added a new "--flat" option to the "frame variable" to allow for flat variable output. An example of the current and new outputs: (lldb) frame variable argc = 1 argv = 0x00007fff5fbffe80 pt = { x = 2 y = 3 } rect = { bottom_left = { x = 1 y = 2 } top_right = { x = 3 y = 4 } } (lldb) frame variable --flat argc = 1 argv = 0x00007fff5fbffe80 pt.x = 2 pt.y = 3 rect.bottom_left.x = 1 rect.bottom_left.y = 2 rect.top_right.x = 3 rect.top_right.y = 4 As you can see when there is a lot of hierarchy it can help flatten things out. Also if you want to use a member in an expression, you can copy the text from the "--flat" output and not have to piece it together manually. This can help when you want to use parts of the STL in expressions: (lldb) frame variable --flat argc = 1 argv = 0x00007fff5fbffea8 hello_world._M_dataplus._M_p = 0x0000000000000000 (lldb) expr hello_world._M_dataplus._M_p[0] == '\0' llvm-svn: 116532
* Added extra logging, and made sure that the argumentSean Callanan2010-10-081-0/+9
| | | | | | | struct for expressions is deallocated when the ClangExpressionDeclMap is taken down. llvm-svn: 116028
* Updated the expression parser to ignore non-external Sean Callanan2010-10-061-8/+16
| | | | | | | functions it finds in libraries unless it cannot find an external function with the desired name. llvm-svn: 115721
* Added support for (de)materializing values in registers,Sean Callanan2010-10-051-41/+204
| | | | | | so that expressions can use them. llvm-svn: 115658
* Added a new ValueObject type that will be used to freeze dry expressionGreg Clayton2010-10-051-2/+2
| | | | | | | | | | | | | | | results. The clang opaque type for the expression result will be added to the Target's ASTContext, and the bytes will be stored in a DataBuffer inside the new object. The class is named: ValueObjectConstResult Now after an expression is evaluated, we can get a ValueObjectSP back that contains a ValueObjectConstResult object. Relocated the value object dumping code into a static function within the ValueObject class instead of being in the CommandObjectFrame.cpp file which is what contained the code to dump variables ("frame variables"). llvm-svn: 115578
* Make C++ constructors and destructors correctly within the clang types weGreg Clayton2010-10-011-3/+5
| | | | | | generate from DWARF. llvm-svn: 115268
* Fixed the forward declaration issue that was present in the DWARF parser afterGreg Clayton2010-09-291-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | adding methods to C++ and objective C classes. In order to make methods, we need the function prototype which means we need the arguments. Parsing these could cause a circular reference that caused an assertion. Added a new typedef for the clang opaque types which are just void pointers: lldb::clang_type_t. This appears in lldb-types.h. This was fixed by enabling struct, union, class, and enum types to only get a forward declaration when we make the clang opaque qual type for these types. When they need to actually be resolved, lldb_private::Type will call a new function in the SymbolFile protocol to resolve a clang type when it is not fully defined (clang::TagDecl::getDefinition() returns NULL). This allows us to be a lot more lazy when parsing clang types and keeps down the amount of data that gets parsed into the ASTContext for each module. Getting the clang type from a "lldb_private::Type" object now takes a boolean that indicates if a forward declaration is ok: clang_type_t lldb_private::Type::GetClangType (bool forward_decl_is_ok); So function prototypes that define parameters that are "const T&" can now just parse the forward declaration for type 'T' and we avoid circular references in the type system. llvm-svn: 115012
* Added type lookup, so variables with user-defined typesSean Callanan2010-09-271-111/+25
| | | | | | can be allocated and manipulated. llvm-svn: 114928
* Added the ability to create an objective C method for an objective C Greg Clayton2010-09-241-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | interface in ClangASTContext. Also added two bool returning functions that indicated if an opaque clang qual type is a CXX class type, and if it is an ObjC class type. Objective C classes now will get their methods added lazily as they are encountered. The reason for this is currently, unlike C++, the DW_TAG_structure_type and owns the ivars, doesn't not also contain the member functions. This means when we parse the objective C class interface we either need to find all functions whose names start with "+[CLASS_NAME" or "-[CLASS_NAME" and add them all to the class, or when we parse each objective C function, we slowly add it to the class interface definition. Since objective C's class doesn't change internal bits according to whether it has certain types of member functions (like C++ does if it has virtual functions, or if it has user ctors/dtors), I currently chose to lazily populate the class when each functions is parsed. Another issue we run into with ObjC method declarations is the "self" and "_cmd" implicit args are not marked as artificial in the DWARF (DW_AT_artifical), so we currently have to look for the parameters by name if we are trying to omit artificial function args if the language of the compile unit is ObjC or ObjC++. llvm-svn: 114722
* Updated to latest LLVM. Major LLVM changes:Sean Callanan2010-09-231-6/+7
| | | | | | | | | | - Sema is now exported (and there was much rejoicing.) - Storage classes are now centrally defined. Also fixed some bugs that the new LLVM picked up. llvm-svn: 114622
* Added motheds to C++ classes as we parse them to keep clang happy.Greg Clayton2010-09-231-4/+6
| | | | llvm-svn: 114616
* Removed the hacky "#define this ___clang_this" handlerSean Callanan2010-09-211-22/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for C++ classes. Replaced it with a less hacky approach: - If an expression is defined in the context of a method of class A, then that expression is wrapped as ___clang_class::___clang_expr(void*) { ... } instead of ___clang_expr(void*) { ... }. - ___clang_class is resolved as the type of the target of the "this" pointer in the method the expression is defined in. - When reporting the type of ___clang_class, a method with the signature ___clang_expr(void*) is added to that class, so that Clang doesn't complain about a method being defined without a corresponding declaration. - Whenever the expression gets called, "this" gets looked up, type-checked, and then passed in as the first argument. This required the following changes: - The ABIs were changed to support passing of the "this" pointer as part of trivial calls. - ThreadPlanCallFunction and ClangFunction were changed to support passing of an optional "this" pointer. - ClangUserExpression was extended to perform the wrapping described above. - ClangASTSource was changed to revert the changes required by the hack. - ClangExpressionParser, IRForTarget, and ClangExpressionDeclMap were changed to handle different manglings of ___clang_expr flexibly. This meant no longer searching for a function called ___clang_expr, but rather looking for a function whose name *contains* ___clang_expr. - ClangExpressionParser and ClangExpressionDeclMap now remember whether "this" is required, and know how to look it up as necessary. A few inheritance bugs remain, and I'm trying to resolve these. But it is now possible to use "this" as well as refer implicitly to member variables, when in the proper context. llvm-svn: 114384
* Moved the section load list up into the target so we can use the targetGreg Clayton2010-09-141-4/+4
| | | | | | to symbolicate things without the need for a valid process subclass. llvm-svn: 113895
* Added code to support use of "this" and "self" inSean Callanan2010-09-141-9/+60
| | | | | | | | | | | | | | | | | | | | | expressions. This involved three main changes: - In ClangUserExpression::ClangUserExpression(), we now insert the following lines into the expression: #define this ___clang_this #define self ___clang_self - In ClangExpressionDeclMap::GetDecls(), we special-case ___clang_(this|self) and instead look up "this" or "self" - In ClangASTSource, we introduce the capability to generate Decls with a different, overridden, name from the one that was requested, e.g. this for ___clang_this. llvm-svn: 113866
* Looking at some of the test suite failures in DWARF in .o files with theGreg Clayton2010-09-141-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | debug map showed that the location lists in the .o files needed some refactoring in order to work. The case that was failing was where a function that was in the "__TEXT.__textcoal_nt" in the .o file, and in the "__TEXT.__text" section in the main executable. This made symbol lookup fail due to the way we were finding a real address in the debug map which was by finding the section that the function was in in the .o file and trying to find this in the main executable. Now the section list supports finding a linked address in a section or any child sections. After fixing this, we ran into issue that were due to DWARF and how it represents locations lists. DWARF makes a list of address ranges and expressions that go along with those address ranges. The location addresses are expressed in terms of a compile unit address + offset. This works fine as long as nothing moves around. When stuff moves around and offsets change between the remapped compile unit base address and the new function address, then we can run into trouble. To deal with this, we now store supply a location list slide amount to any location list expressions that will allow us to make the location list addresses into zero based offsets from the object that owns the location list (always a function in our case). With these fixes we can now re-link random address ranges inside the debugger for use with our DWARF + debug map, incremental linking, and more. Another issue that arose when doing the DWARF in the .o files was that GCC 4.2 emits a ".debug_aranges" that only mentions functions that are externally visible. This makes .debug_aranges useless to us and we now generate a real address range lookup table in the DWARF parser at the same time as we index the name tables (that are needed because .debug_pubnames is just as useless). llvm-gcc doesn't generate a .debug_aranges section, though this could be fixed, we aren't going to rely upon it. Renamed a bunch of "UINT_MAX" to "UINT32_MAX". llvm-svn: 113829
* Bugfixes to the expression parser. Fixes include:Sean Callanan2010-09-131-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - If you put a semicolon at the end of an expression, this no longer causes the expression parser to error out. This was a two-part fix: first, ClangExpressionDeclMap::Materialize now handles an empty struct (such as when there is no return value); second, ASTResultSynthesizer walks backward from the end of the ASTs until it reaches something that's not a NullStmt. - ClangExpressionVariable now properly byte-swaps when printing itself. - ClangUtilityFunction now cleans up after itself when it's done compiling itself. - Utility functions can now use external functions just like user expressions. - If you end your expression with a statement that does not return a value, the expression now runs correctly anyway. Also, added the beginnings of an Objective-C object validator function, which is neither installed nor used as yet. llvm-svn: 113789
* There was a check to make sure that the frame had a valid function before ↵Greg Clayton2010-09-101-10/+1
| | | | | | the expression parser would allow decl lookups which was not needed. After removing this you can evaluate expressions correctly when stopped in a frame that only has a symbol or has no symbol context at all. llvm-svn: 113611
* There is currently a problem with our interactionSean Callanan2010-09-081-0/+8
| | | | | | | | | with the Clang parser that prevents us from passing Objective-C types to functions that expect C types. This quick hack keeps us in business until that interaction is fixed. llvm-svn: 113429
* Improved function lookup to avoid conflicts betweenSean Callanan2010-09-071-3/+18
| | | | | | | | | symbols with the same name and no debug information. Also improved the way functions are called so we don't automatically define them as variadic functions in the IR. llvm-svn: 113290
* Fixed a bug where the parser-specific members ofSean Callanan2010-08-301-11/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | persistent variables were staying around too long. This caused the following problem: - A persistent result variable is created for the result of an expression. The pointer to the corresponding Decl is stored in the variable. - The persistent variable is looked up during struct generation (correctly) using its Decl. - Another expression defines a new result variable which happens to have a Decl in the same place as the original result variable. - The persistent variable is looked up during struct generation using its Decl, but the old result variable appears first in the list and has the same Decl pointer. The fix is to destroy parser-specific data when it is no longer valid. Also improved some logging as I diagnosed the bug. llvm-svn: 112540
* Refactored ClangExpressionDeclMap to useSean Callanan2010-08-231-184/+154
| | | | | | | | ClangExpressionVariables for found external variables as well as for struct members, replacing the Tuple and StructMember data structures. llvm-svn: 111859
* Modified the host process monitor callback function ↵Greg Clayton2010-08-211-14/+7
| | | | | | | | | | | | | | | | | | Host::StartMonitoringChildProcess to spawn a thread for each process that is being monitored. Previously LLDB would spawn a single thread that would wait for any child process which isn't ok to do as a shared library (LLDB.framework on Mac OSX, or lldb.so on linux). The old single thread used to call wait4() with a pid of -1 which could cause it to reap child processes that it shouldn't have. Re-wrote the way Function blocks are handles. Previously I attempted to keep all blocks in a single memory allocation (in a std::vector). This made the code somewhat efficient, but hard to work with. I got rid of the old BlockList class, and went to a straight parent with children relationship. This new approach will allow for partial parsing of the blocks within a function. llvm-svn: 111706
* First step of refactoring variable handling in theSean Callanan2010-08-201-16/+13
| | | | | | | | | | | | | | | expression parser. There shouldn't be four separate classes encapsulating a variable. ClangExpressionVariable is now meant to be the container for all variable information. It has several optional components that hold data for different subsystems. ClangPersistentVariable has been removed; we now use ClangExpressionVariable instead. llvm-svn: 111600
* Added documentation to ClangExpressionDeclMap.Sean Callanan2010-08-131-3/+2
| | | | | | | | Also cleaned up its API a tiny bit (but not the extensive amount that is actually needed. That's still coming.) llvm-svn: 111049
* Added automatically generated result variables for eachSean Callanan2010-08-121-35/+56
| | | | | | | | | | | | | | | | | | | | expression. It is now possible to do things like this: (lldb) expr int $i = 5; $i + 1 $0 = (int) 6 (lldb) expr $i + 3 $1 = (int) 8 (lldb) expr $1 + $0 $2 = (int) 14 As a bonus, this allowed us to move printing of expression results into the ClangPersistentVariable class. This code needs a bit of refactoring -- in particular, ClangExpressionDeclMap has eaten one too many bacteria and needs to undergo mitosis -- but the infrastructure appears to be holding up nicely. llvm-svn: 110896
* Added support for persistent variables to theSean Callanan2010-08-111-26/+122
| | | | | | | | | | | | | | | | | | | | | | | | | expression parser. It is now possible to type: (lldb) expr int $i = 5; $i + 1 (int) 6 (lldb) expr $i + 2 (int) 7 The skeleton for automatic result variables is also implemented. The changes affect: - the process, which now contains a ClangPersistentVariables object that holds persistent variables associated with it - the expression parser, which now uses the persistent variables during variable lookup - TaggedASTType, where I loaded some commonly used tags into a header so that they are interchangeable between different clients of the class llvm-svn: 110777
* Removed the -i option from the expr command, andSean Callanan2010-08-061-1/+3
| | | | | | | | | | | | made IR-based expression evaluation the default. Also added a new class to hold persistent variables. The class is empty as yet while I write up a design document for what it will do. Also the place where it is currently created (by the Expression command) is certainly wrong. llvm-svn: 110415
* Added support for accessing members of C++ objects,Sean Callanan2010-08-041-0/+19
| | | | | | | | | | | | | including superclass members. This involved ensuring that access control was ignored, and ensuring that the operands of BitCasts were properly scanned for variables that needed importing. Also laid the groundwork for declaring objects of custom types; however, this functionality is disabled for now because of a potential loop in ASTImporter. llvm-svn: 110174
* Added support for objective C built-in types: id, Class, and SEL. This Greg Clayton2010-08-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | involved watching for the objective C built-in types in DWARF and making sure when we convert the DWARF types into clang types that we use the appropriate ASTContext types. Added a way to find and dump types in lldb (something equivalent to gdb's "ptype" command): image lookup --type <TYPENAME> This only works for looking up types by name and won't work with variables. It also currently dumps out verbose internal information. I will modify it to dump more appropriate user level info in my next submission. Hookup up the "FindTypes()" functions in the SymbolFile and SymbolVendor so we can lookup types by name in one or more images. Fixed "image lookup --address <ADDRESS>" to be able to correctly show all symbol context information, but it will only show this extra information when the new "--verbose" flag is used. Updated to latest LLVM to get a few needed fixes. llvm-svn: 110089
* Added support for rewriting objc_msgSend so we canSean Callanan2010-07-311-3/+36
| | | | | | | | | | | call Objective-C methods from expressions. Also added some more logging to the function-calling thread plan so that we can see the registers when a function finishes. Also documented things maybe a bit better. llvm-svn: 109938
* Added support for calling functions from expressions.Sean Callanan2010-07-271-4/+10
| | | | | | | | | Right now we mock up the function as a variadic function when generating the IR for the call; we need to eventually make the function be the right type if the type is available. llvm-svn: 109543
* Added support for locating a function that isSean Callanan2010-07-271-0/+18
| | | | | | | referenced in the IR. We don't yet support updating the call to that function. llvm-svn: 109483
* Changed SymbolContext so when you search for functionsSean Callanan2010-07-271-26/+60
| | | | | | | | | | | | | | | | | | it returns a list of functions as a SymbolContextList. Rewrote the clients of SymbolContext to use this SymbolContextList. Rewrote some of the providers of the data to SymbolContext to make them respect preferences as to whether the list should be cleared first; propagated that change out. ClangExpressionDeclMap and ClangASTSource use this new function list to properly generate function definitions - even for functions that don't have a prototype in the debug information. llvm-svn: 109476
* Updated the IR converter for the target to eliminateSean Callanan2010-07-241-0/+6
| | | | | | | | | | | | spurious guard variables on expression statics. Updated the AST result synthesizer to eliminate the unneeded result pointer. Very rudimentary expressions now evaluate correctly in the target using the new JIT-based mechanism. llvm-svn: 109317
* Added logging:Sean Callanan2010-07-231-0/+65
| | | | | | | | | | - When we JIT an expression, we print the disassembly of the generated code - When we put the structure into the target, we print the individual entries in the structure byte for byte. llvm-svn: 109278
* Modified TaggedASTType to inherit from ClangASTTypeSean Callanan2010-07-231-11/+8
| | | | | | | | | | | | | and moved it to its own header file for cleanliness. Added more logging to ClangFunction so that we can diagnose crashes in the executing expression. Added code to extract the result of the expression from the struct that is passed to the JIT-compiled code. llvm-svn: 109199
* Change over to using the definitions for mach-o types and defines to theGreg Clayton2010-07-211-6/+13
| | | | | | | | | | | defines that are in "llvm/Support/MachO.h". This should allow ObjectFileMachO and ObjectContainerUniversalMachO to be able to be cross compiled in Linux. Also did some cleanup on the ASTType by renaming it to ClangASTType and renaming the header file. Moved a lot of "AST * + opaque clang type *" functionality from lldb_private::Type over into ClangASTType. llvm-svn: 109046
* Added functionality to dematerialize values that wereSean Callanan2010-07-201-126/+187
| | | | | | | | | | | | | | used by the JIT compiled expression, including the result of the expression. Also added a new class, ASTType, which encapsulates an opaque Clang type and its associated AST context. Refactored ClangExpressionDeclMap to use ASTTypes, significantly reducing the possibility of mixups of types from different AST contexts. llvm-svn: 108965
* Added the necessary code to copy variables used bySean Callanan2010-07-171-87/+197
| | | | | | | an expression into the struct prepared for the JIT compiled code to use. llvm-svn: 108596
* Wrote the code that looks at a context to seeSean Callanan2010-07-161-23/+175
| | | | | | | if the variables in that context allow a particular JIT compiled expression to run in that context. llvm-svn: 108485
* "expr -i" now performs the required transforms toSean Callanan2010-07-131-1/+101
| | | | | | | | prepare the IR for JIT compilation. We still need to do the JIT compilation and move the arguments in/out of target memory. llvm-svn: 108279
* Updated the expression parser to use proper logging when Sean Callanan2010-06-231-18/+22
| | | | | | | looking for external variables. Also cleaned up the log messages coming from the DWARF interpreter. llvm-svn: 106613
* Added support to the expression parser for locatingSean Callanan2010-06-221-5/+54
| | | | | | externally-defined functions. llvm-svn: 106606
* Initial checkin of lldb code from internal Apple repo.Chris Lattner2010-06-081-0/+246
llvm-svn: 105619
OpenPOWER on IntegriCloud