aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/API/SBThread.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-09-06*** This commit represents a complete reformatting of the LLDB source codeKate Stone1-1435/+1152
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
2016-08-06Fix Windows build - add return statement in ↵Oleksiy Vyalov1-1/+1
SBThread::StepUsingScriptedThreadPlan. llvm-svn: 277895
2016-08-05Add a few more needed bits to the scripted thread plans.Jim Ingham1-4/+21
llvm-svn: 277879
2016-07-08Add an API to unwind from a hand-called expression.Jim Ingham1-0/+25
This is just an SB API way of doing "thread return -x". <rdar://problem/27110360> llvm-svn: 274822
2016-06-10SBThread also had some places where it got the ExecutionContext w/o Jim Ingham1-9/+27
taking the API lock. llvm-svn: 272407
2016-05-19second pass over removal of Mutex and ConditionSaleem Abdulrasool1-57/+52
llvm-svn: 270024
2016-05-07Take the API lock in SBThread::IsValid & SBFrame::IsValid.Jim Ingham1-1/+13
The IsValid calls can try to reconstruct the thread & frame, which can take various internal locks. This can cause A/B locking issues with the Target lock, so these calls need to that the Target lock. llvm-svn: 268828
2016-04-10Provide more information in ThreadSanitizer's JSON data. Move remaining ↵Kuba Brecka1-40/+3
TSan logic from SBThread to InstrumentationRuntime plugin. llvm-svn: 265905
2016-03-30Fix the ThreadSanitizer support to avoid creating empty SBThreads and to not ↵Kuba Brecka1-1/+5
crash when thread_id is unavailable. Plus a whitespace fix. llvm-svn: 264854
2016-03-23Add ThreadSanitizer debugging support.Kuba Brecka1-1/+58
This patch adds ThreadSanitizer support into LLDB: - Adding a new InstrumentationRuntime plugin, ThreadSanitizerRuntime, in the same way ASan is implemented. - A breakpoint stops in `__tsan_on_report`, then we extract all sorts of information by evaluating an expression. We then populate this into StopReasonExtendedInfo. - SBThread gets a new API, SBThread::GetStopReasonExtendedBacktraces(), which returns TSan’s backtraces in the form of regular SBThreads. Non-TSan stop reasons return an empty collection. - Added some test cases. Reviewed by Greg Clayton. llvm-svn: 264162
2016-02-13Adding an SBThread::StepInto that takes an end-line, also moved the code ↵Jim Ingham1-4/+19
that figures out the address range for the step to SymbolContext. llvm-svn: 260772
2015-12-15When constructing an address range to "step" or "next" through,Jason Molenda1-2/+2
find the largest address range (possibly combining multiple LineEntry's for this line number) that is contiguous. This allows lldb's fast-step stepping algorithm to potentially run for a longer address range than if we have to stop at every LineEntry indicating a subexpression in the source line. http://reviews.llvm.org/D15407 <rdar://problem/23270882> llvm-svn: 255590
2015-09-09Fix log message warning in SBThread.Bruce Mitchener1-1/+1
Summary: The format string was not set up correctly as it was missing the %. This resulted in a warning (correctly) that the data arguments were not all used. Reviewers: clayborg, jingham Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D12714 llvm-svn: 247111
2015-09-08SBThread::StepOutOfFrame should check that the SBStackFrame it gets passedJim Ingham1-1/+15
is valid, and that its thread is the same as this SBThread. llvm-svn: 247046
2015-07-14Refactor Unix signals.Chaoren Lin1-1/+1
Summary: - Consolidate Unix signals selection in UnixSignals. - Make Unix signals available from platform. - Add jSignalsInfo packet to retrieve Unix signals from remote platform. - Get a copy of the platform signal for each remote process. - Update SB API for signals. - Update signal utility in test suite. Reviewers: ovyalov, clayborg Subscribers: chaoren, jingham, labath, emaste, tberghammer, lldb-commits Differential Revision: http://reviews.llvm.org/D11094 llvm-svn: 242101
2015-06-25Resubmitting 240466 after fixing the linux test suite failures.Greg Clayton1-2/+2
A few extras were fixed - Symbol::GetAddress() now returns an Address object, not a reference. There were places where people were accessing the address of a symbol when the symbol's value wasn't an address symbol. On MacOSX, undefined symbols have a value zero and some places where using the symbol's address and getting an absolute address of zero (since an Address object with no section and an m_offset whose value isn't LLDB_INVALID_ADDRESS is considered an absolute address). So fixing this required some changes to make sure people were getting what they expected. - Since some places want to access the address as a reference, I added a few new functions to symbol: Address &Symbol::GetAddressRef(); const Address &Symbol::GetAddressRef() const; Linux test suite passes just fine now. <rdar://problem/21494354> llvm-svn: 240702
2015-06-23Revert "Reduced packet counts to the remote GDB server where possible."Chaoren Lin1-2/+2
This reverts commit 0cc0745ea9c68d7fdcadc9904cee3f13c96dae60. Due to breakage on Linux build bot: http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/3436 llvm-svn: 240371
2015-06-22Reduced packet counts to the remote GDB server where possible.Greg Clayton1-2/+2
We have been working on reducing the packet count that is sent between LLDB and the debugserver on MacOSX and iOS. Our approach to this was to reduce the packets required when debugging multiple threads. We currently make one qThreadStopInfoXXXX call (where XXXX is the thread ID in hex) per thread except the thread that stopped with a stop reply packet. In order to implement multiple thread infos in a single reply, we need to use structured data, which means JSON. The new jThreadsInfo packet will attempt to retrieve all thread infos in a single packet. The data is very similar to the stop reply packets, but packaged in JSON and uses JSON arrays where applicable. The JSON output looks like: [ { "tid":1580681, "metype":6, "medata":[2,0], "reason":"exception", "qaddr":140735118423168, "registers": { "0":"8000000000000000", "1":"0000000000000000", "2":"20fabf5fff7f0000", "3":"e8f8bf5fff7f0000", "4":"0100000000000000", "5":"d8f8bf5fff7f0000", "6":"b0f8bf5fff7f0000", "7":"20f4bf5fff7f0000", "8":"8000000000000000", "9":"61a8db78a61500db", "10":"3200000000000000", "11":"4602000000000000", "12":"0000000000000000", "13":"0000000000000000", "14":"0000000000000000", "15":"0000000000000000", "16":"960b000001000000", "17":"0202000000000000", "18":"2b00000000000000", "19":"0000000000000000", "20":"0000000000000000"}, "memory":[ {"address":140734799804592,"bytes":"c8f8bf5fff7f0000c9a59e8cff7f0000"}, {"address":140734799804616,"bytes":"00000000000000000100000000000000"} ] } ] It contains an array of dicitionaries with all of the key value pairs that are normally in the stop reply packet. Including the expedited registers. Notice that is also contains expedited memory in the "memory" key. Any values in this memory will get included in a new L1 cache in lldb_private::Process where if a memory read request is made and that memory request fits into one of the L1 memory cache blocks, it will use that memory data. If a memory request fails in the L1 cache, it will fall back to the L2 cache which is the same block sized caching we were using before these changes. This allows a process to expedite memory that you are likely to use and it reduces packet count. On MacOSX with debugserver, we expedite the frame pointer backchain for a thread (up to 256 entries) by reading 2 pointers worth of bytes at the frame pointer (for the previous FP and PC), and follow the backchain. Most backtraces on MacOSX and iOS now don't require us to read any memory! We will try these packets out and if successful, we should port these to lldb-server in the near future. <rdar://problem/21494354> llvm-svn: 240354
2015-05-29Don't #include "lldb-python.h" from anywhere.Zachary Turner1-2/+0
Since interaction with the python interpreter is moving towards being more isolated, we won't be able to include this header from normal files anymore, all includes of it should be localized to the python library which will live under source/bindings/API/Python after a future patch. None of the files that were including this header actually depended on it anyway, so it was just a dead include in every single instance. llvm-svn: 238581
2015-03-03Don't #include FormatManager.h from Debugger.hZachary Turner1-0/+1
Debugger.h is a huge file that gets included everywhere, and FormatManager.h brings in a ton of unnecessary stuff and doesn't even use anything from it in the header. llvm-svn: 231161
2015-03-03Further reduce the header footprint of Process.hZachary Turner1-2/+3
No functional change here, only deletes unnecessary headers and moves one function's body from the .h file to the .cpp. llvm-svn: 231145
2015-01-28SBThread::GetDescription should use the Thread format instead of making upJim Ingham1-1/+2
some format of its own. llvm-svn: 227285
2014-10-21Make the "synchronous" mode actually work without race conditions.Greg Clayton1-9/+5
There were many issues with synchronous mode that we discovered when started to try and add a "batch" mode. There was a race condition where the event handling thread might consume events when in sync mode and other times the Process::WaitForProcessToStop() would consume them. This also led to places where the Process IO handler might or might not get popped when it needed to be. llvm-svn: 220254
2014-10-10LLDB AddressSanitizer instrumentation runtime plugin, breakpint on error and ↵Kuba Brecka1-0/+22
report data extraction Reviewed at http://reviews.llvm.org/D5592 This patch gives LLDB some ability to interact with AddressSanitizer runtime library, on top of what we already have (historical memory stack traces provided by ASan). Namely, that's the ability to stop on an error caught by ASan, and access the report information that are associated with it. The report information is also exposed into SB API. More precisely this patch... adds a new plugin type, InstrumentationRuntime, which should serve as a generic superclass for other instrumentation runtime libraries, these plugins get notified when modules are loaded, so they get a chance to "activate" when a specific dynamic library is loaded an instance of this plugin type, AddressSanitizerRuntime, which activates itself when it sees the ASan dynamic library or founds ASan statically linked in the executable adds a collection of these plugins into the Process class AddressSanitizerRuntime sets an internal breakpoint on __asan::AsanDie(), and when this breakpoint gets hit, it retrieves the report information from ASan this breakpoint is then exposed as a new StopReason, eStopReasonInstrumentation, with a new StopInfo subclass, InstrumentationRuntimeStopInfo the StopInfo superclass is extended with a m_extended_info field (it's a StructuredData::ObjectSP), that can hold arbitrary JSON-like data, which is the way the new plugin provides the report data the "thread info" command now accepts a "-s" flag that prints out the JSON data of a stop reason (same way the "-j" flag works now) SBThread has a new API, GetStopReasonExtendedInfoAsJSON, which dumps the JSON string into a SBStream adds a test case for all of this I plan to also get rid of the original ASan plugin (memory history stack traces) and use an instance of AddressSanitizerRuntime for that purpose. Kuba llvm-svn: 219546
2014-09-29This checkin is the first step in making the lldb thread stepping mechanism ↵Jim Ingham1-2/+67
more accessible from the user level. It adds the ability to invent new stepping modes implemented by python classes, and to view the current thread plan stack and to some extent alter it. I haven't gotten to documentation or tests yet. But this should not cause any behavior changes if you don't use it, so its safe to check it in now and work on it incrementally. llvm-svn: 218642
2014-06-13Initial merge of some of the iOS 8 / Mac OS X Yosemite specificJason Molenda1-0/+69
lldb support. I'll be doing more testing & cleanup but I wanted to get the initial checkin done. This adds a new SBExpressionOptions::SetLanguage API for selecting a language of an expression. I added adds a new SBThread::GetInfoItemByPathString for retriving information about a thread from that thread's StructuredData. I added a new StructuredData class for representing key-value/array/dictionary information (e.g. JSON formatted data). Helper functions to read JSON and create a StructuredData object, and to print a StructuredData object in JSON format are included. A few Cocoa / Cocoa Touch data formatters were updated by Enrico to track changes in iOS 8 / Yosemite. Before we query a thread's extended information, the system runtime may provide hints to the remote debug stub that it will use to retrieve values out of runtime structures. I added a new SystemRuntime method AddThreadExtendedInfoPacketHints which allows the SystemRuntime to add key-value type data to the initial request that we send to the remote stub. The thread-format formatter string can now retrieve values out of a thread's extended info structured data. The default thread-format string picks up two of these - thread.info.activity.name and thread.info.trace_messages. I added a new "jThreadExtendedInfo" packet in debugserver; I will add documentation to the lldb-gdb-remote.txt doc soon. It accepts JSON formatted arguments (most importantly, "thread":threadnum) and it returns a variety of information regarding the thread to lldb in JSON format. This JSON return is scanned into a StructuredData object that is associated with the thread; UI layers can query the thread's StructuredData to see if key-values are present, and if so, show them to the user. These key-values are likely to be specific to different targets with some commonality among many targets. For instance, many targets will be able to advertise the pthread_t value for a thread. I added an initial rough cut of "thread info" command which will print the information about a thread from the jThreadExtendedInfo result. I need to do more work to make this format reasonably. Han Ming added calls into the pmenergy and pmsample libraries if debugserver is run on Mac OS X Yosemite to get information about the inferior's power use. I added support to debugserver for gathering the Genealogy information about threads, if it exists, and returning it in the jThreadExtendedInfo JSON result. llvm-svn: 210874
2014-05-13Add a new SBThread::SafeToCallFunctions API; this calls over toJason Molenda1-0/+9
the SystemRuntime to check if a thread will have any problems performing an inferior function call so the driver can skip making that function call on that thread. Often the function call can be executed on another thread instead. <rdar://problem/16777874> llvm-svn: 208732
2014-04-25Add a new SBThread::GetQueue() method to get the queue that is Jason Molenda1-0/+37
currently associated with a given thread, on relevant targets. Change the queue detection code to verify that the queues associated with all live threads are included in the list. <rdar://problem/16411314> llvm-svn: 207160
2014-04-11Fixed SBThread.GetStopReasonDataAtIndex() to correctly return breakpoint ↵Greg Clayton1-1/+1
location ID. Patch from Vyacheslav Karpukhin. llvm-svn: 206040
2014-04-04sweep up -Wformat warnings from gccSaleem Abdulrasool1-99/+147
This is a purely mechanical change explicitly casting any parameters for printf style conversion. This cleans up the warnings emitted by gcc 4.8 on Linux. llvm-svn: 205607
2014-04-03Make the fail messagesJim Ingham1-1/+2
llvm-svn: 205497
2014-03-13This commit reworks how the thread plan's ShouldStopHere mechanism works, so ↵Jim Ingham1-4/+10
that it is useful not only for customizing "step-in" behavior (e.g. step-in doesn't step into code with no debug info), but also the behavior of step-in/step-out and step-over when they step out of the frame they started in. I also added as a proof of concept of this reworking a mode for stepping where stepping out of a frame into a frame with no debug information will continue stepping out till it arrives at a frame that does have debug information. This is useful when you are debugging callback based code where the callbacks are separated from the code that initiated them by some library glue you don't care about, among other things. llvm-svn: 203747
2014-03-08Add API logging to the SBQueue/SBQueueItem/SBThread calls.Jason Molenda1-0/+4
llvm-svn: 203330
2013-11-19Add logging for the SB API which creates extendedJason Molenda1-5/+15
threads. Take a stab at fixing the too-soon freeing of the extended backtrace thread list in Process. <rdar://problem/15496603> llvm-svn: 195104
2013-11-16Add a new SBThread::GetExtendedBacktraceOriginatingIndexID() methodJason Molenda1-0/+9
(and same thing to Thread base class) which can be used when looking at an ExtendedBacktrace thread; it will try to find the IndexID() of the original thread that was executing this backtrace when it was recorded. If lldb can't find a record of that thread, it will return the same value as IndexID() for the ExtendedBacktrace thread. llvm-svn: 194912
2013-11-12Change SBThread::GetExtendedBacktrace toJason Molenda1-3/+2
SBThread::GetExtendedBacktraceThread to make it more clear what is being returned. llvm-svn: 194531
2013-11-11The Threads created when requesting extended backtraces need to be owned byJason Molenda1-6/+12
something; add a new ExtendedThreadList to Process where they can be retained for the duration of a public stop. <rdar://problem/15314068> llvm-svn: 194366
2013-11-08Add History subclasses for Thread, Unwind, RegisterContext.Jason Molenda1-1/+2
Still working out some of the details of these classes but I wanted to get the overall structure checked in. <rdar://problem/15314068> llvm-svn: 194245
2013-11-06Rename extended backtrace methods to take out the "ThreadOrigin"Jason Molenda1-3/+3
bit from the method names. <rdar://problem/15314369> llvm-svn: 194122
2013-11-06Add a new GetThreadOriginExtendedBacktrace method to the Jason Molenda1-0/+36
SystemRuntime and SBThread classes. <rdar://problem/15314369> llvm-svn: 194111
2013-11-04Roll back the changes I made in r193907 which created a new FrameJason Molenda1-7/+7
pure virtual base class and made StackFrame a subclass of that. As I started to build on top of that arrangement today, I found that it wasn't working out like I intended. Instead I'll try sticking with the single StackFrame class -- there's too much code duplication to make a more complicated class hierarchy sensible I think. llvm-svn: 193983
2013-11-02Add a new base class, Frame. It is a pure virtual function whichJason Molenda1-7/+7
defines a protocol that all subclasses will implement. StackFrame is currently the only subclass and the methods that Frame vends are nearly identical to StackFrame's old methods. Update all callers to use Frame*/Frame& instead of pointers to StackFrames. This is almost entirely a mechanical change that touches a lot of the code base so I'm committing it alone. No new functionality is added with this patch, no new subclasses of Frame exist yet. I'll probably need to tweak some of the separation, possibly moving some of StackFrame's methods up in to Frame, but this is a good starting point. <rdar://problem/15314068> llvm-svn: 193907
2013-10-21Expose the Thread::GetQueueID() method through the SBThread API, similar toJason Molenda1-0/+28
the existing SBThread::GetQueueName() method. llvm-svn: 193132
2013-09-12Added a 'jump' command, similar to GDBs.Richard Mitton1-0/+25
This allows the PC to be directly changed to a different line. It's similar to the example python script in examples/python/jump.py, except implemented as a builtin. Also this version will track the current function correctly even if the target line resolves to multiple addresses. (e.g. debugging a templated function) llvm-svn: 190572
2013-07-18This commit does two things. One, it converts the return value of the ↵Jim Ingham1-21/+21
QueueThreadPlanXXX plan providers from a "ThreadPlan *" to a "lldb::ThreadPlanSP". That was needed to fix a bug where the ThreadPlanStepInRange wasn't checking with its sub-plans to make sure they succeed before trying to proceed further. If the sub-plan failed and as a result didn't make any progress, you could end up retrying the same failing algorithm in an infinite loop. <rdar://problem/14043602> llvm-svn: 186618
2013-04-15Adding new Python API function to check for stopped threads.Andrew Kaylor1-0/+10
llvm-svn: 179577
2013-03-27<rdar://problem/13521159>Greg Clayton1-23/+23
LLDB is crashing when logging is enabled from lldb-perf-clang. This has to do with the global destructor chain as the process and its threads are being torn down. All logging channels now make one and only one instance that is kept in a global pointer which is never freed. This guarantees that logging can correctly continue as the process tears itself down. llvm-svn: 178191
2013-02-28the log entry for SBThread::GetProcess() would not include the pointer to ↵Enrico Granata1-3/+1
the process because we were using the value of the (otherwise unused) process_sp - instead of fetching the SP from sb_process llvm-svn: 176231
2012-12-20Adding eStopReasonThreadExiting and fixing the handling of this state on Linux.Andrew Kaylor1-0/+9
llvm-svn: 170800
2012-12-12Fixed a few bugs in the "step in" thread plan logic.Jim Ingham1-14/+20
Added a "step-in-target" flag to "thread step-in" so if you have something like: Process 28464 stopped * thread #1: tid = 0x1c03, function: main , stop reason = breakpoint 1.1 frame #0: 0x0000000100000e08 a.out`main at main.c:62 61 -> 62 int A6 = complex (a(4), b(5), c(6)); // Stop here to step targetting b and hitting breakpoint. 63 and you want to get into "complex" skipping a, b and c, you can do: (lldb) step -t complex Process 28464 stopped * thread #1: tid = 0x1c03, function: complex , stop reason = step in frame #0: 0x0000000100000d0d a.out`complex at main.c:44 41 42 int complex (int first, int second, int third) 43 { -> 44 return first + second + third; // Step in targetting complex should stop here 45 } 46 47 int main (int argc, char const *argv[]) llvm-svn: 170008