summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/IRForTarget.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Implemented a feature where the expression parserSean Callanan2010-12-161-25/+74
| | | | | | | | | | | | | 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
* Added support for generating expressions that haveSean Callanan2010-12-131-2/+51
| | | | | | | | | | | | | | 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
* Fixes to make id work as well as well as fix minor errorsSean Callanan2010-12-061-0/+4
| | | | | | when calling built-ins. llvm-svn: 121070
* Fixed a bug in which the SEL type was being resolvedSean Callanan2010-12-061-1/+1
| | | | | | | | wrongly as the target of a pointer rather than the SEL pointer itself. This caused incorrect behavior when dealing with Objective-C selector variables. llvm-svn: 121048
* Fixed a problem in which non-external variablesSean Callanan2010-12-061-0/+3
| | | | | | | (for example, string literals) were being flagged erroneously as undefined external variables. llvm-svn: 120972
* Eliminated a redundant code path.Sean Callanan2010-12-031-1/+1
| | | | llvm-svn: 120834
* Removed a compiler warning.Sean Callanan2010-12-031-1/+1
| | | | llvm-svn: 120788
* Fixed IRForTarget so that it errors out when functionSean Callanan2010-12-021-4/+21
| | | | | | | pointers are used. Previously, they caused a crash in the JIT because we didn't resolve them correctly. llvm-svn: 120728
* Removed a stray dump().Sean Callanan2010-11-201-3/+1
| | | | llvm-svn: 119888
* Added some logging back and cleaned up the code to match LLDB's codingGreg Clayton2010-11-191-118/+110
| | | | | | conventions. llvm-svn: 119771
* Fixed the logic in IRForTarget that recognizesSean Callanan2010-11-181-4/+4
| | | | | | | externally-defined variables to match up with the code in ClangASTSource that produces them. llvm-svn: 119750
* Added support for constant strings of the form @"this-is-a-string".Sean Callanan2010-11-171-39/+349
| | | | | | | They are replaced with calls to the CoreFoundation function CFStringCreateWithBytes() by a portion of the IRForTarget pass. llvm-svn: 119582
* Added quotes around names that are being lookup up or inspected in the Greg Clayton2010-11-151-26/+26
| | | | | | | | | | | expression logging. Added some properties to the "objc" test. The expression parser can currently display properties that are backed by the default functions "expr myStr.string" will work. But it won't currently work when the property is backed by a different function such as "expr myStr.date". llvm-svn: 119103
* Made variable resolution more robust by handlingSean Callanan2010-11-081-25/+27
| | | | | | | | | every external variable reference in the module, and returning a clean error (instead of letting LLVM issue a fatal error) if the variable could not be resolved. llvm-svn: 118388
* Modified all logging calls to hand out shared pointers to make sure weGreg Clayton2010-11-061-10/+10
| | | | | | | | | | | don't crash if we disable logging when some code already has a copy of the logger. Prior to this fix, logs were handed out as pointers and if they were held onto while a log got disabled, then it could cause a crash. Now all logs are handed out as shared pointers so this problem shouldn't happen anymore. We are also using our new shared pointers that put the shared pointer count and the object into the same allocation for a tad better performance. llvm-svn: 118319
* Fixed a bug where variables in the source operandsSean Callanan2010-11-061-1/+2
| | | | | | | of store statements were not being marked for resolution. llvm-svn: 118316
* Fixed a bug where we left a definition hangingSean Callanan2010-11-021-0/+3
| | | | | | | for a global variable that we had replaced with a reference to a slot in the input array. llvm-svn: 118123
* Fixed a problem where function calls on i386 weren't Sean Callanan2010-10-261-0/+3
| | | | | | | | | being generated correctly. Also added a messy way to single-step through expressions that I will improve soon. llvm-svn: 117342
* Fixed IRForTarget to not recognize $__lldb variablesSean Callanan2010-10-211-1/+2
| | | | | | | as persistent variables. These are special markers used by LLDB. llvm-svn: 117078
* Made many ConstString functions inlined in the header file.Greg Clayton2010-10-151-60/+68
| | | | | | | | | | | | | | | | | | | 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
* Added handling for external variables in functionSean Callanan2010-10-051-0/+20
| | | | | | | arguments to the expression parser. This means that structs can be returned from the "expr" command. llvm-svn: 115698
* Switched the expression parser from using TargetDataSean Callanan2010-09-301-16/+37
| | | | | | | | | | | | to using Clang to get type sizes. This fixes a bug where the type size for a double[2] was being wrongly reported as 8 instead of 16 bytes, causing problems for IRForTarget. Also improved logging so that the next bug in this area will be easier to find. llvm-svn: 115208
* Removed a dreadful hack to get at the name of theSean Callanan2010-09-281-23/+19
| | | | | | | intrinsic being used. Thanks to Chris Lattner for pointing out the proper way to do it. llvm-svn: 115006
* Fixed two bugs in the expression parser:Sean Callanan2010-09-281-8/+44
| | | | | | | | | | | | - the guard variable for the static result variable was being mistaken for the actual result value, causing IRForTarget to fail - LLVM builtins like memcpy were not being properly resolved; now they are resolved to the corresponding function in the target llvm-svn: 114990
* Updated to latest LLVM. Major LLVM changes:Sean Callanan2010-09-231-4/+14
| | | | | | | | | | - 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
* Removed the hacky "#define this ___clang_this" handlerSean Callanan2010-09-211-4/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Bugfixes to the expression parser. Fixes include:Sean Callanan2010-09-131-10/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* Fixed an expression parser bug that preventedSean Callanan2010-09-081-1/+17
| | | | | | | | | | | | | | | certain functions from being resolved correctly. Some functions (particularly varargs functions) are BitCast before being called, and the problem was that a CallInst where getCalledValue() returned a BitCast ConstantExpr was not being relocated at all. This problem should now be resolved for the case of BitCast. llvm-svn: 113396
* Fixed a bug where we did not handle constantSean Callanan2010-09-071-3/+34
| | | | | | | | | | | | | | | | expressions correctly. These produced a result variable with an initializer but no store instruction, and the store instruction was as a result never rewritten to become a store to a persistent variable. Now if the result variable has an initializer but is never used, we generate a (redundant) store instruction for it, which is then later rewritten into a (useful) store to the persistent result variable. llvm-svn: 113300
* Improved function lookup to avoid conflicts betweenSean Callanan2010-09-071-7/+10
| | | | | | | | | 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-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* This is a major refactoring of the expression parser.Sean Callanan2010-08-271-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal is to separate the parser's data from the data belonging to the parser's clients. This allows clients to use the parser to obtain (for example) a JIT compiled function or some DWARF code, and then discard the parser state. Previously, parser state was held in ClangExpression and used liberally by ClangFunction, which inherited from ClangExpression. The main effects of this refactoring are: - reducing ClangExpression to an abstract class that declares methods that any client must expose to the expression parser, - moving the code specific to implementing the "expr" command from ClangExpression and CommandObjectExpression into ClangUserExpression, a new class, - moving the common parser interaction code from ClangExpression into ClangExpressionParser, a new class, and - making ClangFunction rely only on ClangExpressionParser and not depend on the internal implementation of ClangExpression. Side effects include: - the compiler interaction code has been factored out of ClangFunction and is now in an AST pass (ASTStructExtractor), - the header file for ClangFunction is now fully documented, - several bugs that only popped up when Clang was deallocated (which never happened, since the lifetime of the compiler was essentially infinite) are now fixed, and - the developer-only "call" command has been disabled. I have tested the expr command and the Objective-C step-into code, which use ClangUserExpression and ClangFunction, respectively, and verified that they work. Please let me know if you encounter bugs or poor documentation. llvm-svn: 112249
* Refactored ClangExpressionDeclMap to useSean Callanan2010-08-231-9/+7
| | | | | | | | ClangExpressionVariables for found external variables as well as for struct members, replacing the Tuple and StructMember data structures. llvm-svn: 111859
* First step of refactoring variable handling in theSean Callanan2010-08-201-1/+1
| | | | | | | | | | | | | | | 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
* Patch by Bill Lynch fixing handling of the pidSean Callanan2010-08-181-3/+4
| | | | | | in the IR transformation passes. llvm-svn: 111388
* Added documentation to ClangExpressionDeclMap.Sean Callanan2010-08-131-2/+1
| | | | | | | | 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-3/+137
| | | | | | | | | | | | | | | | | | | | 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-23/+128
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Added support for accessing members of C++ objects,Sean Callanan2010-08-041-1/+5
| | | | | | | | | | | | | 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
* Set a CodeGenOption in Clang to inhibit insertionSean Callanan2010-08-031-0/+8
| | | | | | | | | | of profiling code into expressions. Modified IRForTarget to emit array and record member accesses correctly. (Reading and writing both work.) llvm-svn: 110088
* Added support for rewriting objc_msgSend so we canSean Callanan2010-07-311-29/+220
| | | | | | | | | | | 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
* Updated to llvm/clang from July 30, 2010 at 08:00.Greg Clayton2010-07-301-1/+1
| | | | llvm-svn: 109887
* Added and improved logging. This is helping us as weSean Callanan2010-07-281-8/+10
| | | | | | | diagnose a problem where we're not correctly emitting PIC code. llvm-svn: 109568
* Added support for calling functions from expressions.Sean Callanan2010-07-271-20/+37
| | | | | | | | | 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-10/+48
| | | | | | | referenced in the IR. We don't yet support updating the call to that function. llvm-svn: 109483
* Fixed a bug in the IR transformer where we wereSean Callanan2010-07-271-1/+10
| | | | | | | | trying to do replaceUsesOfWith on a constant, which doesn't work. Turns out we don't need to do anything for constants. llvm-svn: 109477
* Updated the IR converter for the target to eliminateSean Callanan2010-07-241-0/+82
| | | | | | | | | | | | 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 functionality to dematerialize values that wereSean Callanan2010-07-201-1/+8
| | | | | | | | | | | | | | 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
* Wrote the code that looks at a context to seeSean Callanan2010-07-161-1/+15
| | | | | | | if the variables in that context allow a particular JIT compiled expression to run in that context. llvm-svn: 108485
* Fixes to the IR generator in the expression parserSean Callanan2010-07-141-2/+109
| | | | | | | | to correctly unfold constant-folded global variables. Also added code to JIT the expression. Simple expressions are now JIT compiled successfully. llvm-svn: 108380
OpenPOWER on IntegriCloud