summaryrefslogtreecommitdiff
path: root/lldb/source/Target/ThreadPlanCallFunction.cpp
AgeCommit message (Collapse)Author
2013-02-27Add GNU indirect function support in expressions for Linux.Matt Kopec
llvm-svn: 176206
2013-02-14Add a test for handling a function call that throws an exception, and make ↵Jim Ingham
it work. <rdar://problem/13183944> llvm-svn: 175127
2013-02-09Reworked the way Process::RunThreadPlan and the ThreadPlanCallFunction ↵Jim Ingham
interoperate to fix problems where hitting auto-continue signals while running a thread plan would cause us to lose control of the debug session. <rdar://problem/12993641> llvm-svn: 174793
2013-01-15Separated the "expr --unwind-on-error" behavior into two parts, actual ↵Jim Ingham
errors (i.e. crashes) which continue to be controlled by the --unwind-on-error flag, and --ignore-breakpoint which separately controls behavior when a called function hits a breakpoint. For breakpoints, we don't unwind, we either stop, or ignore the breakpoint, which makes more sense. Also make both these behaviors globally settable through "settings set". Also handle the case where a breakpoint command calls code that ends up re-hitting the breakpoint. We were recursing and crashing. Now we just stop without calling the second command. <rdar://problem/12986644> <rdar://problem/9119325> llvm-svn: 172503
2012-12-07Set ThreadPlanCallFunction to private in ConstructorSetup. This fixes a ↵Andrew Kaylor
problem on Linux where 'continue' was misfiring after an expression evaluation when stopped at a breakpoint. The problem was that InferiorCallMmap was not setting its ThreadPlanCallFunction to private and so the completion of that thread plan appeared to be the stop reason and therefore the 'continue' operation failed to step over the breakpoint. The SetPrivate call is being put in ThreadPlanCallFunction rather than InferiorCallMmap to make the solution more general. llvm-svn: 169618
2012-11-29Resolve printf formatting warnings on Linux:Daniel Malea
- use macros from inttypes.h for format strings instead of OS-specific types Patch from Matt Kopec! llvm-svn: 168945
2012-11-26The Function calling thread plan was replacing the stored stop info too ↵Jim Ingham
soon, causing recursive entry into the breakpoint StopInfo's PerformAction, which is bad. Reworked this so that it is now correct. <rdar://problem/12501259> llvm-svn: 168634
2012-09-11Some more typing-related fixes.Filipe Cabecinhas
llvm-svn: 163638
2012-08-29<rdar://problem/11757916>Greg Clayton
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes: - Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file". - modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly - Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was. - modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile() Cleaned up header includes a bit as well. llvm-svn: 162860
2012-08-09Removed explicit NULL checks for shared pointersSean Callanan
and instead made us use implicit casts to bool. This generated a warning in C++11. <rdar://problem/11930775> llvm-svn: 161559
2012-05-11Found one more place where the OkayToDiscard needs to be consulted.Jim Ingham
Also changed the defaults for SBThread::Step* to not delete extant plans. Also added some test cases to test more complex stepping scenarios. llvm-svn: 156667
2012-05-11Don't try to use "OkayToDiscard" to mean BOTH this plan is a user plan or ↵Jim Ingham
not AND unwind on error. rdar://problem/11419156 llvm-svn: 156627
2012-05-10If the ObjC Step Through Trampoline plan causes a target crash, properly ↵Jim Ingham
propagate the error back to the controlling plans so that they don't lose control. Also change "ThreadPlanStepThrough" to take the return StackID for its backstop breakpoint as an argument to the constructor rather than having it try to figure it out itself, since it might get it wrong whereas the caller always knows where it is coming from. rdar://problem/11402287 llvm-svn: 156529
2012-04-13Don't do the work in DoTakedown if the thread plan isn't valid.Jim Ingham
Also fixed up some logging. llvm-svn: 154709
2012-04-13Factor out a bunch of common code in the two ThreadPlanCallFunction ↵Jim Ingham
constructors. Also add a sanity check - try reading the frame, and if we fail bag out. llvm-svn: 154698
2012-04-13ThreadPlanCallFunction's destructor wasn't calling DoTakedown, so if the ↵Jim Ingham
that plan got discarded we weren't doing the takedown. llvm-svn: 154681
2012-04-10Set variables returned by utility functions toSean Callanan
not consume slots in the persistent variable store. llvm-svn: 154416
2012-04-09Rework how master plans declare themselves. Also make "PlanIsBasePlan" not ↵Jim Ingham
rely only on this being the bottom plan in the stack, but allow the plan to declare itself as such. llvm-svn: 154351
2012-02-21Thread hardening part 3. Now lldb_private::Thread objects have std::weak_ptrGreg Clayton
objects for the backlink to the lldb_private::Process. The issues we were running into before was someone was holding onto a shared pointer to a lldb_private::Thread for too long, and the lldb_private::Process parent object would get destroyed and the lldb_private::Thread had a "Process &m_process" member which would just treat whatever memory that used to be a Process as a valid Process. This was mostly happening for lldb_private::StackFrame objects that had a member like "Thread &m_thread". So this completes the internal strong/weak changes. Documented the ExecutionContext and ExecutionContextRef classes so that our LLDB developers can understand when and where to use ExecutionContext and ExecutionContextRef objects. llvm-svn: 151009
2011-12-22Improve the x86_64 return value decoder to handle most structure returns.Jim Ingham
Switch from GetReturnValue, which was hardly ever used, to GetReturnValueObject which is much more convenient. Return the "return value object" as a persistent variable if requested. llvm-svn: 147157
2011-11-01Enhanced the ObjC DynamicCheckerFunction to test for "object responds to ↵Jim Ingham
selector" as well as "object borked"... Also made the error when the checker fails reflect this fact rather than report a crash at 0x0. Also a little cleanup: - StopInfoMachException had a redundant copy of the description string. - ThreadPlanCallFunction had a redundant copy of the thread, and had a copy of the process that it didn't really need. llvm-svn: 143419
2011-10-19Moved lldb::user_id_t values to be 64 bit. This was going to be needed forGreg Clayton
process IDs, and thread IDs, but was mainly needed for for the UserID's for Types so that DWARF with debug map can work flawlessly. With DWARF in .o files the type ID was the DIE offset in the DWARF for the .o file which is not unique across all .o files, so now the SymbolFileDWARFDebugMap class will make the .o file index part (the high 32 bits) of the unique type identifier so it can uniquely identify the types. llvm-svn: 142534
2011-08-12Make ValueObject::SetValueFromCString work correctly.Jim Ingham
Also change the SourceInitFile to look for .lldb-<APPNAME> and source that preferentially if it exists. Also made the breakpoint site report its address as well as its breakpoint number when it gets hit and can't find any the associated locations (usually because the breakpoint got disabled or deleted programmatically between the time it was hit and reported.) Changed ThreadPlanCallFunction to initialize the ivar m_func in the initializers of the constructor, rather than waiting to initialize till later on in the function. Fixed a bug where if you make an SBError and the ask it Success, it returns false. Fixed ValueObject::ResolveValue so that it resolves a temporary value, rather than overwriting the one in the value object. llvm-svn: 137536
2011-08-11Fix the broken build that happened with my last checkin.Greg Clayton
llvm-svn: 137300
2011-08-11Added the ability to remove orphaned module shared pointers from a ModuleList.Greg Clayton
This is helping us track down some extra references to ModuleSP objects that are causing things to get kept around for too long. Added a module pointer accessor to target and change a lot of code to use it where it would be more efficient. "taret delete" can now specify "--clean=1" which will cleanup the global module list for any orphaned module in the shared module cache which can save memory and also help track down module reference leaks like we have now. llvm-svn: 137294
2011-08-10Check log shared pointer before using it.Johnny Chen
llvm-svn: 137228
2011-07-19The implementation of categories is now synchronization safeEnrico Granata
Code cleanup: - The Format Manager implementation is now split between two files: FormatClasses.{h|cpp} where the actual formatter classes (ValueFormat, SummaryFormat, ...) are implemented and FormatManager.{h|cpp} where the infrastructure classes (FormatNavigator, FormatManager, ...) are contained. The wrapper code always remains in Debugger.{h|cpp} - Several leftover fields, methods and comments from previous design choices have been removed type category subcommands (enable, disable, delete) now can take a list of category names as input - for type category enable, saying "enable A B C" is the same as saying enable C enable B enable A (the ordering is relevant in enabling categories, and it is expected that a user typing enable A B C wants to look into category A, then into B, then into C and not the other way round) - for the other two commands, the order is not really relevant (however, the same inverted ordering is used for consistency) llvm-svn: 135494
2011-06-03Fix some order-of-initialisation warningsPeter Collingbourne
llvm-svn: 132588
2011-05-19Fixed a crasher that was happened when a log shared pointer wasn't valid.Greg Clayton
Fixed ThreadPlanCallFunction::ReportRegisterState(...) to only dump when verbose logging is enabled and fixed the function to use the new RegisterValue method of reading registers. Fixed the GDB remote client to not send a continue packet after receiving stdout or stderr from the inferior process. llvm-svn: 131628
2011-05-17Fix the error message when an expression evaluation is interrupted by a ↵Jim Ingham
crash/breakpoint hit to give the reason for the interrupt. Also make sure it we don't want to unwind from the evaluation we print something if it is interrupted. llvm-svn: 131448
2011-05-15Added the ability to get the return value from a ThreadPlanCallFunctionGreg Clayton
thread plan. In order to get the return value, you can call: void ThreadPlanCallFunction::RequestReturnValue (lldb::ValueSP &return_value_sp); This registers a shared pointer to a return value that will get filled in if everything goes well. After the thread plan is run the return value will be extracted for you. Added an ifdef to be able to switch between the LLVM MCJIT and the standand JIT. We currently have the standard JIT selected because we have some work to do to get the MCJIT fuctioning properly. Added the ability to call functions with 6 argument in the x86_64 ABI. Added the ability for GDBRemoteCommunicationClient to detect if the allocate and deallocate memory packets are supported and to not call allocate memory ("_M") or deallocate ("_m") if we find they aren't supported. Modified the ProcessGDBRemote::DoAllocateMemory(...) and ProcessGDBRemote::DoDeallocateMemory(...) to be able to deal with the allocate and deallocate memory packets not being supported. If they are not supported, ProcessGDBRemote will switch to calling "mmap" and "munmap" to allocate and deallocate memory instead using our trivial function call support. Modified the "void ProcessGDBRemote::DidLaunchOrAttach()" to correctly ignore the qHostInfo triple information if any was specified in the target. Currently if the target only specifies an architecture when creating the target: (lldb) target create --arch i386 a.out Then the vendor, os and environemnt will be adopted by the target. If the target was created with any triple that specifies more than the arch: (lldb) target create --arch i386-unknown-unknown a.out Then the target will maintain its triple and not adopt any new values. This can be used to help force bare board debugging where the dynamic loader for static files will get used and users can then use "target modules load ..." to set addressses for any files that are desired. Added back some convenience functions to the lldb_private::RegisterContext class for writing registers with unsigned values. Also made all RegisterContext constructors explicit to make sure we know when an integer is being converted to a RegisterValue. llvm-svn: 131370
2011-05-14Expand the ABI prepare trivial function call to allow 6 simple args.Greg Clayton
llvm-svn: 131334
2011-05-12Cleaned up the ABI::PrepareTrivialCall() function to take three argumentGreg Clayton
pointers: virtual bool PrepareTrivialCall (Thread &thread, lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, lldb::addr_t *arg1_ptr, lldb::addr_t *arg2_ptr, lldb::addr_t *arg3_ptr) const = 0; Prior to this it was: virtual bool PrepareTrivialCall (Thread &thread, lldb::addr_t sp, lldb::addr_t functionAddress, lldb::addr_t returnAddress, lldb::addr_t arg, lldb::addr_t *this_arg, lldb::addr_t *cmd_arg) const = 0; This was because the function that called this slowly added more features to be able to call a C++ member function that might have a "this" pointer, and then later added "self + cmd" support for objective C. Cleaning this code up and the code that calls it makes it easier to implement the functions for new targets. The MacOSX_arm::PrepareTrivialCall() is now filled in and ready for testing. llvm-svn: 131221
2011-05-11Moved all code from ArchDefaultUnwindPlan and ArchVolatileRegs into theirGreg Clayton
respective ABI plugins as they were plug-ins that supplied ABI specfic info. Also hookep up the UnwindAssemblyInstEmulation so that it can generate the unwind plans for ARM. Changed the way ABI plug-ins are handed out when you get an instance from the plug-in manager. They used to return pointers that would be mananged individually by each client that requested them, but now they are handed out as shared pointers since there is no state in the ABI objects, they can be shared. llvm-svn: 131193
2011-05-09Fixed a bug in which expression-local variables wereSean Callanan
treated as being permanently resident in target memory. In fact, since the expression's stack frame is deleted and potentially re-used after the expression completes, the variables need to be treated as being freeze-dried. llvm-svn: 131104
2011-03-07Add a method "GetEntryPoint" to the ObjectFile class, and implement it on ↵Jim Ingham
MachO & ELF - though the ELF implementation is probably a little weak. Then use this method in place of directly looking for "start" in the ThreadPlanCallFunction constructor to find the stopping point for our function evaluation. llvm-svn: 127194
2011-01-26Make sure that if a CallFunction thread plan crashes while running in the ↵Jim Ingham
"run to address" mode, and it is an auto-discard thread plan, the plan stack unwinds properly. llvm-svn: 124306
2011-01-22Centralize the register reporting (might want to move this function to Thread).Jim Ingham
Make sure DoTakedown gets called only once by adding a dedicated m_takedown_done bool. Add a little more useful logging. llvm-svn: 124015
2011-01-20Back up both the register AND the stop state when calling functions.Jim Ingham
Set the thread state to "bland" before calling functions so they don't inherit the pending signals and die. llvm-svn: 123869
2011-01-18In ThreadPlanCallFunction, do the Takedown right when the thread plan gets ↵Jim Ingham
popped. When the function call is discarded (e.g. when it crashes and discard_on_error is true) the plan gets discarded. You need to make sure that the stack gets restored right then, and not wait till you start again and the thread plan stack is cleared. llvm-svn: 123716
2011-01-06Fixed issues with RegisterContext classes and the subclasses. There wasGreg Clayton
an issue with the way the UnwindLLDB was handing out RegisterContexts: it was making shared pointers to register contexts and then handing out just the pointers (which would get put into shared pointers in the thread and stack frame classes) and cause double free issues. MallocScribble helped to find these issues after I did some other cleanup. To help avoid any RegisterContext issue in the future, all code that deals with them now returns shared pointers to the register contexts so we don't end up with multiple deletions. Also now that the RegisterContext class doesn't require a stack frame, we patched a memory leak where a StackFrame object was being created and leaked. Made the RegisterContext class not have a pointer to a StackFrame object as one register context class can be used for N inlined stack frames so there is not a 1 - 1 mapping. Updates the ExecutionContextScope part of the RegisterContext class to never return a stack frame to indicate this when it is asked to recreate the execution context. Now register contexts point to the concrete frame using a concrete frame index. Concrete frames are all of the frames that are actually formed on the stack of a thread. These concrete frames can be turned into one or more user visible frames due to inlining. Each inlined stack frame has the exact same register context (shared via shared pointers) as any parent inlined stack frames all the way up to the concrete frame itself. So now the stack frames and the register contexts should behave much better. llvm-svn: 122976
2010-12-13Added support for generating expressions that haveSean Callanan
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
2010-11-12Excised a version of the low-level function callingSean Callanan
logic that supported calling functions with arbitrary arguments. We use ClangFunction for this, and the low-level logic is only required to support one or two pointer arguments. llvm-svn: 118871
2010-11-11Add ThreadPlanTracer class to allow instruction step tracing of execution.Jim Ingham
Also changed eSetVarTypeBool to eSetVarTypeBoolean to make it consistent with eArgTypeBoolean. llvm-svn: 118824
2010-11-08Added more logging so we see the register stateSean Callanan
when a function starts and ends, and also the disassembly for anything that is a client of ClangExpressionParser after it has been JIT compiled. llvm-svn: 118401
2010-11-06Modified all logging calls to hand out shared pointers to make sure weGreg Clayton
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
2010-11-04Re-enabled LLDB's pointer checkers, and moved theSean Callanan
implementation of the Objective-C object checkers into the Objective-C language runtime. llvm-svn: 118226
2010-11-03Factored the code that implements breakpoints onSean Callanan
exceptions for different languages out of ThreadPlanCallFunction and put it into the appropriate language runtimes. llvm-svn: 118200
2010-11-03Modified ThreadPlanCallFunction to perform theSean Callanan
exception checks at the right time, and modified ClangFunction so that it doesn't misinterpret the stop as a timeout stop. llvm-svn: 118189
2010-11-03Modified the thread plan that calls functions toSean Callanan
set breakpoints at the different locations where an exception could be thrown, so that exceptions thrown by expressions are properly caught. llvm-svn: 118142