aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectThread.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-09-19Fix more functions in Args to use StringRef.Zachary Turner1-4/+9
This patch also marks the const char* versions as =delete to prevent their use. This has the potential to cause build breakages on some platforms which I can't compile. I have tested on Windows, Linux, and OSX. Best practices for fixing broken callsites are outlined in Args.h in a comment above the deleted function declarations. Eventually we can remove these =delete declarations, but for now they are important to make sure that all implicit conversions from const char * are manually audited to make sure that they do not invoke a conversion from nullptr. llvm-svn: 281919
2016-09-06*** This commit represents a complete reformatting of the LLDB source codeKate Stone1-1904/+1693
*** 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-26Tables of command options in LLDB benefit from hand-formatting to make itKate Stone1-46/+46
easier to scan a set of options with a relatively large number of positional arguments. This commit standardizes their formatting throughout LLDB and applies surrounding directives to exempt them from being formatted by clang-format. These kinds of exemptions should be rare cases that benefit significantly from alternative formatting. They also imply a long-term obligation to maintain their format since the automated tools will not do so. llvm-svn: 279882
2016-08-11Decoupled Options from CommandInterpreter.Todd Fiala1-50/+60
Options used to store a reference to the CommandInterpreter instance in the base Options class. This made it impossible to parse options independent of a CommandInterpreter. This change removes the reference from the base class. Instead, it modifies the options-parsing-related methods to take an ExecutionContext pointer, which the options may inspect if they need to do so. Closes https://reviews.llvm.org/D23416 Reviewers: clayborg, jingham llvm-svn: 278440
2016-07-14LLDB help content has accumulated over time without a recent attempt toKate Stone1-142/+98
review it for consistency, accuracy, and clarity. These changes attempt to address all of the above while keeping the text relatively terse. <rdar://problem/24868841> llvm-svn: 275485
2016-05-19second pass over removal of Mutex and ConditionSaleem Abdulrasool1-3/+3
llvm-svn: 270024
2016-03-17Fix deadlock due to thread list locking in 'bt all' with obj-cStephane Sezer1-38/+72
Summary: The gdb-remote async thread cannot modify thread state while the main thread holds a lock on the state. Don't use locking thread iteration for bt all. Specifically, the deadlock manifests when lldb attempts to JIT code to symbolicate objective c while backtracing. As part of this code path, SetPrivateState() is called on an async thread. This async thread will block waiting for the thread_list lock held by the main thread in CommandObjectIterateOverThreads. The main thread will also block on the async thread during DoResume (although with a timeout), leading to a deadlock. Due to the timeout, the deadlock is not immediately apparent, but the inferior will be left in an invalid state after the bt all completes, and objective-c symbols will not be successfully resolved in the backtrace. Reviewers: andrew.w.kaylor, jingham, clayborg Subscribers: sas, lldb-commits Differential Revision: http://reviews.llvm.org/D18075 Change by Francis Ricci <fjricci@fb.com> llvm-svn: 263735
2016-03-12This change introduces a "ExpressionExecutionThread" to the ThreadList. Jim Ingham1-3/+4
Turns out that most of the code that runs expressions (e.g. the ObjC runtime grubber) on behalf of the expression parser was using the currently selected thread. But sometimes, e.g. when we are evaluating breakpoint conditions/commands, we don't select the thread we're running on, we instead set the context for the interpreter, and explicitly pass that to other callers. That wasn't getting communicated to these utility expressions, so they would run on some other thread instead, and that could cause a variety of subtle and hard to reproduce problems. I also went through the commands and cleaned up the use of GetSelectedThread. All those uses should have been trying the thread in the m_exe_ctx belonging to the command object first. It would actually have been pretty hard to get misbehavior in these cases, but for correctness sake it is good to make this usage consistent. <rdar://problem/24978569> llvm-svn: 263326
2016-02-26Add the "block" keyword to "thread step-in -e", and an alias that uses it: ↵Jim Ingham1-1/+34
"sif <target function>" - i.e. step-into-function to allow you to step through a complex calling sequence into a particular function that may span multiple lines. Also some test cases for this and the --step-target feature. llvm-svn: 261953
2016-02-25Fix Clang-tidy modernize-use-nullptr and modernize-use-default warnings in ↵Eugene Zelenko1-305/+194
source/Commands/CommandObjectThread.cpp; other minor fixes. llvm-svn: 261936
2016-02-13Adding an SBThread::StepInto that takes an end-line, also moved the code ↵Jim Ingham1-60/+15
that figures out the address range for the step to SymbolContext. llvm-svn: 260772
2016-02-10This is an idea to make "thread step-in --target" work for the commonJim Ingham1-2/+85
case where you have: 1 -> foo (bar(), 2 baz(), 3 lala()); 4 You are sitting on line 1, and want to step into foo, but not bar, baz & lala. Unfortunately there are line table entries for lines 1-3, and lldb doesn't know anything about the nesting of statement in these lines. So we'll have to use the user's intelligence... This patch adds: (lldb) thread step-in -t foo --end-line 4 That tells lldb to keep stepping in till line 4, but stop if you step into foo. I think I would remember to use this when faced with some of the long gnarly call sequences in lldb. But there might be ways I haven't thought of to make it more convenient. Jason suggests having "end" as a special token for --end-line which just means keep going to the end of the function, I really want to get into this thing... There should be an SB API and tests, which will come if this seems useful. llvm-svn: 260352
2016-02-06Fix "thread backtrace -s": option was misparsed because of a missing break.Jim Ingham1-0/+1
<rdar://problem/24525106> llvm-svn: 259962
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-10-07commands: Use override instead of virtual.Bruce Mitchener1-99/+79
Summary: This removes all uses of virtual on functions where override could be used, including on destructors. It also adds override where virtual was previously missing. Reviewers: clayborg, labath Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D13503 llvm-svn: 249564
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-05-27Improve LLDB prompt handlingPavel Labath1-1/+3
Summary: There is an issue in lldb where the command prompt can appear at the wrong time. The partial fix we have in for this is not working all the time and is introducing unnecessary delays. This change does: - Change Process:SyncIOHandler to use integer start id's for synchronization to avoid it being confused by quick start-stop cycles. I picked this up from a suggested patch by Greg to lldb-dev. - coordinates printing of asynchronous text with the iohandlers. This is also based on a (different) Greg's patch, but I have added stronger synchronization to it to avoid races. Together, these changes solve the prompt problem for me on linux (both with and without libedit). I think they should behave similarly on Mac and FreeBSD and I think they will not make matters worse for windows. Test Plan: Prompt comes out alright. All tests still pass on linux. Reviewers: clayborg, emaste, zturner Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D9823 llvm-svn: 238313
2015-05-27Add support for custom commands to set flags on themselvesEnrico Granata1-48/+48
This works for Python commands defined via a class (implement get_flags on your class) and C++ plugin commands (which can call SBCommand::GetFlags()/SetFlags()) Flags allow features such as not letting the command run if there's no target, or if the process is not stopped, ... Commands could always check for these things themselves, but having these accessible via flags makes custom commands more consistent with built-in ones llvm-svn: 238286
2015-05-13Remote Non-Stop SupportEwan Crawford1-0/+6
Summary: This patch is the beginnings of support for Non-stop mode in the remote protocol. Letting a user examine stopped threads, while other threads execute freely. Non-stop mode is enabled using the setting target.non-stop-mode, which sends a QNonStop packet when establishing the remote connection. Changes are also made to treat the '?' stop reply packet differently in non-stop mode, according to spec https://sourceware.org/gdb/current/onlinedocs/gdb/Remote-Non_002dStop.html#Remote-Non_002dStop. A setting for querying the remote for default thread on setup is also included. Handling of '%' async notification packets will be added next. Reviewers: clayborg Subscribers: lldb-commits, ADodds, ted, deepak2427 Differential Revision: http://reviews.llvm.org/D9656 llvm-svn: 237239
2015-03-26Add an assertion for frame[0] being valid in CommandObjectThread.cpp.Stephane Sezer1-1/+2
Summary: This should always be true but sometimes is not, during platform bring up. As recommended by Jim Ingham, an assertion should be enough here to help. This addresses post commit comments in http://reviews.llvm.org/D8554. Test Plan: Run unit tests. Reviewers: jasonmolenda, emaste, jingham, clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D8574 llvm-svn: 233298
2015-03-23Add a missing null pointer check in CommandObjectThread.cpp.Stephane Sezer1-1/+1
Reviewers: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D8554 llvm-svn: 232979
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-02-06Add a "-a/--address" option to "thread until". You can specify one or more ↵Jim Ingham1-27/+61
line numbers (as arguments) and/or one or more addresses (with -a) and until will stop at the first one of thesepoints it hits, or on exit from the function if you leave the function before hitting any of these stop points. <rdar://problem/12438270> llvm-svn: 228370
2015-01-15Moved Args::StringToXIntYZ to StringConvert::ToXIntYZVince Harron1-13/+14
The refactor was motivated by some comments that Greg made http://reviews.llvm.org/D6918 and also to break a dependency cascade that caused functions linking in string->int conversion functions to pull in most of lldb llvm-svn: 226199
2015-01-09Change int32_t to uint32_t to fix warnings.Zachary Turner1-1/+1
Variable was being declared as signed, but treated as unsigned at every point of use. Patch by Dan Sinclair Differential Revision: http://reviews.llvm.org/D6897 llvm-svn: 225540
2014-10-21Make the "synchronous" mode actually work without race conditions.Greg Clayton1-16/+36
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-5/+12
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-199/+398
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-08-12Fix iohandler prompt race condition.Todd Fiala1-1/+5
This issue caused the lldb prompt to not show up in certain cases, very noticeable on Linux systems. See details on this review: http://reviews.llvm.org/D4863 And on this lldb-commits thread: http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140811/012306.html Change by Shawn Best. (Much useful help and testing by the rest of the community, thanks all!) llvm-svn: 215446
2014-07-16Fix some warnings in the Windows build.Zachary Turner1-1/+1
llvm-svn: 213194
2014-07-09Revert "Fix broken tests due to new error output."Zachary Turner1-25/+25
This reverts commit ec7c94f8e6860968d384b578e5564a9c55c80b4a and re-enables OptionValidators. llvm-svn: 212627
2014-07-08Add the ability to provide a "count" option to the various "thread step-*" ↵Jim Ingham1-0/+19
operations. Only step-inst and step-inst are currently supported, the rest just warn that they are not supported if you try to provide a count. llvm-svn: 212559
2014-07-08Fix broken tests due to new error output.Todd Fiala1-24/+24
This reverses out the options validators changes. We'll get these back in once the changes to the output can be resolved. Restores broken tests on FreeBSD, Linux, MacOSX. Changes reverted: r212500, r212317, r212290. llvm-svn: 212543
2014-07-03Adds the notion of an OptionValidator.Zachary Turner1-24/+24
The purpose of the OptionValidator is to determine, based on some arbitrary set of conditions, whether or not a command option is valid for a given debugger state. An example of this might be to selectively disable or enable certain command options that don't apply to a particular platform. This patch contains no functional change, and does not actually make use of an OptionValidator for any purpose yet. A follow-up patch will begin to add the logic and users of OptionValidator. Reviewed by: Greg Clayton, Jim Ingham Differential Revision: http://reviews.llvm.org/D4369 llvm-svn: 212290
2014-06-13Initial merge of some of the iOS 8 / Mac OS X Yosemite specificJason Molenda1-0/+188
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-05Rename eExecution*** to eExpression*** to be consistent with the result type.Jim Ingham1-2/+2
llvm-svn: 207945
2014-05-05Make the Expression Execution result enum available to the SB API layer.Jim Ingham1-1/+1
Add a callback that will allow an expression to be cancelled between the expression evaluation stages (for the ClangUserExpressions.) <rdar://problem/16790467>, <rdar://problem/16573440> llvm-svn: 207944
2014-04-03Make the fail messagesJim Ingham1-3/+5
llvm-svn: 205497
2014-03-13This commit reworks how the thread plan's ShouldStopHere mechanism works, so ↵Jim Ingham1-7/+31
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
2013-11-12Change SBThread::GetExtendedBacktrace toJason Molenda1-1/+1
SBThread::GetExtendedBacktraceThread to make it more clear what is being returned. llvm-svn: 194531
2013-11-12Add initial --extended / -e support to thread backtrace.Jason Molenda1-0/+49
llvm-svn: 194455
2013-11-06Added Iterable, a class that vends standard C++Sean Callanan1-8/+7
iterators for LLDB's container data structures. Iterable abstracts over the backing data structure, ignoring keys for maps for example. It also provides locking as a service so that the code for (ThreadSP thread_sp : process->Threads()) { // ... use thread_sp } takes the appropriate locks once, without having to do anything else. The salient advantages of this system are: - Much simpler and idiomatic loop code - Lock once instead of each time an element is fetched - Less boilerplate to produce the iterators The intent is that Iterable will replace Get...AtIndex in most places, and that ForEach(), which solves the same problem in a less-idiomatic way, be phased out in favor of this approach. I've added Iterables to ThreadList, TypeList, and Process (which is really just forwarding to ThreadList). llvm-svn: 194159
2013-11-04Roll back the changes I made in r193907 which created a new FrameJason Molenda1-5/+5
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-5/+5
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-09-12Fixing a problem where CommandObjectThreadContinue held the thread list lock ↵Andrew Kaylor1-9/+18
while waiting for the process to stop after a continue. llvm-svn: 190626
2013-09-12Added a 'jump' command, similar to GDBs.Richard Mitton1-0/+203
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-09-05Add OptionParser.hVirgile Bello1-10/+10
llvm-svn: 190063
2013-07-18This commit does two things. One, it converts the return value of the ↵Jim Ingham1-17/+17
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-01-31Add "thread return -x" to unwind the innermost user called expression (if ↵Jim Ingham1-3/+122
you happen to have stopped in it due to a crash.) Make the message when you hit an crash while evaluating an expression a little clearer, and mention "thread return -x". rdar://problem/13110464 llvm-svn: 174095
2013-01-25<rdar://problem/13069948>Greg Clayton1-2/+2
Major fixed to allow reading files that are over 4GB. The main problems were that the DataExtractor was using 32 bit offsets as a data cursor, and since we mmap all of our object files we could run into cases where if we had a very large core file that was over 4GB, we were running into the 4GB boundary. So I defined a new "lldb::offset_t" which should be used for all file offsets. After making this change, I enabled warnings for data loss and for enexpected implicit conversions temporarily and found a ton of things that I fixed. Any functions that take an index internally, should use "size_t" for any indexes and also should return "size_t" for any sizes of collections. llvm-svn: 173463