summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Thread.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Don't try to use "OkayToDiscard" to mean BOTH this plan is a user plan or ↵Jim Ingham2012-05-111-1/+0
| | | | | | | | not AND unwind on error. rdar://problem/11419156 llvm-svn: 156627
* If the ObjC Step Through Trampoline plan causes a target crash, properly ↵Jim Ingham2012-05-101-2/+2
| | | | | | | | | | | | | | 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
* Clean up the usage of "MasterPlan" status in ThreadPlans. Only ↵Jim Ingham2012-05-031-4/+35
| | | | | | | | | | | | | | | user-initiated plans should be MasterPlans that want to stay on the plan stack. So make all plans NOT MasterPlans by default and then have the SB API's and the CommandObjectThread step commands set this explicitly. Also added a "clean up" phase to the Thread::ShouldStop so that if plans get stranded on the stack, we can remove them. This is done by adding an IsPlanStale method to the thread plans, and if the plan can know that it is no longer relevant, it returns true, and the plan and its sub-plans will get discarded. llvm-svn: 156101
* Fix reporting of stop reasons when the StepOver & StepIn plans stop because ↵Jim Ingham2012-05-011-1/+1
| | | | | | of a crash or breakpoint. Added the ability for a plan to say it is done but doesn't want to be the reason for the stop. llvm-svn: 155927
* Make sure the "synchronous breakpoint callbacks" get called before the ↵Jim Ingham2012-04-201-0/+11
| | | | | | | | | | | thread plan logic gets invoked, and if they ask to continue that should short-circuit the thread plans for that thread. Also add a bit more explanation for how this machinery is supposed to work. Also pass eExecutionPolicyOnlyWhenNeeded, not eExecutionPolicyAlways when evaluating the expression for breakpoint conditions. llvm-svn: 155236
* The plan stack should never be used while empty. GetCurrentPlan is the ↵Jim Ingham2012-04-191-4/+5
| | | | | | | | | entry point to contol logic for the plan stack, so assert here if it gets called with an empty plan stack. <rdar://problem/11265974> llvm-svn: 155078
* Clear the "m_actual_stop_info_sp" in the thread during Destroy. It might be ↵Jim Ingham2012-04-101-0/+1
| | | | | | a StopInfoThreadPlan, and that would hold onto members that need to be destroyed while the Full thread is still around. llvm-svn: 154366
* Rework how master plans declare themselves. Also make "PlanIsBasePlan" not ↵Jim Ingham2012-04-091-1/+12
| | | | | | rely only on this being the bottom plan in the stack, but allow the plan to declare itself as such. llvm-svn: 154351
* <rdar://problem/11035349> Greg Clayton2012-03-291-20/+32
| | | | | | Fixed an issue with stepping where the stack frame list could get changed out from underneath you when multiple threads start accessing frame info. llvm-svn: 153627
* When comparing a Thread against a ThreadSpec, don't fetch the Thread's Name ↵Jim Ingham2012-03-071-1/+1
| | | | | | or QueueName if the ThreadSpec doesn't specify them. llvm-svn: 152245
* Make the StackFrameList::GetFrameAtIndex only fetch as many stack frames as ↵Jim Ingham2012-02-291-1/+4
| | | | | | | | | needed to get the frame requested. <rdar://problem/10943135> llvm-svn: 151705
* Thread hardening part 3. Now lldb_private::Thread objects have std::weak_ptrGreg Clayton2012-02-211-22/+43
| | | | | | | | | | | | | | | | | 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
* The second part in thread hardening the internals of LLDB where we makeGreg Clayton2012-02-181-7/+7
| | | | | | | | | | | | | | | | the lldb_private::StackFrame objects hold onto a weak pointer to the thread object. The lldb_private::StackFrame objects the the most volatile objects we have as when we are doing single stepping, frames can often get lost or thrown away, only to be re-created as another object that still refers to the same frame. We have another bug tracking that. But we need to be able to have frames no longer be able to get the thread when they are not part of a thread anymore, and this is the first step (this fix makes that possible but doesn't implement it yet). Also changed lldb_private::ExecutionContextScope to return shared pointers to all objects in the execution context to further thread harden the internals. llvm-svn: 150871
* Threads now store their "temporary" resume state, so we know whether they ↵Jim Ingham2012-01-311-3/+72
| | | | | | | | | were suspended in the most recent step, and if they weren't allowed to run, don't ask questions about their state unless explicitly requested to do so. llvm-svn: 149443
* SBFrame is now threadsafe using some extra tricks. One issue is that stackGreg Clayton2012-01-301-22/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | frames might go away (the object itself, not the actual logical frame) when we are single stepping due to the way we currently sometimes end up flushing frames when stepping in/out/over. They later will come back to life represented by another object yet they have the same StackID. Now when you get a lldb::SBFrame object, it will track the frame it is initialized with until the thread goes away or the StackID no longer exists in the stack for the thread it was created on. It uses a weak_ptr to both the frame and thread and also stores the StackID. These three items allow us to determine when the stack frame object has gone away (the weak_ptr will be NULL) and allows us to find the correct frame again. In our test suite we had such cases where we were just getting lucky when something like this happened: 1 - stop at breakpoint 2 - get first frame in thread where we stopped 3 - run an expression that causes the program to JIT and run code 4 - run more expressions on the frame from step 2 which was very very luckily still around inside a shared pointer, yet, not part of the current thread (a new stack frame object had appeared with the same stack ID and depth). We now avoid all such issues and properly keep up to date, or we start returning errors when the frame doesn't exist and always responds with invalid answers. Also fixed the UserSettingsController (not going to rewrite this just yet) so that it doesn't crash on shutdown. Using weak_ptr's came in real handy to track when the master controller has already gone away and this allowed me to pull out the previous NotifyOwnerIsShuttingDown() patch as it is no longer needed. llvm-svn: 149231
* Switching back to using std::tr1::shared_ptr. We originally switched awayGreg Clayton2012-01-291-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | due to RTTI worries since llvm and clang don't use RTTI, but I was able to switch back with no issues as far as I can tell. Once the RTTI issue wasn't an issue, we were looking for a way to properly track weak pointers to objects to solve some of the threading issues we have been running into which naturally led us back to std::tr1::weak_ptr. We also wanted the ability to make a shared pointer from just a pointer, which is also easily solved using the std::tr1::enable_shared_from_this class. The main reason for this move back is so we can start properly having weak references to objects. Currently a lldb_private::Thread class has a refrence to its parent lldb_private::Process. This doesn't work well when we now hand out a SBThread object that contains a shared pointer to a lldb_private::Thread as this SBThread can be held onto by external clients and if they end up using one of these objects we can easily crash. So the next task is to start adopting std::tr1::weak_ptr where ever it makes sense which we can do with lldb_private::Debugger, lldb_private::Target, lldb_private::Process, lldb_private::Thread, lldb_private::StackFrame, and many more objects now that they are no longer using intrusive ref counted pointer objects (you can't do std::tr1::weak_ptr functionality with intrusive pointers). llvm-svn: 149207
* Improve the x86_64 return value decoder to handle most structure returns.Jim Ingham2011-12-221-1/+1
| | | | | | | | 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
* Add the ability to capture the return value in a thread's stop info, and ↵Jim Ingham2011-12-171-1/+17
| | | | | | | | | | | | | print it as part of the thread format output. Currently this is only done for the ThreadPlanStepOut. Add a convenience API ABI::GetReturnValueObject. Change the ValueObject::EvaluationPoint to BE an ExecutionContextScope, rather than trying to hand out one of its subsidiary object's pointers. That way this will always be good. llvm-svn: 146806
* Make the ThreadPlanStepThrough set a backstop breakpoint on the return ↵Jim Ingham2011-12-031-36/+57
| | | | | | | | | | | | | | address from the function it is being asked to step through, so that even if we get the trampoline target wrong (for instance) we will still not lose control. The other fix here is to tighten up the handling of the case where the current plan doesn't explain the stop, but a plan above us does. In that case, if the plan that does explain the stop says it is done, we need to clean up the plans below it and continue on with our processing. llvm-svn: 145740
* Moved lldb::user_id_t values to be 64 bit. This was going to be needed forGreg Clayton2011-10-191-12/+12
| | | | | | | | | | | 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
* Make the "log enable lldb-step" output easier to parse.Jim Ingham2011-10-151-18/+43
| | | | llvm-svn: 142025
* Converted the lldb_private::Process over to use the intrusiveGreg Clayton2011-09-221-6/+7
| | | | | | | | | | | | | | | | | | | | shared pointers. Changed the ExecutionContext over to use shared pointers for the target, process, thread and frame since these objects can easily go away at any time and any object that was holding onto an ExecutionContext was running the risk of using a bad object. Now that the shared pointers for target, process, thread and frame are just a single pointer (they all use the instrusive shared pointers) the execution context is much safer and still the same size. Made the shared pointers in the the ExecutionContext class protected and made accessors for all of the various ways to get at the pointers, references, and shared pointers. llvm-svn: 140298
* Update declarations for all functions/methods that accept printf-styleJason Molenda2011-09-201-1/+1
| | | | | | | | stdarg formats to use __attribute__ format so the compiler can flag incorrect uses. Fix all incorrect uses. Most of these are innocuous, a few were resulting in crashes. llvm-svn: 140185
* Adopt the intrusive pointers in:Greg Clayton2011-09-171-1/+3
| | | | | | | | | | | | lldb_private::Breakpoint lldb_private::BreakpointLocations lldb_private::BreakpointSite lldb_private::Debugger lldb_private::StackFrame lldb_private::Thread lldb_private::Target llvm-svn: 139985
* Move the SourceManager from the Debugger to the Target. That way it can ↵Jim Ingham2011-09-081-46/+0
| | | | | | | | | | store the per-Target default Source File & Line. Set the default Source File & line to main (if it can be found.) at startup. Selecting the current thread & or frame resets the current source file & line, and "source list" as well as the breakpoint command "break set -l <NUM>" will use the current source file. llvm-svn: 139323
* Added a new plug-in type: lldb_private::OperatingSystem. The operating system Greg Clayton2011-08-221-0/+29
| | | | | | | | | | | | | | | | | | | | plug-ins are add on plug-ins for the lldb_private::Process class that can add thread contexts that are read from memory. It is common in kernels to have a lot of threads that are not currently executing on any cores (JTAG debugging also follows this sort of thing) and are context switched out whose state is stored in memory data structures. Clients can now subclass the OperatingSystem plug-ins and then make sure their Create functions correcltly only enable themselves when the right binary/target triple are being debugged. The operating system plug-ins get a chance to attach themselves to processes just after launching or attaching and are given a lldb_private::Process object pointer which can be inspected to see if the main executable, target triple, or any shared libraries match a case where the OS plug-in should be used. Currently the OS plug-ins can create new threads, define the register contexts for these threads (which can all be different if desired), and populate and manage the thread info (stop reason, registers in the register context) as the debug session goes on. llvm-svn: 138228
* Add missing check for non-NULL frame_sp.Jim Ingham2011-08-161-3/+6
| | | | llvm-svn: 137692
* We were leaking a stack frame in StackFrameList in Thread.cpp which couldGreg Clayton2011-08-121-11/+8
| | | | | | | | | | 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
* Fixed some issues with parsing C++ methods where our detectionGreg Clayton2011-08-121-7/+7
| | | | | | | | | | | | | was failing if the DWARF was laid out in a certain way. The way we detect C++ classes is now more robust so that a class method can be defined outside of the class and refer to a definition inside the class with a DW_AT_specification or DW_AT_abstract_origin attribute. Fixed a case in Thread.cpp where we were looking up info in the frame when we didn't need to. This was from some changes to support external editors. Now the info is only looked up if needed. llvm-svn: 137436
* Don't create a new stop info if we've already calculated one and it is still ↵Jim Ingham2011-08-091-1/+10
| | | | | | valid. llvm-svn: 137084
* Indent the frames in the "thread.GetStatus" frame listing. Also put the ↵Jim Ingham2011-07-261-0/+2
| | | | | | same space after each thread listing for "thread backtrace all" as "thread backtrace 1 3 5" llvm-svn: 136052
* Move SaveFrameZeroState and RestoreSaveFrameZero implementations to Thread ↵Peter Collingbourne2011-06-031-0/+27
| | | | | | base class llvm-svn: 132586
* Fixed a crasher that was happened when a log shared pointer wasn't valid.Greg Clayton2011-05-191-1/+1
| | | | | | | | | | | 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
* Centralized a lot of the status information for processes,Greg Clayton2011-04-181-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | threads, and stack frame down in the lldb_private::Process, lldb_private::Thread, lldb_private::StackFrameList and the lldb_private::StackFrame classes. We had some command line commands that had duplicate versions of the process status output ("thread list" and "process status" for example). Removed the "file" command and placed it where it should have been: "target create". Made an alias for "file" to "target create" so we stay compatible with GDB commands. We can now have multple usable targets in lldb at the same time. This is nice for comparing two runs of a program or debugging more than one binary at the same time. The new command is "target select <target-idx>" and also to see a list of the current targets you can use the new "target list" command. The flow in a debug session can be: (lldb) target create /path/to/exe/a.out (lldb) breakpoint set --name main (lldb) run ... hit breakpoint (lldb) target create /bin/ls (lldb) run /tmp Process 36001 exited with status = 0 (0x00000000) (lldb) target list Current targets: target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped ) * target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited ) (lldb) target select 0 Current targets: * target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped ) target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited ) (lldb) bt * thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1 frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16 frame #1: 0x0000000100000b64 a.out`start + 52 Above we created a target for "a.out" and ran and hit a breakpoint at "main". Then we created a new target for /bin/ls and ran it. Then we listed the targest and selected our original "a.out" program, so we showed two concurent debug sessions going on at the same time. llvm-svn: 129695
* Add GetFrameWithStackID to the StackFrameList and the Thread (which routes ↵Jim Ingham2011-03-311-0/+5
| | | | | | to its StackFrameList.) llvm-svn: 128592
* Fixed the LLDB build so that we can have private types, private enums andGreg Clayton2011-03-241-1/+1
| | | | | | | | 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
* The UserSettings controllers must be initialized & terminated in theCaroline Tice2011-03-101-2/+10
| | | | | | | | correct order. Previously this was tacitly implemented but not enforced, so it was possible to accidentally do things in the wrong order and cause problems. This fixes that problem. llvm-svn: 127430
* Rework the RunThreadPlan event handling to use Event Hijacking not stopping ↵Jim Ingham2011-02-081-24/+40
| | | | | | the event thread. Also clarify the logic of the function. llvm-svn: 125083
* Endian patch from Kirk Beitz that allows better cross platform building.Greg Clayton2011-02-011-1/+0
| | | | llvm-svn: 124643
* Enabled extra warnings and fixed a bunch of small issues.Greg Clayton2011-01-251-1/+1
| | | | llvm-svn: 124250
* Check for a NULL saved stop info shared pointer.Jim Ingham2011-01-251-1/+2
| | | | llvm-svn: 124170
* More useful STEP logging.Jim Ingham2011-01-241-1/+19
| | | | | | Be sure to clear out the base plan's m_report_run and m_report_stop each time we resume so we don't use stale values. llvm-svn: 124113
* Added support for stepping out of a frame. If you have 10 stack frames, and you Greg Clayton2011-01-211-8/+28
| | | | | | | | | | select frame #3, you can then do a step out and be able to go directly to the frame above frame #3! Added StepOverUntil and StepOutOfFrame to the SBThread API to allow more powerful stepping. llvm-svn: 123970
* Back up both the register AND the stop state when calling functions.Jim Ingham2011-01-201-1/+38
| | | | | | | Set the thread state to "bland" before calling functions so they don't inherit the pending signals and die. llvm-svn: 123869
* Added the following functions to SBThread to allow threads to be suspended ↵Greg Clayton2011-01-121-24/+0
| | | | | | | | | | when a process is resumed: bool SBThread::Suspend(); bool SBThread::Resume(); bool SBThread::IsSuspended(); llvm-svn: 123300
* Fixed issues with RegisterContext classes and the subclasses. There wasGreg Clayton2011-01-061-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Added the ability for a process to inherit the current host environment. ThisGreg Clayton2010-12-041-1/+1
| | | | | | | | | | was done as an settings variable in the process for now. We will eventually move all environment stuff over to the target, but we will leave it with the process for now. The default setting is for a process to inherit the host environment. This can be disabled by setting the "inherit-env" setting to false in the process. llvm-svn: 120862
* Fixed an issue where the UserSettingsControllers were being created out ofGreg Clayton2010-11-191-4/+5
| | | | | | | order and this was causing the target, process and thread trees to not be available. llvm-svn: 119784
* Cleaned up code that wasn't using the Initialize and Terminate paradigm byGreg Clayton2010-11-181-25/+28
| | | | | | | | | | | | | | | | | | changing it to use it. There was an extra parameter added to the static accessor global user settings controllers that wasn't needed. A bool was being used as a parameter to the accessor just so it could be used to clean up the global user settings controller which is now fixed by splitting up the initialization into the "static void Class::Initialize()", access into the "static UserSettingsControllerSP & Class::GetSettingsController()", and cleanup into "static void Class::Terminate()". Also added initialize and terminate calls to the logging code to avoid issues when LLDB is shutting down. There were cases after the logging was switched over to use shared pointers where we could crash if the global destructor chain was being run and it causes the log to be destroyed and any any logging occurred. llvm-svn: 119757
* The thread plan destructors may call Thread virtual methods. That means ↵Jim Ingham2010-11-181-2/+13
| | | | | | they have to get cleaned up in the derived class's destructor. Make sure that happens. llvm-svn: 119675
OpenPOWER on IntegriCloud