summaryrefslogtreecommitdiffstats
path: root/lldb/source/Expression/ClangFunction.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* We were leaking a stack frame in StackFrameList in Thread.cpp which couldGreg Clayton2011-08-121-4/+2
| | | | | | | | | | cause extra shared pointer references to one or more modules to be leaked. This would cause many object files to stay around the life of LLDB, so after a recompile and rexecution, we would keep adding more and more memory. After fixing the leak, we found many cases where leaked stack frames were still being used and causing crashes in the test suite. These are now all resolved. llvm-svn: 137516
* Centralize all of the type name code so that we always strip the leadingGreg Clayton2011-06-301-4/+4
| | | | | | | | "struct ", "class ", and "union " from the start of any type names that are extracted from clang QualType objects. I had to fix test suite cases that were expecting the struct/union/class prefix to be there. llvm-svn: 134132
* This commit integrates support for the LLVM MCJITSean Callanan2011-05-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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
* Added new lldb_private::Process memory read/write functions to stop a bunchGreg Clayton2011-05-221-28/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of duplicated code from appearing all over LLDB: lldb::addr_t Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error); bool Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error); size_t Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error); size_t Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error); in lldb_private::Process the following functions were renamed: From: uint64_t Process::ReadUnsignedInteger (lldb::addr_t load_addr, size_t byte_size, Error &error); To: uint64_t Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Error &error); Cleaned up a lot of code that was manually doing what the above functions do to use the functions listed above. Added the ability to get a scalar value as a buffer that can be written down to a process (byte swapping the Scalar value if needed): uint32_t Scalar::GetAsMemoryData (void *dst, uint32_t dst_len, lldb::ByteOrder dst_byte_order, Error &error) const; The "dst_len" can be smaller that the size of the scalar and the least significant bytes will be written. "dst_len" can also be larger and the most significant bytes will be padded with zeroes. Centralized the code that adds or removes address bits for callable and opcode addresses into lldb_private::Target: lldb::addr_t Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const; lldb::addr_t Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const; All necessary lldb_private::Address functions now use the target versions so changes should only need to happen in one place if anything needs updating. Fixed up a lot of places that were calling : addr_t Address::GetLoadAddress(Target*); to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress() as needed. There were many places in the breakpoint code where things could go wrong for ARM if these weren't used. llvm-svn: 131878
* Made expressions that are just casts of pointer Sean Callanan2011-05-071-1/+3
| | | | | | | | | | | | 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
* Fixed the LLDB build so that we can have private types, private enums andGreg Clayton2011-03-241-12/+12
| | | | | | | | public types and public enums. This was done to keep the SWIG stuff from parsing all sorts of enums and types that weren't needed, and allows us to abstract our API better. llvm-svn: 128239
* Get ObjC stepping working again when the process is not the default host ↵Jim Ingham2011-03-171-18/+26
| | | | | | architecture. llvm-svn: 127825
* Clean up a bit of the type getting code where lldb_private:Type now hasGreg Clayton2011-02-161-8/+7
| | | | | | | | | | | | | | clang_type_t GetClangFullType(); // Get a completely defined clang type clang_type_t GetClangLayoutType(); // Get a clang type that can be used for type layout clang_type_t GetClangForwardType(); // A type that can be completed if needed, but is more efficient. llvm-svn: 125691
* Made lldb_private::ArchSpec contain much more than just an architecture. ItGreg Clayton2011-02-151-5/+20
| | | | | | | | | | now, in addition to cpu type/subtype and architecture flavor, contains: - byte order (big endian, little endian) - address size in bytes - llvm::Triple for true target triple support and for more powerful plug-in selection. llvm-svn: 125602
* Make expressions clean up their JIT'ed code allocation.Greg Clayton2011-01-191-8/+12
| | | | llvm-svn: 123855
* Make a few log messages come out in "log enable lldb step" as well as "log ↵Jim Ingham2011-01-181-1/+1
| | | | | | enable lldb expression". llvm-svn: 123784
* Added support for the fragile ivars provided bySean Callanan2011-01-171-1/+1
| | | | | | | Apple's Objective-C 2.0 runtime. They are enabled if the Objective-C runtime has the proper version. llvm-svn: 123694
* Modified LLDB expressions to not have to JIT and run code just to see variableGreg Clayton2010-12-141-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | values or persistent expression variables. Now if an expression consists of a value that is a child of a variable, or of a persistent variable only, we will create a value object for it and make a ValueObjectConstResult from it to freeze the value (for program variables only, not persistent variables) and avoid running JITed code. For everything else we still parse up and JIT code and run it in the inferior. There was also a lot of clean up in the expression code. I made the ClangExpressionVariables be stored in collections of shared pointers instead of in collections of objects. This will help stop a lot of copy constructors on these large objects and also cleans up the code considerably. The persistent clang expression variables were moved over to the Target to ensure they persist across process executions. Added the ability for lldb_private::Target objects to evaluate expressions. We want to evaluate expressions at the target level in case we aren't running yet, or we have just completed running. We still want to be able to access the persistent expression variables between runs, and also evaluate constant expressions. Added extra logging to the dynamic loader plug-in for MacOSX. ModuleList objects can now dump their contents with the UUID, arch and full paths being logged with appropriate prefix values. Thread hardened the Communication class a bit by making the connection auto_ptr member into a shared pointer member and then making a local copy of the shared pointer in each method that uses it to make sure another thread can't nuke the connection object while it is being used by another thread. Added a new file to the lldb/test/load_unload test that causes the test a.out file to link to the libd.dylib file all the time. This will allow us to test using the DYLD_LIBRARY_PATH environment variable after moving libd.dylib somewhere else. llvm-svn: 121745
* Added support for generating expressions that haveSean Callanan2010-12-131-6/+8
| | | | | | | | | | | | | | 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
* Moved the code in ClangUserExpression that set up & ran the thread plan with ↵Jim Ingham2010-11-301-254/+14
| | | | | | | | | | timeouts, and restarting with all threads into a utility function in Process. This required a bunch of renaming. Added a ThreadPlanCallUserExpression that differs from ThreadPlanCallFunction in that it holds onto a shared pointer to its ClangUserExpression so that can't go away before the thread plan is done using it. Fixed the stop message when you hit a breakpoint while running a user expression so it is more obvious what has happened. llvm-svn: 120386
* The thread plan destructors may call Thread virtual methods. That means ↵Jim Ingham2010-11-181-1/+2
| | | | | | they have to get cleaned up in the derived class's destructor. Make sure that happens. llvm-svn: 119675
* Added an "Interrupted" bit to the ProcessEventData. Halt now generates an eventJim Ingham2010-11-171-47/+50
| | | | | | | | | with the Interrupted bit set. Process::HandlePrivateEvent ignores Interrupted events. DoHalt is changed to ensure that the stop even is processed, and an event with the Interrupted event is posted. Finally ClangFunction is rationalized to use this facility so the that Halt is handled more deterministically. llvm-svn: 119453
* Modified the lldb_private::Type clang type resolving code to handle threeGreg Clayton2010-11-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | cases when getting the clang type: - need only a forward declaration - need a clang type that can be used for layout (members and args/return types) - need a full clang type This allows us to partially parse the clang types and be as lazy as possible. The first case is when we just need to declare a type and we will complete it later. The forward declaration happens only for class/union/structs and enums. The layout type allows us to resolve the full clang type _except_ if we have any modifiers on a pointer or reference (both R and L value). In this case when we are adding members or function args or return types, we only need to know how the type will be laid out and we can defer completing the pointee type until we later need it. The last type means we need a full definition for the clang type. Did some renaming of some enumerations to get rid of the old "DC" prefix (which stands for DebugCore which is no longer around). Modified the clang namespace support to be almost ready to be fed to the expression parser. I made a new ClangNamespaceDecl class that can carry around the AST and the namespace decl so we can copy it into the expression AST. I modified the symbol vendor and symbol file plug-ins to use this new class. llvm-svn: 118976
* Modified all logging calls to hand out shared pointers to make sure weGreg Clayton2010-11-061-3/+3
| | | | | | | | | | | 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
* Added the equivalent of gdb's "unwind-on-signal" to the expression command, ↵Jim Ingham2010-11-051-7/+25
| | | | | | and a parameter to control it in ClangUserExpression, and on down to ClangFunction. llvm-svn: 118290
* Modified ThreadPlanCallFunction to perform theSean Callanan2010-11-031-1/+1
| | | | | | | | exception checks at the right time, and modified ClangFunction so that it doesn't misinterpret the stop as a timeout stop. llvm-svn: 118189
* Add the ability to disable individual log categories, ratherCaroline Tice2010-10-291-1/+5
| | | | | | | | | than just the entire log channel. Add checks, where appropriate, to make sure a log channel/category has not been disabled before attempting to write to it. llvm-svn: 117715
* Don't cache the public stop reason, since it can change as plan completion ↵Jim Ingham2010-10-201-3/+3
| | | | | | gets processed. That means GetStopReason needs to return a shared pointer, not a pointer to the thread's cached version. Also allow the thread plans to get and set the thread private stop reason - that is usually more appropriate for the logic the thread plans need to do. llvm-svn: 116892
* Made many ConstString functions inlined in the header file.Greg Clayton2010-10-151-9/+15
| | | | | | | | | | | | | | | | | | | 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 support for breakpoint conditions. I also had to separate the "run ↵Jim Ingham2010-10-141-2/+4
| | | | | | | | 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
* Add a way to temporarily divert events from a broadcaster to a private listener.Jim Ingham2010-10-111-4/+18
| | | | llvm-svn: 116271
* Add "-o" option to "expression" which prints the object description if ↵Jim Ingham2010-09-301-1/+2
| | | | | | available. llvm-svn: 115115
* Fixed the forward declaration issue that was present in the DWARF parser afterGreg Clayton2010-09-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Replace the vestigial Value::GetOpaqueCLangQualType with the more correct ↵Jim Ingham2010-09-281-1/+1
| | | | | | | | Value::GetValueOpaqueClangQualType. But mostly, move the ObjC Trampoline handling code from the MacOSX dyld plugin to the AppleObjCRuntime classes. llvm-svn: 114935
* Removed the hacky "#define this ___clang_this" handlerSean Callanan2010-09-211-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-141-1/+1
| | | | | | to symbolicate things without the need for a valid process subclass. llvm-svn: 113895
* 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
* remove unneeded #include, reducing # static ctors.Chris Lattner2010-09-081-1/+0
| | | | llvm-svn: 113437
* Fixed an expression parser bug that preventedSean Callanan2010-09-081-0/+6
| | | | | | | | | | | | | | | 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
* Added a ClangUtilityFunction class that allows theSean Callanan2010-08-271-1/+3
| | | | | | | | | | | | | 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-271-232/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Check for errors in Resume before waiting for the resume to complete.Jim Ingham2010-08-171-1/+6
| | | | llvm-svn: 111216
* Documented ClangExpression and made parts of itSean Callanan2010-08-131-1/+1
| | | | | | | more sane (i.e., removed dead arguments, made sensible defaults, etc.) llvm-svn: 110990
* Abtracted the old "lldb_private::Thread::StopInfo" into an abtract class.Greg Clayton2010-08-041-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will allow debugger plug-ins to make any instance of "lldb_private::StopInfo" that can completely describe any stop reason. It also provides a framework for doing intelligent things with the stop info at important times in the lifetime of the inferior. Examples include the signal stop info in StopInfoUnixSignal. It will check with the process to see that the current action is for the signal. These actions include wether to stop for the signal, wether the notify that the signal was hit, and wether to pass the signal along to the inferior process. The StopInfoUnixSignal class overrides the "ShouldStop()" method of StopInfo and this allows the stop info to determine if it should stop at the signal or continue the process. StopInfo subclasses must override the following functions: virtual lldb::StopReason GetStopReason () const = 0; virtual const char * GetDescription () = 0; StopInfo subclasses can override the following functions: // If the subclass returns "false", the inferior will resume. The default // version of this function returns "true" which means the default stop // info will stop the process. The breakpoint subclass will check if // the breakpoint wants us to stop by calling any installed callback on // the breakpoint, and also checking if the breakpoint is for the current // thread. Signals will check if they should stop based off of the // UnixSignal settings in the process. virtual bool ShouldStop (Event *event_ptr); // Sublasses can state if they want to notify the debugger when "ShouldStop" // returns false. This would be handy for breakpoints where you want to // log information and continue and is also used by the signal stop info // to notify that a signal was received (after it checks with the process // signal settings). virtual bool ShouldNotify (Event *event_ptr) { return false; } // Allow subclasses to do something intelligent right before we resume. // The signal class will figure out if the signal should be propagated // to the inferior process and pass that along to the debugger plug-ins. virtual void WillResume (lldb::StateType resume_state) { // By default, don't do anything } The support the Mach exceptions was moved into the lldb/source/Plugins/Process/Utility folder and now doesn't polute the lldb_private::Thread class with platform specific code. llvm-svn: 110184
* Fixed a bug where we didn't restore thread andSean Callanan2010-07-261-48/+56
| | | | | | | | frame state after running a function. This caused nondeterministic crashes in the expression evaluation code. llvm-svn: 109454
* Modified TaggedASTType to inherit from ClangASTTypeSean Callanan2010-07-231-50/+134
| | | | | | | | | | | | | and moved it to its own header file for cleanliness. Added more logging to ClangFunction so that we can diagnose crashes in the executing expression. Added code to extract the result of the expression from the struct that is passed to the JIT-compiled code. llvm-svn: 109199
* Remove use of STL collection class use of the "data()" method since it isn'tGreg Clayton2010-07-201-4/+4
| | | | | | | part of C++'98. Most of these were "std::vector<T>::data()" and "std::string::data()". llvm-svn: 108957
* I enabled some extra warnings for hidden local variables and for hiddenGreg Clayton2010-07-141-1/+1
| | | | | | virtual functions and caught some things and did some general code cleanup. llvm-svn: 108299
* Merged Eli Friedman's linux build changes where he added Makefile files thatGreg Clayton2010-07-091-17/+30
| | | | | | | enabled LLVM make style building and made this compile LLDB on Mac OS X. We can now iterate on this to make the build work on both linux and macosx. llvm-svn: 108009
* Updated to llvm/clang from July 2, 2010 at 8:00AM.Greg Clayton2010-07-021-5/+5
| | | | llvm-svn: 107494
* Initial checkin of lldb code from internal Apple repo.Chris Lattner2010-06-081-0/+671
llvm-svn: 105619
OpenPOWER on IntegriCloud