summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression
Commit message (Collapse)AuthorAgeFilesLines
* Allow expresions to have unique expression prefixes:Greg Clayton2015-05-271-1/+16
| | | | | | | | | | | | | | | | | | expr_options = lldb.SBExpressionOptions() expr_options.SetPrefix(''' struct Foo { int a; int b; int c; } ''' expr_result = frame.EvaluateExpression ("Foo foo = { 1, 2, 3}; foo", expr_options) This fixed a current issue with ptr_refs, cstr_refs and malloc_info so that they can work. If expressions define their own types and then return expression results that use those types, those types get copied into the target's AST context so they persist and the expression results can be still printed and used in future expressions. Code was added to the expression parser to copy the context in which types are defined if they are used as the expression results. So in the case of types defined by expressions, they get defined in a lldb_expr function and that function and _all_ of its statements get copied. Many types of statements are not supported in this copy (array subscript, lambdas, etc) so this causes expressions to fail as they can't copy the result types. To work around this issue I have added code that allows expressions to specify an expression specific prefix. Then when you evaluate the expression you can pass the "expr_options" and have types that can be correctly copied out into the target. I added this as a way to work around an issue, but I also think it is nice to be allowed to specify an expression prefix that can be reused by many expressions, so this feature is very useful. <rdar://problem/21130675> llvm-svn: 238365
* Don't allow infininte recursion when trying to resolve re-exported symbols.Greg Clayton2015-05-151-0/+5
| | | | | | <rdar://problem/20821289> llvm-svn: 237477
* Fixed a ton of gcc compile warningsVince Harron2015-05-131-1/+4
| | | | | | | | | | Removed some unused variables, added some consts, changed some casts to const_cast. I don't think any of these changes are very controversial. Differential Revision: http://reviews.llvm.org/D9674 llvm-svn: 237218
* Fix ClangUserExpression::Evaluate return code in case of eExpressionParseErrorIlia K2015-05-071-2/+3
| | | | | | | | | | | | | | Summary: This patch fixes retvalue of ClangUserExpression::Evaluate in case of eExpressionParseError error Reviewers: jingham, spyffe, clayborg Reviewed By: clayborg Subscribers: lldb-commits, clayborg, spyffe, jingham Differential Revision: http://reviews.llvm.org/D9502 llvm-svn: 236700
* Added support for locating and importing functionsSean Callanan2015-05-012-0/+67
| | | | | | | | | | | | (including inline functions) from modules in the expression parser. We now have to retain a reference to the code generator in ClangExpressionDeclMap so that any imported function bodies can be appropriately sent to that code generator. <rdar://problem/19883002> llvm-svn: 236297
* Updated our use of clang::Preprocessor to reflectSean Callanan2015-05-011-1/+1
| | | | | | a change in the API used to get macros. llvm-svn: 236292
* Made macros from modules be injected before ourSean Callanan2015-04-302-40/+64
| | | | | | | | | | | global convenience expression prefix. Also ensured that if macros are defined by the modules we don't try to redefine them. Finally cleaned up a bit of code while I was in there. <rdar://problem/20756642> llvm-svn: 236266
* Fix build after Clang API change in r236176.Richard Smith2015-04-291-11/+4
| | | | llvm-svn: 236182
* Fix build.Chaoren Lin2015-04-231-1/+1
| | | | llvm-svn: 235653
* Fix build of lldb after clang r235614.Richard Smith2015-04-231-2/+2
| | | | llvm-svn: 235631
* This patch implements several improvements to theSean Callanan2015-04-203-26/+286
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | module-loading support for the expression parser. - It adds support for auto-loading modules referred to by a compile unit. These references are currently in the form of empty translation units. This functionality is gated by the setting target.auto-import-clang-modules (boolean) = false - It improves and corrects support for loading macros from modules, currently by textually pasting all #defines into the user's expression. The improvements center around including only those modules that are relevant to the current context - hand-loaded modules and the modules that are imported from the current compile unit. - It adds an "opt-in" mechanism for all of this functionality. Modules have to be explicitly imported (via @import) or auto-loaded (by enabling the above setting) to enable any of this functionality. It also adds support to the compile unit and symbol file code to deal with empty translation units that indicate module imports, and plumbs this through to the CompileUnit interface. Finally, it makes the following changes to the test suite: - It adds a testcase that verifies that modules are automatically loaded when the appropriate setting is enabled (lang/objc/modules-auto-import); and - It modifies lanb/objc/modules-incomplete to test the case where a module #undefs something that is #defined in another module. <rdar://problem/20299554> llvm-svn: 235313
* Added support to ClangUserExpression for importingSean Callanan2015-04-142-4/+159
| | | | | | | | | | | | | all the macros from the modules the user has loaded. These macros are currently imported textually into the expression's source code, which turns out not to impose the horrific string processing overhead that I thought it would, but I still plan to look into performance improvements. Also modified TestCModules to test that this works. llvm-svn: 234922
* Updated IRForTarget to change the way we generateSean Callanan2015-04-141-2/+4
| | | | | | | | | | | | relocations. We used to do GEP on a pointer to the result type, which is wrong. We should be doing GEP on a pointer to char, which allows us to offset correctly. This fixes the C modules testcase, so it's no longer ExpectFail. llvm-svn: 234918
* [IRForTarget] Strenghten handling of alternate mangling.Siva Chandra2015-04-091-26/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes an issue with GCC generated binaries wherein an expression with method invocations on std::string variables was failing. Such use cases are tested in TestSTL (albeit, in a test marked with @unittest2.expectedFailure because of other reasons). The reason for this particular failure with GCC is that the generated DWARF for std::basic_string<...> is incomplete, which makes clang not to use the alternate mangling scheme. GCC correctly generates the name of basic_string<...>: DW_AT_name "basic_string<char, std::char_traits<char>, std::allocator<char> >" It also lists the template parameters of basic_string correctly: DW_TAG_template_type_parameter DW_AT_name "_CharT" DW_AT_type <0x0000009c> DW_TAG_template_type_parameter DW_AT_name "_Traits" DW_AT_type <0x00000609> DW_TAG_template_type_parameter DW_AT_name "_Alloc" DW_AT_type <0x000007fb> However, it does not list the template parameters of std::char_traits<>. This makes Clang feel (while parsing the expression) that the string variable is not actually a basic_string instance, and consequently does not use the alternate mangling scheme. Test Plan: dotest.py -C gcc -p TestSTL -- See it go past the "for" loop expression successfully. Reviewers: clayborg, spyffe Reviewed By: clayborg, spyffe Subscribers: tberghammer, zturner, lldb-commits Differential Revision: http://reviews.llvm.org/D8846 llvm-svn: 234522
* Fix resolution of certain recursive types.Stephane Sezer2015-04-081-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: If a struct type S has a member T that has a member that is a function that returns a typedef of S* the respective field would be duplicated, which caused an assert down the line in RecordLayoutBuilder. This patch adds a check that removes the possibility of trying to resolve the same type twice within the same callstack. This commit also adds unit tests for these failures. Fixes https://llvm.org/bugs/show_bug.cgi?id=20486. Patch by Cristian Hancila. Test Plan: Run unit tests. Reviewers: clayborg spyffe Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D8561 llvm-svn: 234441
* Fix -Wformat-pedantic warningsDavid Blaikie2015-04-082-3/+3
| | | | llvm-svn: 234429
* Fixed a problem where the second @import statementSean Callanan2015-04-071-2/+2
| | | | | | | | | | | | in a session would be silently ignored by the compiler because the compiler looked at its SourceLocation and decided it had already handled it. Also updated the relevant test case. <rdar://problem/20315447> llvm-svn: 234330
* Fixed a crash because we weren't generatingSean Callanan2015-04-061-3/+4
| | | | | | | | type-safe relocations against @reloc_placeholder. <rdar://problem/20438754> llvm-svn: 234260
* We have an issue where if you use a C function right now that has no ↵Greg Clayton2015-04-061-6/+10
| | | | | | | | prototype, it isn't marked as extern "C" and the name to lookup is some C++ mangled form of the name. This used to be the case for "printf" before a function prototype was added to the builtin expression prefix file. This fix makes sure that if we get a mangled name that we don't find in the current target, that we only fall back to looking up function by basename if the function isn't contained in a namespace or class (no decl context). llvm-svn: 234178
* Added a testcase that covers loading a module andSean Callanan2015-04-031-0/+12
| | | | | | | | | | | verifying that the types from that module don't override types from DWARF. Also added a target setting to LLDB so we can tell Clang where to look for these local modules. <rdar://problem/18805055> llvm-svn: 234016
* Fix error resulting from llvm r233938.Zachary Turner2015-04-021-1/+1
| | | | llvm-svn: 233942
* Fix type detection for 'char' variablesTamas Berghammer2015-03-311-0/+3
| | | | | | | | | | | | A char can have signed and unsigned encoding but previously lldb always assumed it is signed. This CL adds a logic to detect the encoding of 'char' types based on the default encoding on the target architecture. It fixes variable printing and expression evaluation on architectures where 'char' is signed by default. Differential revision: http://reviews.llvm.org/D8636 llvm-svn: 233682
* Fix build broken by missing `typename` keyword.Zachary Turner2015-03-241-2/+3
| | | | llvm-svn: 233106
* Fix error introduced by changing function signatures.Zachary Turner2015-03-241-30/+46
| | | | | | | | | | | | | | | | | Since ClangASTSource::layoutRecordType() was overriding a virtual function in the base, this was inadvertently causing a new method to be introduced rather than an override. To fix this all method signatures are changed back to taking DenseMaps, and the `override` keyword is added to make sure this type of error doesn't happen again. To keep the original fix intact, which is that fields and bases must be added in offset order, the ImportOffsetMap() function now copies the DenseMap into a vector and then sorts the vector on the value type (e.g. the offset) before iterating over the sorted vector and inserting the items. llvm-svn: 233099
* Fix record layout when synthesizing class types.Zachary Turner2015-03-241-49/+35
| | | | | | | | | | | | | | | | | Prior to this patch, we would try to synthesize class types by iterating over a DenseMap of FieldDecls and adding each one to a CXXRecordDecl. Since a DenseMap doesn't provide a deterministic ordering of the elements, this would not add the fields in FieldOffset order, but rather in some random order determined by the memory layout of the DenseMap. This patch fixes the issue by changing DenseMaps to vectors. The ability to lookup a value in the DenseMap was hardly being used, and where it is sufficient to do a vector lookup. Differential Revision: http://reviews.llvm.org/D8512 llvm-svn: 233090
* Move lldb-log.cpp to core/Logging.cppZachary Turner2015-03-182-2/+1
| | | | | | | | | So that we don't have to update every single #include in the entire codebase to #include this new header (which used to get included by lldb-private-log.h, we automatically #include "Logging.h" from within "Log.h". llvm-svn: 232653
* Added nullptr to fix buildVince Harron2015-03-161-2/+3
| | | | llvm-svn: 232345
* Fixed a bug where the expression parser relied on having symbols for things ↵Greg Clayton2015-03-091-16/+39
| | | | | | | | | | even if they were in the debug info. The issue can happen if you strip your main executable and then run an expression and it would fail to find the stripped symbol and it would then not be able to make the function call. The issue was fixed by doing our normal FindFunctions call. <rdar://problem/20072750> llvm-svn: 231667
* When we have a symbol, like "NSLog" that we try to call in an expression, ↵Greg Clayton2015-03-051-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | make sure we prioritize the external symbols over the internal one. This is a temporary fix until a more comprehensive fix can be made for finding functions that we call in expressions. We find "NSLog" in ClangExpressionDeclMap::FindExternalVisibleDecls() in after a call to target->GetImages().FindFunctions(...). Note that there are two symbols: NSLog from CFNetwork which is not external, and NSLog from Foundation which _is_ external. We do something with the external symbol with: if (extern_symbol) { AddOneFunction (context, NULL, extern_symbol, current_id); context.m_found.function = true; } Then later we try to lookup the _Z5NSLogP8NSStringz name and we don't find it so we call ClangExpressionDeclMap::GetFunctionAddress() with "_Z5NSLogP8NSStringz" as the name and the sc_list_size is zero at the "if" statement at line 568 because we don't find the mangled name and we extract the basename "NSLog" and call: FindCodeSymbolInContext(ConstString(basename), m_parser_vars->m_sym_ctx, sc_list); sc_list_size = sc_list.GetSize(); and we get a list size of two again, and we proceed to search for the symbol again, this time ignoring the external vs non-external-ness of the symbols that we find. This fix ensures we prioritize the external symbol until we get a real fix from Sean Callanan when he gets back to make sure we don't do multiple lookups for the same symbol we already resolved. <rdar://problem/19879282> llvm-svn: 231420
* Add support for the DWARFv3 (circa 2005) DW_OP_form_tls_addressJason Molenda2015-03-051-4/+13
| | | | | | | | | | | | | operator in addition to the vendor-extension DW_OP_GNU_push_tls_address. clang on PS4 and Darwin will be emitting the standard opcode as of r231286 via http://reviews.llvm.org/D8018 Behavior of this standard opcode is the same as DW_OP_GNU_push_tls_address. <rdar://problem/20043195> llvm-svn: 231342
* Don't #include clang headers from BreakpointLocation.hZachary Turner2015-03-041-2/+2
| | | | llvm-svn: 231263
* Don't #include FormatManager.h from Debugger.hZachary Turner2015-03-032-0/+5
| | | | | | | | Debugger.h is a huge file that gets included everywhere, and FormatManager.h brings in a ton of unnecessary stuff and doesn't even use anything from it in the header. llvm-svn: 231161
* Don't #include ClangPersistentVariables.h from Process.hZachary Turner2015-03-033-0/+3
| | | | | | | Nothing from this header file was even being referenced in Process.h anyway, so it was a completely unnecessary include. llvm-svn: 231131
* Reduce header footprint of Target.hZachary Turner2015-03-032-0/+2
| | | | | | | | | | | | This continues the effort to reduce header footprint and improve build speed by removing clang and other unnecessary headers from Target.h. In one case, some headers were included solely for the purpose of declaring a nested class in Target, which was not needed by anybody outside the class. In this case the definition and implementation of the nested class were isolated in the .cpp file so the header could be removed. llvm-svn: 231107
* Don't #include ClangASTContext.h from Module.hZachary Turner2015-03-031-0/+1
| | | | | | | | | | | | This is part of a larger effort to reduce header file footprints. Combined, these patches reduce the build time of LLDB locally by over 30%. However, they touch many files and make many changes, so will be submitted in small incremental pieces. Reviewed By: Greg Clayton Differential Revision: http://reviews.llvm.org/D8022 llvm-svn: 231097
* Fixed an infinite recursion bug that could happen when using python ↵Greg Clayton2015-02-271-1/+1
| | | | | | | | operating system plug-ins where we would ask the operating system plug-in to update its threads and this would cause the plugin to run an expression which would eventually run IRForTarget::CreateResultVariable() which would try to get the selected thread and cause re-entrant bug. <rdar://problem/19924734> llvm-svn: 230711
* Update for Clang API change in r230123 -- lookup_result was alwaysChandler Carruth2015-02-211-1/+1
| | | | | | | | const, there was never a need for lookup_const_result. Now that vestigal type is gone, so switch LLDB to lookup_result and to use the DeclContextLookupResult rather than the Const variant. llvm-svn: 230126
* Fix build after r229094: replace llvm/PassManager.h -> ↵Ilia K2015-02-131-1/+1
| | | | | | llvm/IR/LegacyPassManager.h llvm-svn: 229100
* Make a more complete fix for always supplying an execution context when ↵Greg Clayton2015-02-121-4/+16
| | | | | | | | | | getting byte sizes from types. There was a test in the test suite that was triggering the backtrace logging output that requested that the client pass an execution context. Sometimes we need the process for Objective C types because our static notion of the type might not align with the reality when being run in a live runtime. Switched from an "ExecutionContext *" to an "ExecutionContextScope *" for greater ease of use. llvm-svn: 228892
* Don't crash when evaluating a DWARF expression has a DW_OP_bra with nothing ↵Greg Clayton2015-02-101-0/+7
| | | | | | | | on the value stack. <rdar://problem/18919125> llvm-svn: 228729
* Get rid of Debugger::FormatPrompt() and replace it with the new FormatEntity ↵Greg Clayton2015-02-041-22/+2
| | | | | | | | | | | | | | | | | | | class. Why? Debugger::FormatPrompt() would run through the format prompt every time and parse it and emit it piece by piece. It also did formatting differently depending on which key/value pair it was parsing. The new code improves on this with the following features: 1 - Allow format strings to be parsed into a FormatEntity::Entry which can contain multiple child FormatEntity::Entry objects. This FormatEntity::Entry is a parsed version of what was previously always done in Debugger::FormatPrompt() so it is more efficient to emit formatted strings using the new parsed FormatEntity::Entry. 2 - Allows errors in format strings to be shown immediately when setting the settings (frame-format, thread-format, disassembly-format 3 - Allows auto completion by implementing a new OptionValueFormatEntity and switching frame-format, thread-format, and disassembly-format settings over to using it. 4 - The FormatEntity::Entry for each of the frame-format, thread-format, disassembly-format settings only replaces the old one if the format parses correctly 5 - Combines all consecutive string values together for efficient output. This means all "${ansi.*}" keys and all desensitized characters like "\n" "\t" "\0721" "\x23" will get combined with their previous strings 6 - ${*.script:} (like "${var.script:mymodule.my_var_function}") have all been switched over to use ${script.*:} "${script.var:mymodule.my_var_function}") to make the format easier to parse as I don't believe anyone was using these format string power user features. 7 - All key values pairs are defined in simple C arrays of entries so it is much easier to add new entries. These changes pave the way for subsequent modifications where we can modify formats to do more (like control the width of value strings can do more and add more functionality more easily like string formatting to control the width, printf formats and more). llvm-svn: 228207
* Fixed bugs in the multi-threaded access in HostInfoBase. Prior to this fix, ↵Greg Clayton2015-02-031-2/+4
| | | | | | | | | | static bool variables were used but this is not sufficient. We now use std::call_once in all places where the previous static bool code was used to try to implement thread safety. This was causing code that opened multiple targets to try and get a path to debugserver from the GDB remote communication class, and it would get the LLDB path and some instances would return empty strings and it would cause debugserver to not be found. <rdar://problem/18756927> llvm-svn: 227935
* Preparatory infrastructural work to support dynamically determining sizes of ↵Enrico Granata2015-01-282-5/+5
| | | | | | | | | | | | ObjC types via the runtime This is necessary because the byte size of an ObjC class type is not reliably statically knowable (e.g. because superclasses sit deep in frameworks that we have no debug info for) The lack of reliable size info is a problem when trying to freeze-dry an ObjC instance (not the pointer, the pointee) This commit lays the foundation for having language runtimes help in figuring out byte sizes, and having ClangASTType ask for runtime help No feature change as no runtime actually implements the logic, and nowhere is an ExecutionContext passed in yet llvm-svn: 227274
* The MCJIT doesn't seem to call getPointerForNamedFunction from the ↵Jim Ingham2015-01-271-0/+141
| | | | | | | | | | | | | MemoryManager anymore, switching to getSymbolAddress, which it does call, and implementing it so that we once again look up external symbols in the JIT. Also juked the error reporting from the JIT a little bit. This resolves: http://llvm.org/bugs/show_bug.cgi?id=22314 llvm-svn: 227217
* Fix the -*-version-min option to not try and use the current OS version for ↵Greg Clayton2015-01-221-1/+1
| | | | | | iOS and the simulator since llvm/clang will assert and kill LLDB. llvm-svn: 226846
* Update ExpressionSourceCode::GetText() to match theJason Molenda2015-01-221-1/+1
| | | | | | | | name of the iOS simulator platform which was changed in r181631. <rdar://problem/19200084> llvm-svn: 226789
* Expression evaluation for functions with unknown signatures on works byKate Stone2015-01-211-0/+4
| | | | | | | | | | | | | | | inferring the function signature. This works well where the ABI doesn't distinguish between variadic and fixed argument lists, but on arm64 the calling conventions differ. The default assumption works for fixed argument lists, but variadic functions require explicit prototypes to be called. By far the most common case where this is an issue is when attempting to use printf(). This change augments the default expression prefix to include a working variadic prototype for the function. <rdar://problem/19024779> llvm-svn: 226744
* Fix build after clang r226128.Nico Weber2015-01-151-1/+0
| | | | llvm-svn: 226180
* In commit clang r226096, DefinitionRequired has been removed. Do the same in ↵Sylvestre Ledru2015-01-152-4/+4
| | | | | | lldb implementation llvm-svn: 226162
* Fix issues with LLDB's interpreter and MS ABI guard variables.Zachary Turner2015-01-091-15/+7
| | | | | | | | | | | MS ABI guard variables end with @4IA, so this patch teaches the interpreter about that. Additionally, there was an issue with TurnGuardLoadIntoZero which was causing some guard uses of a variable to be missed. This fixes that by calling Instruction::replaceAllUsesWith() instead of trying to replicate that function. llvm-svn: 225547
OpenPOWER on IntegriCloud