summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression
Commit message (Collapse)AuthorAgeFilesLines
...
* Fixed the message that reports that an expressionSean Callanan2010-10-191-2/+2
| | | | | | | did not return a result. The result is nonexistent (or void), not NULL. llvm-svn: 116855
* Added a new Host call to find LLDB related paths:Greg Clayton2010-10-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | static bool Host::GetLLDBPath (lldb::PathType path_type, FileSpec &file_spec); This will fill in "file_spec" with an appropriate path that is appropriate for the current Host OS. MacOSX will return paths within the LLDB.framework, and other unixes will return the paths they want. The current PathType enums are: typedef enum PathType { ePathTypeLLDBShlibDir, // The directory where the lldb.so (unix) or LLDB mach-o file in LLDB.framework (MacOSX) exists ePathTypeSupportExecutableDir, // Find LLDB support executable directory (debugserver, etc) ePathTypeHeaderDir, // Find LLDB header file directory ePathTypePythonDir // Find Python modules (PYTHONPATH) directory } PathType; All places that were finding executables are and python paths are now updated to use this Host call. Added another new host call to launch the inferior in a terminal. This ability will be very host specific and doesn't need to be supported on all systems. MacOSX currently will create a new .command file and tell Terminal.app to open the .command file. It also uses the new "darwin-debug" app which is a small app that uses posix to exec (no fork) and stop at the entry point of the program. The GDB remote plug-in is almost able launch a process and attach to it, it currently will spawn the process, but it won't attach to it just yet. This will let LLDB not have to share the terminal with another process and a new terminal window will pop up when you launch. This won't get hooked up until we work out all of the kinks. The new Host function is: static lldb::pid_t Host::LaunchInNewTerminal ( const char **argv, // argv[0] is executable const char **envp, const ArchSpec *arch_spec, bool stop_at_entry, bool disable_aslr); Cleaned up FileSpec::GetPath to not use strncpy() as it was always zero filling the entire path buffer. Fixed an issue with the dynamic checker function where I missed a '$' prefix that should have been added. llvm-svn: 116690
* prefix more stuff with '$' to make sure we don't go trying to lookup anythingGreg Clayton2010-10-161-5/+5
| | | | | | we don't need to. llvm-svn: 116676
* Made many ConstString functions inlined in the header file.Greg Clayton2010-10-1510-359/+435
| | | | | | | | | | | | | | | | | | | 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-152-14/+35
| | | | llvm-svn: 116565
* Added support for breakpoint conditions. I also had to separate the "run ↵Jim Ingham2010-10-143-26/+69
| | | | | | | | the expression" part of ClangFunction::Execute from the "Gather the expression result" so that in the case of the Breakpoint condition I can move the condition evaluation into the normal thread plan processing. Also added support for remembering the "last set breakpoint" so that "break modify" will act on the last set breakpoint. llvm-svn: 116542
* 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
* Fixed C++ class clang type creation and display by making sure we omit Greg Clayton2010-10-131-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | artifical members (like the vtable pointer member that shows up in the DWARF). We were adding this to each class which was making all member variables be off by a pointer size. Added a test case so we can track this with "test/forward". Fixed the type name index in DWARF to include all the types after finding some types were being omitted due to the DW_AT_specification having the DW_AT_declaration attribute which was being read into the real type instances when there were forward declarations in the DWARF, causing the type to be omitted. We now check to make sure any DW_AT_declaration values are only respected when parsing types if the attribute is from the current DIE. After fixing the missing types, we ran into some issues with the expression parser finding duplicate entries for __va_list_tag since they are built in types and would result in a "duplicate __va_list_tag definition" error. We are now just ignoring this name during lookup, but we will need to see if we can get the name lookup function to not get called in these cases. Fixed an issue that would cause an assertion where DW_TAG_subroutine_types that had no children, would not properly make a clang function type of: "void (*) (void)". llvm-svn: 116392
* Add a way to temporarily divert events from a broadcaster to a private listener.Jim Ingham2010-10-111-4/+18
| | | | llvm-svn: 116271
* Added extra logging, and made sure that the argumentSean Callanan2010-10-082-0/+12
| | | | | | | struct for expressions is deallocated when the ClangExpressionDeclMap is taken down. llvm-svn: 116028
* Changed the timeout for expressions from 10Sean Callanan2010-10-071-1/+1
| | | | | | | milliseconds to 10 seconds, which was the original intent. llvm-svn: 115942
* Added the ability to get the disassembly instructions from the function andGreg Clayton2010-10-061-6/+5
| | | | | | symbol. llvm-svn: 115734
* 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 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
* Added support for (de)materializing values in registers,Sean Callanan2010-10-051-41/+204
| | | | | | so that expressions can use them. llvm-svn: 115658
* Added the notion that a value object can be constant by adding:Greg Clayton2010-10-051-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bool ValueObject::GetIsConstant() const; void ValueObject::SetIsConstant(); This will stop anything from being re-evaluated within the value object so that constant result value objects can maintain their frozen values without anything being updated or changed within the value object. Made it so the ValueObjectConstResult can be constructed with an lldb_private::Error object to allow for expression results to have errors. Since ValueObject objects contain error objects, I changed the expression evaluation in ClangUserExpression from static Error ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr, lldb::ValueObjectSP &result_valobj_sp); to: static lldb::ValueObjectSP Evaluate (ExecutionContext &exe_ctx, const char *expr_cstr); Even though expression parsing is borked right now (pending fixes coming from Sean Callanan), I filled in the implementation for: SBValue SBFrame::EvaluateExpression (const char *expr); Modified all expression code to deal with the above changes. llvm-svn: 115589
* Moved expression evaluation from CommandObjectExpression into Greg Clayton2010-10-051-0/+52
| | | | | | | ClangUserExpression::Evaluate () as a public static function so anyone can evaluate an expression. llvm-svn: 115581
* Added a new ValueObject type that will be used to freeze dry expressionGreg Clayton2010-10-053-123/+87
| | | | | | | | | | | | | | | 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 handling of signed short types in expressions.Sean Callanan2010-10-011-1/+1
| | | | llvm-svn: 115267
* Switched the expression parser from using TargetDataSean Callanan2010-09-302-30/+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
* Add "-o" option to "expression" which prints the object description if ↵Jim Ingham2010-09-302-14/+12
| | | | | | available. llvm-svn: 115115
* Fixed the forward declaration issue that was present in the DWARF parser afterGreg Clayton2010-09-294-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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
* Replace the vestigial Value::GetOpaqueCLangQualType with the more correct ↵Jim Ingham2010-09-282-2/+2
| | | | | | | | Value::GetValueOpaqueClangQualType. But mostly, move the ObjC Trampoline handling code from the MacOSX dyld plugin to the AppleObjCRuntime classes. llvm-svn: 114935
* Added type lookup, so variables with user-defined typesSean Callanan2010-09-271-111/+25
| | | | | | can be allocated and manipulated. llvm-svn: 114928
* Cleaned a few build related things up:Greg Clayton2010-09-241-0/+4
| | | | | | | | | | Added a virtual destructor to ClangUtilityFunction with a body to it cleans itself up. Moved our SharingPtr into the lldb_private namespace to keep it easy to make an exports file that exports only what is needed ("lldb::*"). llvm-svn: 114771
* 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-238-51/+58
| | | | | | | | | | - 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
* Improved the logging for ASTs generated on theSean Callanan2010-09-221-2/+2
| | | | | | | | expression parser's behalf so that now we see the full TranslationUnitDecl instead of just the FunctionDecl. llvm-svn: 114514
* Removed the hacky "#define this ___clang_this" handlerSean Callanan2010-09-216-62/+322
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-142-5/+5
| | | | | | 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-143-12/+78
| | | | | | | | | | | | | | | | | | | | | 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-142-69/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-138-45/+305
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
* Little bit of line wrapping cleanup.Jim Ingham2010-09-101-8/+51
| | | | | | Mainly ExecuteFunction should save & restore the currently selected Thread & Frame. llvm-svn: 113658
* 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
* remove unneeded #include, reducing # static ctors.Chris Lattner2010-09-081-1/+0
| | | | llvm-svn: 113437
* 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
* Fixed an expression parser bug that preventedSean Callanan2010-09-083-1/+35
| | | | | | | | | | | | | | | 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-072-10/+28
| | | | | | | | | 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
* Added code to run pointer validation checks inSean Callanan2010-09-021-16/+258
| | | | | | | | | expressions. If an expression dereferences an invalid pointer, there will still be a crash - just now the crash will be in the function ___clang_valid_pointer_check(). llvm-svn: 112785
* Added support for dynamic sanity checking inSean Callanan2010-09-013-2/+138
| | | | | | | | | | | | | | | | | | | expressions. Values used by the expression are checked by validation functions which cause the program to crash if the values are unsafe. Major changes: - Added IRDynamicChecks.[ch], which contains the core code related to this feature - Modified CommandObjectExpression to install the validator functions into the target process. - Added an accessor to Process that gets/sets the helper functions llvm-svn: 112690
* Fixed a bug where the parser-specific members ofSean Callanan2010-08-302-13/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fixed a bug where ClangExpressionVariableList wasSean Callanan2010-08-301-1/+3
| | | | | | | | storing pointers to objects inside a std::vector. These objects can move around as the std::vector changes, invalidating the pointers. llvm-svn: 112527
* Added a ClangUtilityFunction class that allows theSean Callanan2010-08-274-3/+132
| | | | | | | | | | | | | debugger to insert self-contained functions for use by expressions (mainly for error-checking). In order to support detecting whether a crash occurred in one of these helpers -- currently our preferred way of reporting that an error-check failed -- added a bit of support for getting the extent of a JITted function in addition to just its base. llvm-svn: 112324
* This is a major refactoring of the expression parser.Sean Callanan2010-08-278-1006/+1249
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud