summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/IRForTarget.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Update declarations for all functions/methods that accept printf-styleJason Molenda2011-09-201-4/+4
| | | | | | | | 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
* This patch modifies the expression parser to allow itSean Callanan2011-09-151-39/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fixed a problem that prevented access to membersSean Callanan2011-08-101-10/+36
| | | | | | | | | | | of string literals ("hello"[2]). Also fixed a problem in which empty string literals were not being compiled correctly ((int)printf("") would print garbage). Added a testcase that covers both. llvm-svn: 137247
* Check log shared pointer before using it.Johnny Chen2011-08-091-3/+8
| | | | llvm-svn: 137173
* Fixed a problem that caused LLDB to fail to executeSean Callanan2011-08-041-191/+154
| | | | | | | | | | | | | | | | | | | | expressions that used function pointers. The problem was that IRForTarget previously only scanned the IR for the expression for call instructions; if a function was used in another context, it was ignored. Now LLDB scans the Module for functions that are only declared (not also defined -- so these are externals); it then constructs function pointers for these functions and substitutes them wherever the function is used. Also made some changes so that "expr main" works just as well as "expr &main"; they end up being the same code, but LLDB was generating the result variable in different ways. llvm-svn: 136928
* Fixed a problem in the expression parser that Sean Callanan2011-08-011-1/+28
| | | | | | | | | | | | | | caused functions that were cast as part of the call to have that cast ignored once their addresses were resolved. Notably, in the case of objc_msgSend(), if the function was cast from something returning i8* to something returning i8, the expression parser was discarding the cast as part of its resolution. This caused crashes later on. llvm-svn: 136648
* Fixed a bug where named constants were beingSean Callanan2011-08-011-2/+17
| | | | | | | | | | | | | | treated as externals, causing problems when we tried to look their locations up in the debug info. For example: expr char c[] = "foo"; c[0] would terminate when trying to find c in the debug information, despite the fact that c was defined inside the expression. llvm-svn: 136629
* This change brings in the latest LLVM/Clang, andSean Callanan2011-07-301-63/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | completes the support in the LLDB expression parser for incomplete types. Clang now imports types lazily, and we complete those types as necessary. Changes include: - ClangASTSource now supports three APIs which it passes to ClangExpressionDeclMap. CompleteType completes a TagDecl or an ObjCInterfaceDecl when needed; FindExternalVisibleDecls finds named entities that are visible in the expression's scope; and FindExternalLexicalDecls performs a (potentially restricted) search for entities inside a lexical scope like a namespace. These changes mean that entities in namespaces should work normally. - The SymbolFileDWARF code for searching a context for a specific name is now more general, and can search arbitrary contexts. - We are continuing to adapt our calls into LLVM from interfaces that take start and end iterators when accepting multiple items to interfaces that use ArrayRef. - I have cleaned up some code, especially our use of namespaces. This change is neutral for our testsuite and greatly improves correctness for large programs (like Clang) with complicated type systems. It should also lay the groundwork for improving the expression parser's performance as we are lazier and lazier about providing type information. llvm-svn: 136555
* 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-3/+3
| | | | | | | | | | | | | | | | | | | | | 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
* Audited the expression parser to find uninitializedSean Callanan2011-07-081-10/+8
| | | | | | | | | pointers. Some of the spots are obviously initialized later, but it's better just to NULL the pointers out at initialization to make the code more robust when exposed to later changes. llvm-svn: 134670
* Fixed an issue for ARM where data symbols would alway return invalid addresses.Greg Clayton2011-06-231-2/+2
| | | | llvm-svn: 133684
* ABI plug-ins must implement the following pure virtual functions:Greg Clayton2011-05-241-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | virtual bool ABI::StackUsesFrames () = 0; Should return true if your ABI uses frames when doing stack backtraces. This means a frame pointer is used that points to the previous stack frame in some way or another. virtual bool ABI::CallFrameAddressIsValid (lldb::addr_t cfa) = 0; Should take a look at a call frame address (CFA) which is just the stack pointer value upon entry to a function. ABIs usually impose alignment restrictions (4, 8 or 16 byte aligned), and zero is usually not allowed. This function should return true if "cfa" is valid call frame address for the ABI, and false otherwise. This is used by the generic stack frame unwinding code to help determine when a stack ends. virtual bool ABI::CodeAddressIsValid (lldb::addr_t pc) = 0; Validates a possible PC value and returns true if an opcode can be at "pc". Some ABIs or architectures have fixed width instructions and must be aligned to a 2 or 4 byte boundary. "pc" can be an opcode or a callable address which means the load address might be decorated with extra bits (such as bit zero to indicate a thumb function call for ARM targets), so take this into account when returning true or false. The address should also be validated to ensure it is a valid address for the address size of the inferior process. 32 bit targets should make sure the address is less than UINT32_MAX. Modified UnwindLLDB to use the new ABI functions to help it properly terminate stacks. Modified the mach-o function that extracts dependent files to not resolve the path as the paths inside a binary might not match those on the current host system. llvm-svn: 132021
* This commit integrates support for the LLVM MCJITSean Callanan2011-05-231-86/+428
| | | | | | | | | | | | | | | | | | | | | | | 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
* Updated to use the latest LLVM/Clang, to pick up JITSean Callanan2011-05-151-3/+9
| | | | | | changes. llvm-svn: 131391
* Added support for reading untyped symbols. Right nowSean Callanan2011-05-081-1/+1
| | | | | | | they are treated as pointers of type (void*). This allows reading of environ, for instance. llvm-svn: 131063
* Made expressions that are just casts of pointer Sean Callanan2011-05-071-94/+193
| | | | | | | | | | | | 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
* Updated LLVM to pick up fixes to the ARM instructionSean Callanan2011-04-141-0/+1
| | | | | | tables. llvm-svn: 129500
* Order of initialization lists.Stephen Wilson2011-04-111-4/+4
| | | | | | | | This patch fixes all of the warnings due to unordered initialization lists. Patch by Marco Minutoli. llvm-svn: 129290
* Fixes for two bugs:Sean Callanan2011-02-101-7/+22
| | | | | | | | | | | | | - Objective-C constant strings were being NULL-terminated erroneously. - Empty Objective-C constant strings were not being generated correctly. Also added the template for a test of these fixes. llvm-svn: 125314
* Fixed an excessive ctor issue. Patch from Kirk Beitz / Jai Menon.Greg Clayton2011-02-051-3/+3
| | | | llvm-svn: 124928
* Updated Clang to a version that supports propagatingSean Callanan2011-01-271-2/+7
| | | | | | | | the "virtual" flag when importing a C++ function declaration. Made changes to LLDB to support other changes in Clang. llvm-svn: 124355
* Added error reporting to IRForTarget so that theSean Callanan2011-01-271-8/+215
| | | | | | | user doesn't have to enable logging to see where something went wrong. llvm-svn: 124342
* Added a safeguard to ensure that the user does not create variables that ↵Sean Callanan2011-01-211-2/+16
| | | | | | override persistent result variables. llvm-svn: 124001
* Added support for the fragile ivars provided bySean Callanan2011-01-171-3/+48
| | | | | | | Apple's Objective-C 2.0 runtime. They are enabled if the Objective-C runtime has the proper version. llvm-svn: 123694
* Fixed handling of explicitly-declared persistentSean Callanan2011-01-131-5/+19
| | | | | | variables. llvm-svn: 123398
* Implemented a major overhaul of the way variables are handledSean Callanan2011-01-131-17/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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
OpenPOWER on IntegriCloud