summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/ClangExpressionParser.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* This commit changes the way LLDB executes userSean Callanan2013-04-181-37/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | expressions. Previously, ClangUserExpression assumed that if there was a constant result for an expression then it could be determined during parsing. In particular, the IRInterpreter ran while parser state (in particular, ClangExpressionDeclMap) was present. This approach is flawed, because the IRInterpreter actually is capable of using external variables, and hence the result might be different each run. Until now, we papered over this flaw by re-parsing the expression each time we ran it. I have rewritten the IRInterpreter to be completely independent of the ClangExpressionDeclMap. Instead of special-casing external variable lookup, which ties the IRInterpreter closely to LLDB, we now interpret the exact same IR that the JIT would see. This IR assumes that materialization has occurred; hence the recent implementation of the Materializer, which does not require parser state (in the form of ClangExpressionDeclMap) to be present. Materialization, interpretation, and dematerialization are now all independent of parsing. This means that in theory we can parse expressions once and run them many times. I have three outstanding tasks before shutting this down: - First, I will ensure that all of this works with core files. Core files have a Process but do not allow allocating memory, which currently confuses materialization. - Second, I will make expression breakpoint conditions remember their ClangUserExpression and re-use it. - Third, I will tear out all the redundant code (for example, materialization logic in ClangExpressionDeclMap) that is no longer used. While implementing this fix, I also found a bug in IRForTarget's handling of floating-point constants. This should be fixed. llvm-svn: 179801
* Since we use C++11, we should switch over to using std::unique_ptr when ↵Greg Clayton2013-04-181-12/+12
| | | | | | | | C++11 is being used. To do this, we follow what we have done for shared pointers and we define a STD_UNIQUE_PTR macro that can be used and it will "do the right thing". Due to some API differences in std::unique_ptr and due to the fact that we need to be able to compile without C++11, we can't use move semantics so some code needed to change so that it can compile with either C++. Anyone wanting to use a unique_ptr or auto_ptr should now use the "STD_UNIQUE_PTR(TYPE)" macro. llvm-svn: 179779
* Flipped the big switch: LLDB now uses the new Sean Callanan2013-04-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Materializer for all expressions that need to run in the target. This includes the following changes: - Removed a bunch of (de-)materialization code from ClangExpressionDeclMap and assumed the presence of a Materializer where we previously had a fallback. - Ensured that an IRMemoryMap is passed into ClangExpressionDeclMap::Materialize(). - Fixed object ownership on LLVMContext; it is now owned by the IRExecutionUnit, since the Module and the ExecutionEngine both depend on its existence. - Fixed a few bugs in IRMemoryMap and the Materializer that showed up during testing. llvm-svn: 179649
* Audited the existing Materializer code to ensureSean Callanan2013-04-151-1/+1
| | | | | | | | that it works in the absence of a process. Codepaths in the Materializer now use the best execution context scope available to them. llvm-svn: 179539
* Factored out memory access into the target processSean Callanan2013-04-051-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from IRExecutionUnit into a superclass called IRMemoryMap. IRMemoryMap handles all reading and writing, ensuring that areas are kept track of and memory is properly cached (and deleted). Also fixed several cases where we would simply leak binary data in the target process over time. Now the expression objects explicitly own their IRExecutionUnit and delete it when they go away. This is why I had to modify ClangUserExpression, ClangUtilityFunction, and ClangFunction. As a side effect of this, I am removing the JIT mutex for an IRMemoryMap. If it turns out that we need this mutex, I'll add it in then, but right now it's just adding complexity. This is part of a more general project to make expressions fully reusable. The next step is to make materialization and dematerialization use the IRMemoryMap API rather than writing and reading directly from the process's memory. This will allow the IR interpreter to use the same data, but in the host's memory, without having to use a different set of pointers. llvm-svn: 178832
* Enabled blocks support in the expression parser.Sean Callanan2013-04-011-0/+1
| | | | | | | | | | | Note: although it is now possible to declare blocks and call them inside the same expression, we do not generate correct block descriptors so these blocks cannot be passed to functions like dispatch_async. <rdar://problem/12578656> llvm-svn: 178509
* Disable warnings from Clang correctly, by directlySean Callanan2013-03-301-2/+2
| | | | | | | | manipulating the diagnostics engine. <rdar://problem/13508470> llvm-svn: 178399
* <rdar://problem/13521159>Greg Clayton2013-03-271-1/+1
| | | | | | | | LLDB is crashing when logging is enabled from lldb-perf-clang. This has to do with the global destructor chain as the process and its threads are being torn down. All logging channels now make one and only one instance that is kept in a global pointer which is never freed. This guarantees that logging can correctly continue as the process tears itself down. llvm-svn: 178191
* Refactored the expression parser so that the IRSean Callanan2013-03-191-274/+18
| | | | | | | | | | | | | | | | | | | | | | | | | and the JITted code are managed by a standalone class that handles memory management itself. I have removed RecordingMemoryManager and ProcessDataAllocator, which filled similar roles and had confusing ownership, with a common class called IRExecutionUnit. The IRExecutionUnit manages all allocations ever made for an expression and frees them when it goes away. It also contains the code generator and can vend the Module for an expression to other clases. The end goal here is to make the output of the expression parser re-usable; that is, to avoid re-parsing when re-parsing isn't necessary. I've also cleaned up some code and used weak pointers in more places. Please let me know if you see any leaks; I checked myself as well but I might have missed a case. llvm-svn: 177364
* Removed One Definition Rule warnings because they'reSean Callanan2013-03-081-0/+1
| | | | | | | | noisy when dealing with anonymous structs. <rdar://problem/13246914> llvm-svn: 176738
* Convert from the C-based LLVM Disassembler shim to the full MC Disassembler ↵Jim Ingham2013-03-021-1/+3
| | | | | | | | | | | | API's. Calculate "can branch" using the MC API's rather than our hand-rolled regex'es. As extra credit, allow setting the disassembly flavor for x86 based architectures to intel or att. <rdar://problem/11319574> <rdar://problem/9329275> llvm-svn: 176392
* Change to JITDefault code model for ELF targetsAndrew Kaylor2013-02-211-1/+9
| | | | | | On x86-64 platforms, the small code model assumes that code will be loaded below the 2GB boundary. With the static relocation model, the fact that the expression code is initially loaded (in the LLDB debugger address space) above that boundary causes problems. Switching to the JITDefault code model causes the large code model to be used for 64-bit targets and small code model of 32-bit targets. llvm-svn: 175828
* Fixed a bug where certain vector code didn'tSean Callanan2013-02-211-0/+10
| | | | | | | | | work on i386. Now we let the JIT emit SSE/SSE2 instructions on i386. <rdar://problem/13240476> llvm-svn: 175700
* Change ELF relocation model to staticAndrew Kaylor2013-02-201-1/+6
| | | | llvm-svn: 175671
* Bring lldb up to date with clang revision 175141.Filipe Cabecinhas2013-02-141-0/+1
| | | | llvm-svn: 175213
* <rdar://problem/13069948>Greg Clayton2013-01-251-1/+1
| | | | | | | | | | | | Major fixed to allow reading files that are over 4GB. The main problems were that the DataExtractor was using 32 bit offsets as a data cursor, and since we mmap all of our object files we could run into cases where if we had a very large core file that was over 4GB, we were running into the 4GB boundary. So I defined a new "lldb::offset_t" which should be used for all file offsets. After making this change, I enabled warnings for data loss and for enexpected implicit conversions temporarily and found a ton of things that I fixed. Any functions that take an index internally, should use "size_t" for any indexes and also should return "size_t" for any sizes of collections. llvm-svn: 173463
* Quick fix to make LLDB TOT work with Clang TOT.Sean Callanan2013-01-221-1/+1
| | | | | | | Avoids an error about an ambiguous constructor call. llvm-svn: 173118
* Update to reflect API changes in r171367.Chandler Carruth2013-01-021-2/+2
| | | | llvm-svn: 171381
* Rewrite #includes for llvm/Foo.h to llvm/IR/Foo.h as appropriate to reflect theChandler Carruth2013-01-021-2/+2
| | | | | | | | | migration in r171366. I don't know anything about lldb, but a force run of the build bot indicated it would need this patch. I'll try to watch the build bot to get it green. llvm-svn: 171374
* Fix Linux build warnings due to redefinition of macros:Daniel Malea2012-12-051-0/+2
| | | | | | | | | - add new header lldb-python.h to be included before other system headers - short term fix (eventually python dependencies must be cleaned up) Patch by Matt Kopec! llvm-svn: 169341
* Resolve printf formatting warnings on Linux:Daniel Malea2012-11-291-2/+2
| | | | | | | | - use macros from inttypes.h for format strings instead of OS-specific types Patch from Matt Kopec! llvm-svn: 168945
* Fix lldb to compile with top of tree LLVM/clang.Greg Clayton2012-11-161-1/+1
| | | | llvm-svn: 168204
* Patch from Matt Kopec:Greg Clayton2012-10-301-1/+1
| | | | | | This patch switches support on Linux from JIT to MCJIT. llvm-svn: 167026
* Cleanup some variable names to indicate auto pointers and also manager the ↵Greg Clayton2012-10-241-18/+15
| | | | | | llvm::Module memory more correctly. llvm-svn: 166598
* Added support for "bool", "true", and "false" toSean Callanan2012-10-171-0/+2
| | | | | | | the expression parser (also wchar_t) and added a test case. llvm-svn: 166131
* Bunch of cleanups for warnings found by the llvm static analyzer.Jim Ingham2012-10-121-0/+1
| | | | llvm-svn: 165808
* Removed some debugging cruft.Sean Callanan2012-09-241-3/+0
| | | | llvm-svn: 164572
* Brought LLDB top-of-tree into sync with LLVM/ClangSean Callanan2012-09-241-56/+75
| | | | | | | | | | | | | top-of-tree. Removed all local patches and llvm.zip. The intent is that fron now on top-of-tree will always build against LLVM/Clang top-of-tree, and that problems building will be resolved as they occur. Stable release branches of LLDB can be constructed as needed and linked to specific release branches of LLVM/Clang. llvm-svn: 164563
* Disable the "pretty stack trace" signal handler,Sean Callanan2012-09-061-0/+2
| | | | | | | which can conflict with accurate crash reporting in multithreaded contexts. llvm-svn: 163282
* Removed explicit NULL checks for shared pointersSean Callanan2012-08-091-1/+1
| | | | | | | | | and instead made us use implicit casts to bool. This generated a warning in C++11. <rdar://problem/11930775> llvm-svn: 161559
* Instructions generated by a disassembler can nowSean Callanan2012-08-011-1/+1
| | | | | | | | | | | | | | | | | | keep a shared pointer to their disassembler. This is important for the LLVM-C disassembler because it needs to lock its parent in order to disassemble itself. This means that every interface that returned a Disassembler* needs to return a DisassemblerSP, so that the instructions and any external owners share the same reference count on the object. I changed all clients to use this shared pointer, which also plugged a few leaks. <rdar://problem/12002822> llvm-svn: 161123
* Minor fixes for ARM/iOS targets:Sean Callanan2012-06-081-0/+3
| | | | | | | | | | - On iOS, we select the "apcs-gnu" ABI to match what libraries expect. - Literals are now allocated at their preferred alignment, eliminating many alignment crashes. llvm-svn: 158236
* Enabled C++11 in the expression parser. auto andSean Callanan2012-05-161-0/+2
| | | | | | | | | various other syntactic sugar work. Lambdas do not due to some problems relocating code containing lambdas. Rvalue references work when returned from expressions, but need more testing. llvm-svn: 156948
* <rdar://problem/11330621>Greg Clayton2012-05-101-2/+1
| | | | | | | | | | | | Fixed the DisassemblerLLVMC disassembler to parse more efficiently instead of parsing opcodes over and over. The InstructionLLVMC class now only reads the opcode in the InstructionLLVMC::Decode function. This can be done very efficiently for ARM and architectures that have fixed opcode sizes. For x64 it still calls the disassembler to get the byte size. Moved the lldb_private::Instruction::Dump(...) function up into the lldb_private::Instruction class and it now uses the function that gets the mnemonic, operandes and comments so that all disassembly is using the same code. Added StreamString::FillLastLineToColumn() to allow filling a line up to a column with a character (which is used by the lldb_private::Instruction::Dump(...) function). Modified the Opcode::GetData() fucntion to "do the right thing" for thumb instructions. llvm-svn: 156532
* Disabled spell checking in the expression parser,Sean Callanan2012-04-171-0/+6
| | | | | | | which incurs large overheads in terms of type parsing and importing. llvm-svn: 154885
* Updated the revision of LLVM/Clang used by LLDB.Sean Callanan2012-03-081-4/+9
| | | | | | | | | | | | | | | This takes two important changes: - Calling blocks is now supported. You need to cast their return values, but that works fine. - We now can correctly run JIT-compiled expressions that use floating-point numbers. Also, we have taken a fix that allows us to ignore access control in Objective-C as in C++. llvm-svn: 152286
* Updated LLVM to take a new MC JIT that supportsSean Callanan2012-03-011-1/+2
| | | | | | | | | | allocations by section. We install these sections in the target process and inform the JIT of their new locations. Also removed some unused variable warnings. llvm-svn: 151789
* <rdar://problem/10103468>Greg Clayton2012-02-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | I started work on being able to add symbol files after a debug session had started with a new "target symfile add" command and quickly ran into problems with stale Address objects in breakpoint locations that had lldb_private::Section pointers into modules that had been removed or replaced. This also let to grabbing stale modules from those sections. So I needed to thread harded the Address, Section and related objects. To do this I modified the ModuleChild class to now require a ModuleSP on initialization so that a weak reference can created. I also changed all places that were handing out "Section *" to have them hand out SectionSP. All ObjectFile, SymbolFile and SymbolVendors were inheriting from ModuleChild so all of the find plug-in, static creation function and constructors now require ModuleSP references instead of Module *. Address objects now have weak references to their sections which can safely go stale when a module gets destructed. This checkin doesn't complete the "target symfile add" command, but it does get us a lot clioser to being able to do such things without a high risk of crashing or memory corruption. llvm-svn: 151336
* The second part in thread hardening the internals of LLDB where we makeGreg Clayton2012-02-181-9/+9
| | | | | | | | | | | | | | | | the lldb_private::StackFrame objects hold onto a weak pointer to the thread object. The lldb_private::StackFrame objects the the most volatile objects we have as when we are doing single stepping, frames can often get lost or thrown away, only to be re-created as another object that still refers to the same frame. We have another bug tracking that. But we need to be able to have frames no longer be able to get the thread when they are not part of a thread anymore, and this is the first step (this fix makes that possible but doesn't implement it yet). Also changed lldb_private::ExecutionContextScope to return shared pointers to all objects in the execution context to further thread harden the internals. llvm-svn: 150871
* I have brought LLDB up-to-date with top of treeSean Callanan2012-02-041-62/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LLVM/Clang. This brings in several fixes, including: - Improvements in the Just-In-Time compiler's allocation of memory: the JIT now allocates memory in chunks of sections, improving its ability to generate relocations. I have revamped the RecordingMemoryManager to reflect these changes, as well as to get the memory allocation and data copying out fo the ClangExpressionParser code. Jim Grosbach wrote the updates to the JIT on the LLVM side. - A new ExternalASTSource interface to allow LLDB to report accurate structure layout information to Clang. Previously we could only report the sizes of fields, not their offsets. This meant that if data structures included field alignment directives, we could not communicate the necessary alignment to Clang and accesses to the data would fail. Now we can (and I have update the relevant test case). Thanks to Doug Gregor for implementing the Clang side of this fix. - The way Objective-C interfaces are completed by Clang has been made consistent with RecordDecls; with help from Doug Gregor and Greg Clayton I have ensured that this still works. - I have eliminated all local LLVM and Clang patches, committing the ones that are still relevant to LLVM and Clang as needed. I have tested the changes extensively locally, but please let me know if they cause any trouble for you. llvm-svn: 149775
* Added a mechanism for the IR interpreter to returnSean Callanan2012-01-241-18/+16
| | | | | | | | | an error along with its boolean result. The expression parser reports this error if the interpreter fails and the expression could not be run in the target. llvm-svn: 148870
* http://llvm.org/bugs/show_bug.cgi?id=11618Johnny Chen2012-01-061-0/+2
| | | | | | | | lldb::SBValue::AddressOf does not work on dereferenced registers in synthetic children provider Patch submitted by Enrico Granata. llvm-svn: 147637
* The "desired result type" code in the expressionSean Callanan2011-12-211-0/+3
| | | | | | | | | | | | | | | | | | | | | | parser has hitherto been an implementation waiting for a use. I have now tied the '-o' option for the expression command -- which indicates that the result is an Objective-C object and needs to be printed -- to the ExpressionParser, which communicates the desired type to Clang. Now, if the result of an expression is determined by an Objective-C method call for which there is no type information, that result is implicitly cast to id if and only if the -o option is passed to the expression command. (Otherwise if there is no explicit cast Clang will issue an error. This behavior is identical to what happened before r146756.) Also added a testcase for -o enabled and disabled. llvm-svn: 147099
* Picked up a new revision of Clang to pull in Objective-CSean Callanan2011-12-011-1/+2
| | | | | | | | | | | | | | | | | enhancements. With these enhancements, the return values of Objective-C methods with unknown return types can be implicitly cast to id for the purpose of making method calls. So what would have required this: (int)[(id)[ClassWithNoDebugInfo methodReturningObject] methodReturningInt] can now be written as: (int)[[ClassWithNoDebugInfo methodReturningObject] methodReturningInt] llvm-svn: 145567
* Added a language parameter to the expression parser,Sean Callanan2011-11-071-7/+20
| | | | | | | | | | | which will in the future allow expressions to be compiled as C, C++, and Objective-C instead of the current default Objective-C++. This feature requires some additional support from Clang -- specifically, it requires reference types in the parser regardless of language -- so it is not yet exposed to the user. llvm-svn: 144042
* Updated LLVM/Clang to pick up a fix for imports ofSean Callanan2011-11-041-1/+1
| | | | | | | | | | | | | | | C++ vtables, fixing a record layout problem in the expression parser. Also fixed various problems with the generation and unpacking of llvm.zip given our new better handling of multiple architectures in the LLVM build. (And added a log message that will hopefully catch record layout problems in the future.) llvm-svn: 143741
* Minor logging changes: added logging right beforeSean Callanan2011-11-011-2/+21
| | | | | | | the expression makes it to the JIT, and made some logging only appear in verbose mode. llvm-svn: 143467
* As part of a general refactoring of ClangASTSource toSean Callanan2011-10-281-1/+2
| | | | | | | | | | | | | | | | | allow it to complete types on behalf of any AST context (including the "scratch" AST context associated with the target), I scrapped its role as intermediary between the Clang parser and ClangExpressionDeclMap, and instead made ClangExpressionDeclMap inherit from ClangASTSource. After this, I will migrate the functions that complete types and perform namespace lookups from ClangExpressionDeclMap to ClangASTSource. Ultimately ClangExpressionDeclMap's only responsiblity will be to look up variables and ensure that they are materialized and dematerialized correctly. llvm-svn: 143253
* Enabled dedicated debugger support in Clang, meaningSean Callanan2011-10-211-1/+1
| | | | | | | that Objective-C methods returning types incompatible with "id" can be properly cast. llvm-svn: 142702
* Implemented a namespace map that allows searchingSean Callanan2011-10-121-1/+1
| | | | | | | | | | | | | | | | | | of namespaces (only in the modules where they've been found) for entities inside those namespaces. For each NamespaceDecl that has been imported into the parser, we maintain a map containing [ModuleSP, ClangNamespaceDecl] pairs in the ASTImporter. This map has one entry for each module in which the namespace has been found. When we later scan for an entity inside a namespace, we search only the modules in which that namespace was found. Also made a small whitespace fix in ClangExpressionParser.cpp. llvm-svn: 141748
OpenPOWER on IntegriCloud