summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Thread.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Excised a version of the low-level function callingSean Callanan2010-11-121-12/+0
| | | | | | | | | 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
* Add ThreadPlanTracer class to allow instruction step tracing of execution.Jim Ingham2010-11-111-48/+118
| | | | | | Also changed eSetVarTypeBool to eSetVarTypeBoolean to make it consistent with eArgTypeBoolean. llvm-svn: 118824
* Remove an obsolete reference to immediate plans.Jim Ingham2010-11-101-1/+1
| | | | llvm-svn: 118691
* Modified all logging calls to hand out shared pointers to make sure weGreg Clayton2010-11-061-8/+8
| | | | | | | | | | | 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-6/+41
| | | | | | and a parameter to control it in ClangUserExpression, and on down to ClangFunction. llvm-svn: 118290
* First pass at adding logging capabilities for the API functions. At the momentCaroline Tice2010-10-261-0/+36
| | | | | | | | | | | | | | | | | | it logs the function calls, their arguments and the return values. This is not complete or polished, but I am committing it now, at the request of someone who really wants to use it, even though it's not really done. It currently does not attempt to log all the functions, just the most important ones. I will be making further adjustments to the API logging code over the next few days/weeks. (Suggestions for improvements are welcome). Update the Python build scripts to re-build the swig C++ file whenever the python-extensions.swig file is modified. Correct the help for 'log enable' command (give it the correct number & type of arguments). llvm-svn: 117349
* Don't cache the public stop reason, since it can change as plan completion ↵Jim Ingham2010-10-201-61/+11
| | | | | | 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
* Added a new test case to test signals with.Greg Clayton2010-10-101-0/+7
| | | | | | | | | | | | | | | | | | Added frame relative frame selection to "frame select". You can now select frames relative to the current frame (which defaults to zero if the current frame hasn't yet been set for a thread): The gdb "up" command can be done as: (lldb) frame select -r 1 The gdb "down" command can be done as: (lldb) frame select -r -1 Place the following in your ~/.lldbinit file for "up" and "down": command alias up frame select -r 1 command alias down frame select -r -1 llvm-svn: 116176
* There are now to new "settings set" variables that live in each debuggerGreg Clayton2010-10-041-40/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instance: settings set frame-format <string> settings set thread-format <string> This allows users to control the information that is seen when dumping threads and frames. The default values are set such that they do what they used to do prior to changing over the the user defined formats. This allows users with terminals that can display color to make different items different colors using the escape control codes. A few alias examples that will colorize your thread and frame prompts are: settings set frame-format 'frame #${frame.index}: \033[0;33m${frame.pc}\033[0m{ \033[1;4;36m${module.file.basename}\033[0;36m ${function.name}{${function.pc-offset}}\033[0m}{ \033[0;35mat \033[1;35m${line.file.basename}:${line.number}}\033[0m\n' settings set thread-format 'thread #${thread.index}: \033[1;33mtid\033[0;33m = ${thread.id}\033[0m{, \033[0;33m${frame.pc}\033[0m}{ \033[1;4;36m${module.file.basename}\033[0;36m ${function.name}{${function.pc-offset}}\033[0m}{, \033[1;35mstop reason\033[0;35m = ${thread.stop-reason}\033[0m}{, \033[1;36mname = \033[0;36m${thread.name}\033[0m}{, \033[1;32mqueue = \033[0;32m${thread.queue}}\033[0m\n' A quick web search for "colorize terminal output" should allow you to see what you can do to make your output look like you want it. The "settings set" commands above can of course be added to your ~/.lldbinit file for permanent use. Changed the pure virtual void ExecutionContextScope::Calculate (ExecutionContext&); To: void ExecutionContextScope::CalculateExecutionContext (ExecutionContext&); I did this because this is a class that anything in the execution context heirarchy inherits from and "target->Calculate (exe_ctx)" didn't always tell you what it was really trying to do unless you look at the parameter. llvm-svn: 115485
* Replace the vestigial Value::GetOpaqueCLangQualType with the more correct ↵Jim Ingham2010-09-281-0/+10
| | | | | | | | Value::GetValueOpaqueClangQualType. But mostly, move the ObjC Trampoline handling code from the MacOSX dyld plugin to the AppleObjCRuntime classes. llvm-svn: 114935
* Create more useful instance names for target, process and thread instances.Caroline Tice2010-09-271-0/+16
| | | | | | | Change default 'set' behavior so that all instance settings for the specified variable will be updated, unless the "-n" ("--no_override") command options is specified. llvm-svn: 114808
* Add GetSP to the StackFrame.Jim Ingham2010-09-231-0/+5
| | | | llvm-svn: 114674
* Make GetInstanceSettingsValue methods take an Error * rather than an Error &,Caroline Tice2010-09-201-3/+8
| | | | | | and have them return a bool to indicate success or not. llvm-svn: 114361
* Add UserSettings to Target class, making Target settingsCaroline Tice2010-09-201-4/+5
| | | | | | | | | | | | | | | | | | the parent of Process settings; add 'default-arch' as a class-wide setting for Target. Replace lldb::GetDefaultArchitecture with Target::GetDefaultArchitecture & Target::SetDefaultArchitecture. Add 'use-external-editor' as user setting to Debugger class & update code appropriately. Add Error parameter to methods that get user settings, for easier reporting of bad requests. Fix various other minor related bugs. Fix test cases to work with new changes. llvm-svn: 114352
* Added code that will allow completely customizable prompts for use inGreg Clayton2010-09-191-20/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | replacing the "(lldb)" prompt, the "frame #1..." displays when doing stack backtracing and the "thread #1....". This will allow you to see exactly the information that you want to see where you want to see it. This currently isn't hookup up to the prompts yet, but it will be soon. So what is the format of the prompts? Prompts can contain variables that have access to the current program state. Variables are text that appears in between a prefix of "${" and ends with a "}". Some of the interesting variables include: // The frame index (0, 1, 2, 3...) ${frame.index} // common frame registers with generic names ${frame.pc} ${frame.sp} ${frame.fp} ${frame.ra} ${frame.flags} // Access to any frame registers by name where REGNAME is any register name: ${frame.reg.REGNAME} // The current compile unit file where the frame is located ${file.basename} ${file.fullpath} // Function information ${function.name} ${function.pc-offset} // Process info ${process.file.basename} ${process.file.fullpath} ${process.id} ${process.name} // Thread info ${thread.id} ${thread.index} ${thread.name} ${thread.queue} ${thread.stop-reason} // Target information ${target.arch} // The current module for the current frame (the shared library or executable // that contains the current frame PC value): ${module.file.basename} ${module.file.fullpath} // Access to the line entry for where the current frame is when your thread // is stopped: ${line.file.basename} ${line.file.fullpath} ${line.number} ${line.start-addr} ${line.end-addr} Many times the information that you might have in your prompt might not be available and you won't want it to print out if it isn't valid. To take care of this you can enclose everything that must resolve into a scope. A scope is starts with '{' and ends with '}'. For example in order to only display the current file and line number when the information is available the format would be: "{ at {$line.file.basename}:${line.number}}" Broken down this is: start the scope: "{" format whose content will only be displayed if all information is available: "at {$line.file.basename}:${line.number}" end the scope: "}" We currently can represent the infomration we see when stopped at a frame: frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19 with the following format: "frame #${frame.index}: ${frame.pc} {${module.file.basename}`}{${function.name}{${function.pc-offset}}{ at ${line.file.basename}:${line.number}}\n" This breaks down to always print: "frame #${frame.index}: ${frame.pc} " only print the module followed by a tick if we have a valid module: "{${module.file.basename}`}" print the function name with optional offset: "{${function.name}{${function.pc-offset}}" print the line info if it is available: "{ at ${line.file.basename}:${line.number}}" then finish off with a newline: "\n" Notice you can also put newlines ("\n") and tabs and everything else you are used to putting in a format string when desensitized with the \ character. Cleaned up some of the user settings controller subclasses. All of them do not have any global settings variables and were all implementing stubs for the get/set global settings variable. Now there is a default version in UserSettingsController that will do nothing. llvm-svn: 114306
* Fix issues with CreateInstanceName, a virtual function, being calledCaroline Tice2010-09-161-1/+8
| | | | | | in an initializer. llvm-svn: 114107
* Add comments to InstanceSettings constructors explaining why they have Caroline Tice2010-09-091-4/+6
| | | | | | | to be set up the way they are. Comment out code that removes pending settings for live instances (after the settings are copied over). llvm-svn: 113519
* Make sure creating a pending instance doesn't also trigger creating a live ↵Caroline Tice2010-09-081-6/+8
| | | | | | | | | instance; also make sure creating a pending instance uses the specified instance name rather than creating a new one; add brackets to instance names when searching for and removing pending instances. llvm-svn: 113370
* Add a user settings controller to Thread. Then added a step-avoid-regexp ↵Jim Ingham2010-09-081-0/+219
| | | | | | | | setting which controls whether to stop in a function matching the regexp. llvm-svn: 113335
* Cleaned up step logging a bit.Greg Clayton2010-09-031-9/+10
| | | | llvm-svn: 113023
* Fixed the StackFrame to correctly resolve the StackID's SymbolContextScope.Greg Clayton2010-09-031-5/+21
| | | | | | | | | Added extra logging for stepping. Fixed an issue where cached stack frame data could be lost between runs when the thread plans read a stack frame. llvm-svn: 112973
OpenPOWER on IntegriCloud