summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/ThreadList.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Logging] Replace Log::Printf with LLDB_LOG macro (NFC)Jonas Devlieghere2019-07-241-28/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces explicit calls to log::Printf with the new LLDB_LOGF macro. The macro is similar to LLDB_LOG but supports printf-style format strings, instead of formatv-style format strings. So instead of writing: if (log) log->Printf("%s\n", str); You'd write: LLDB_LOG(log, "%s\n", str); This change was done mechanically with the command below. I replaced the spurious if-checks with vim, since I know how to do multi-line replacements with it. find . -type f -name '*.cpp' -exec \ sed -i '' -E 's/log->Printf\(/LLDB_LOGF\(log, /g' "{}" + Differential revision: https://reviews.llvm.org/D65128 llvm-svn: 366936
* Use the multi-lockable form of std::lock for operator=Jim Ingham2019-03-291-2/+4
| | | | | | | | | | | For = operators for lists that have mutexes, we were either just taking the locks sequentially or hand-rolling a trick to try to avoid lock inversion. Use the std::lock mechanism for this instead. Differential Revision: https://reviews.llvm.org/D59957 llvm-svn: 357276
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Remove header grouping comments.Jonas Devlieghere2018-11-111-4/+0
| | | | | | | | This patch removes the comments grouping header includes. They were added after running IWYU over the LLDB codebase. However they add little value, are often outdates and burdensome to maintain. llvm-svn: 346626
* Move RegisterValue,Scalar,State from Core to UtilityPavel Labath2018-08-071-1/+1
| | | | | | | | | | | | | These three classes have no external dependencies, but they are used from various low-level APIs. Moving them down to Utility improves overall code layering (although it still does not break any particular dependency completely). The XCode project will need to be updated after this change. Differential Revision: https://reviews.llvm.org/D49740 llvm-svn: 339127
* Reflow paragraphs in comments.Adrian Prantl2018-04-301-82/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is intended as a clean up after the big clang-format commit (r280751), which unfortunately resulted in many of the comment paragraphs in LLDB being very hard to read. FYI, the script I used was: import textwrap import commands import os import sys import re tmp = "%s.tmp"%sys.argv[1] out = open(tmp, "w+") with open(sys.argv[1], "r") as f: header = "" text = "" comment = re.compile(r'^( *//) ([^ ].*)$') special = re.compile(r'^((([A-Z]+[: ])|([0-9]+ )).*)|(.*;)$') for line in f: match = comment.match(line) if match and not special.match(match.group(2)): # skip intentionally short comments. if not text and len(match.group(2)) < 40: out.write(line) continue if text: text += " " + match.group(2) else: header = match.group(1) text = match.group(2) continue if text: filled = textwrap.wrap(text, width=(78-len(header)), break_long_words=False) for l in filled: out.write(header+" "+l+'\n') text = "" out.write(line) os.rename(tmp, sys.argv[1]) Differential Revision: https://reviews.llvm.org/D46144 llvm-svn: 331197
* Re-land "Don't assume backing thread shares protocol ID."Jonas Devlieghere2018-04-131-0/+14
| | | | | | | | | | | | | | | | | | When we're dealing with virtual (memory) threads created by the OS plugins, there's no guarantee that the real thread and the backing thread share a protocol ID. Instead, we should iterate over the memory threads to find the virtual thread that is backed by the current real thread. Differential revision: https://reviews.llvm.org/D45497 rdar://36485830 The original revision (r329891) was reverted because the associated tests ran into a deadlock on the Linux bots. That problem was resolved by r330002. llvm-svn: 330005
* Revert "Don't assume backing thread shares protocol ID."Jonas Devlieghere2018-04-121-14/+0
| | | | | | | This reverts r329891 because the test case is timing out on linux: http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/21834 llvm-svn: 329897
* Don't assume backing thread shares protocol ID.Jonas Devlieghere2018-04-121-0/+14
| | | | | | | | | | | | | | When we're dealing with virtual (memory) threads created by the OS plugins, there's no guarantee that the real thread and the backing thread share a protocol ID. Instead, we should iterate over the memory threads to find the virtual thread that is backed by the current real thread. Differential revision: https://reviews.llvm.org/D45497 rdar://36485830 llvm-svn: 329891
* Move Log from Core -> Utility.Zachary Turner2017-03-031-1/+1
| | | | | | | | | All references to Host and Core have been removed, so this class can now safely be lowered into Utility. Differential Revision: https://reviews.llvm.org/D30559 llvm-svn: 296909
* Break some dependencies in lldbUtility.Zachary Turner2017-02-011-9/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D29359 llvm-svn: 293806
* Fixed a crasher that has been borking out heap for a long time. Greg Clayton2016-12-081-1/+2
| | | | | | | | | | ThreadList had an assignment operator that didn't lock the "rhs" thread list object. This means a thread list can be mutated while it is being copied. The copy constructor calls the assignment operator as well. So this fixes the unsafe threaded access to ThreadList which we believe is responsible for a lot of crashes. <rdar://problem/28075793> llvm-svn: 289100
* *** This commit represents a complete reformatting of the LLDB source codeKate Stone2016-09-061-732/+624
| | | | | | | | | | | | | | | | | | | | | | | *** 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
* second pass over removal of Mutex and ConditionSaleem Abdulrasool2016-05-191-30/+35
| | | | llvm-svn: 270024
* This change introduces a "ExpressionExecutionThread" to the ThreadList. Jim Ingham2016-03-121-0/+37
| | | | | | | | | | | | | | | | | | | 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
* Fix Clang-tidy modernize-use-nullptr and readability-simplify-boolean-expr ↵Eugene Zelenko2015-12-151-0/+5
| | | | | | | | warnings in some files in source/Target/. Simplify smart pointers checks in conditions. Other minor fixes. llvm-svn: 255598
* Change the null check to an assert.Zachary Turner2015-11-131-1/+3
| | | | llvm-svn: 253092
* Add a null check against the ThreadPlanZachary Turner2015-11-131-1/+1
| | | | | | | | I'm seeing some cases where the ThreadPlan is null. It could be a sign of a valid race condition, but at least we shouldn't crash. llvm-svn: 253086
* Fix TestThreadSpecificBreakpoint.py on Linux after rL252355.Chaoren Lin2015-11-071-1/+5
| | | | | | | | | | | | | | | | | Summary: On Linux, if a thread-specific conditional breakpoint was hit, it won't necessarily be the thread that hit the breakpoint itself that evaluates the conditional expression, so the thread that hit the breakpoint could still be asked to stop, even though it hasn't been allowed to run since the previous stop. Reviewers: sivachandra, jingham Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D14472 llvm-svn: 252391
* Another optimization to keep down gdb-remote traffic. If we have suspended ↵Jim Ingham2015-11-061-2/+18
| | | | | | | | a thread while running, don't request the thread status when deciding why we stopped. llvm-svn: 252355
* Add an OperatingSystem plugin to support goroutinesRyan Brown2015-09-161-1/+2
| | | | | | | | | | The Go runtime schedules user level threads (goroutines) across real threads. This adds an OS plugin to create memory threads for goroutines. It supports the 1.4 and 1.5 go runtime. Differential Revision: http://reviews.llvm.org/D5871 llvm-svn: 247852
* Fix typos.Bruce Mitchener2015-07-221-2/+2
| | | | | | | | | | | | Summary: Fix a bunch of typos. Reviewers: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D11386 llvm-svn: 242856
* Fix up some comments to be more explicit. Remove some long-commented out code.Jim Ingham2015-06-021-0/+1
| | | | llvm-svn: 238862
* Enable debugging of multithreaded programs on Windows.Adrian McCarthy2015-05-181-2/+2
| | | | llvm-svn: 237637
* Reverting r237392 since it broke TestNumThreads on ubuntu builder.Oleksiy Vyalov2015-05-151-2/+2
| | | | llvm-svn: 237415
* Enable multithreaded debugging on Windows.Adrian McCarthy2015-05-141-2/+2
| | | | llvm-svn: 237392
* Move some functions from source/lldb.cpp to Utility.Zachary Turner2015-03-181-0/+1
| | | | | | | | | | Specifically, there were some functions for converting enums to strings and a function for matching a string using a specific matching algorithm. This moves those functions to more appropriate headers in lldb/Utility and updates references to include the new headers. llvm-svn: 232673
* [lldb] Abstract a superclass for a generic thread container.Kuba Brecka2014-09-051-21/+2
| | | | | | | | | Reviewed at http://reviews.llvm.org/D5200 and http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140901/012799.html llvm-svn: 217269
* Fix the behavior when hand-calling a function times out on one thread,Jim Ingham2014-04-081-1/+10
| | | | | | | | | | but by the time we go to halt, it has already stopped by hitting the function end breakpoint. That wasn't being shown to the threads so the Function call thread plan didn't know its job was done. <rdar://problem/16515785> llvm-svn: 205803
* Fixed deadlocks that could occur when using python for breakpoints, ↵Greg Clayton2014-02-131-0/+11
| | | | | | | | | operating system plugins, and other async python usage. <rdar://problem/16054348> <rdar://problem/16040833> llvm-svn: 201372
* Correct logic checking for the first stop IDEd Maste2014-01-171-1/+1
| | | | llvm-svn: 199503
* Fix a bug where if we stop but nobody says there was a reason for the stop, ↵Jim Ingham2014-01-151-5/+19
| | | | | | | | | | | | | we would return control to the user anyway. This was put in to handle monitors that would say there was no stop reason when you first attached to them. But it broke the case where you hit a thread specific breakpoint on many threads, but NOT the one specified in the breakpoint. I work around this by only doing the junky override when the StopID is 0 - i.e. on first attach. This commit also adds a test for thread specific breakpoints. llvm-svn: 199290
* Adding support for setting thread stop state when a process stops.Andrew Kaylor2013-05-101-0/+22
| | | | | | This re-submission of this patch fixes a problem where the code sometimes caused a deadlock. The Process::SetPrivateState method was locking the Process::m_private_state variable and then later calling ThreadList::DidStop, which locks the ThreadList mutex. Other methods in ThreadList which were being called from other threads lock the ThreadList mutex and then call Process::GetPrivateState which locks the Process::m_private_state mutex. To avoid deadlocks, Process::SetPrivateState now locks the ThreadList mutex before locking the Process::m_private_state mutex. llvm-svn: 181609
* Revert r181482 as it causes occasional hangs in LLDB buildbotsDaniel Malea2013-05-091-22/+0
| | | | llvm-svn: 181526
* Changed the formerly pure virtual function:Greg Clayton2013-05-091-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | namespace lldb_private { class Thread { virtual lldb::StopInfoSP GetPrivateStopReason() = 0; }; } To not be virtual. The lldb_private::Thread now handles the correct caching and will call a new pure virtual function: namespace lldb_private { class Thread { virtual bool CalculateStopInfo() = 0; } } This function must be overridden by thead lldb_private::Thread subclass and the only thing it needs to do is to set the Thread::StopInfo() with the current stop reason and return true, or return false if there is no stop reason. The lldb_private::Thread class will take care of calling this function only when it is required. This allows lldb_private::Thread subclasses to be a bit simpler and not all need to duplicate the cache and invalidation settings. Also renamed: lldb::StopInfoSP lldb_private::Thread::GetPrivateStopReason(); To: lldb::StopInfoSP lldb_private::Thread::GetPrivateStopInfo(); Also cleaned up a case where the ThreadPlanStepOverBreakpoint might not re-set its breakpoint if the thread disappears (which was happening due to a bug when using the OperatingSystem plug-ins with memory threads and real threads). llvm-svn: 181501
* Adding code to set thread state to stopped when the process stops.Andrew Kaylor2013-05-081-0/+22
| | | | llvm-svn: 181482
* Figure out the reply to "PlanExplainsStop" once when we stop and then use ↵Jim Ingham2013-05-081-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the cached value. This fixes problems, for instance, with the StepRange plans, where they know that they explained the stop because they were at their "run to here" breakpoint, then deleted that breakpoint, so when they got asked again, doh! I had done this for a couple of plans in an ad hoc fashion, this just formalizes it. Also add a "ResumeRequested" in Process so that the code in the completion handlers can tell the ShouldStop logic they want to resume rather than just directly resuming. That allows us to handle resuming in a more controlled fashion. Also, SetPublicState can take a "restarted" flag, so that it doesn't drop the run lock when the target was immediately restarted. --This line, and those below , will be ignored-- M test/lang/objc/objc-dynamic-value/TestObjCDynamicValue.py M include/lldb/Target/ThreadList.h M include/lldb/Target/ThreadPlanStepOut.h M include/lldb/Target/Thread.h M include/lldb/Target/ThreadPlanBase.h M include/lldb/Target/ThreadPlanStepThrough.h M include/lldb/Target/ThreadPlanStepInstruction.h M include/lldb/Target/ThreadPlanStepInRange.h M include/lldb/Target/ThreadPlanStepOverBreakpoint.h M include/lldb/Target/ThreadPlanStepUntil.h M include/lldb/Target/StopInfo.h M include/lldb/Target/Process.h M include/lldb/Target/ThreadPlanRunToAddress.h M include/lldb/Target/ThreadPlan.h M include/lldb/Target/ThreadPlanCallFunction.h M include/lldb/Target/ThreadPlanStepOverRange.h M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h M source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp M source/Target/StopInfo.cpp M source/Target/Process.cpp M source/Target/ThreadPlanRunToAddress.cpp M source/Target/ThreadPlan.cpp M source/Target/ThreadPlanCallFunction.cpp M source/Target/ThreadPlanStepOverRange.cpp M source/Target/ThreadList.cpp M source/Target/ThreadPlanStepOut.cpp M source/Target/Thread.cpp M source/Target/ThreadPlanBase.cpp M source/Target/ThreadPlanStepThrough.cpp M source/Target/ThreadPlanStepInstruction.cpp M source/Target/ThreadPlanStepInRange.cpp M source/Target/ThreadPlanStepOverBreakpoint.cpp M source/Target/ThreadPlanStepUntil.cpp M lldb.xcodeproj/xcshareddata/xcschemes/Run Testsuite.xcscheme llvm-svn: 181381
* Reinstating r181091 and r181106 with fix for Linux regressions.Andrew Kaylor2013-05-071-30/+32
| | | | llvm-svn: 181340
* Temporarily reverting r181091 and r181106 due to the vast test breakage on ↵Ashok Thirumurthi2013-05-071-32/+30
| | | | | | | | | | the Linux buildbots while we develop a better understanding of how to manage the thread lists in a platform-independant fashion. Reviewed by: Daniel Malea llvm-svn: 181323
* After recent OperatingsSystem plug-in changes, the lldb_private::Process and ↵Greg Clayton2013-05-041-30/+32
| | | | | | | | | | lldb_private::Thread subclasses were changed and the API was not respected properly. This checkin aims to fix this. The process now has two thread lists: a real thread list for threads that are created by the lldb_private::Process subclass, and the user visible threads. The user visible threads are the same as the real threas when no OS plug-in in used. But when an OS plug-in is used, the user thread can be a combination of real and "memory" threads. Real threads can be placed inside of memory threads so that a thread appears to be different, but is still controlled by the actual real thread. When the thread list needs updating, the lldb_private::Process class will call the: lldb_private::Process::UpdateThreadList() function with the old real thread list, and the function is expected to fill in the new real thread list with the current state of the process. After this function, the process will check if there is an OS plug-in being used, and if so, it will give the old user thread list, the new real thread list and the OS plug-in will create the new user thread list from both of these lists. If there is no OS plug-in, the real thread list is the user thread list. These changes keep the lldb_private::Process subclasses clean and no changes are required. llvm-svn: 181091
* <rdar://problem/13700260>Greg Clayton2013-05-011-5/+51
| | | | | | | | | | | | | | <rdar://problem/13723772> Modified the lldb_private::Thread to work much better with the OperatingSystem plug-ins. Operating system plug-ins can now return have a "core" key/value pair in each thread dictionary for the OperatingSystemPython plug-ins which allows the core threads to be contained with memory threads. It also allows these memory threads to be stepped, resumed, and controlled just as if they were the actual backing threads themselves. A few things are introduced: - lldb_private::Thread now has a GetProtocolID() method which returns the thread protocol ID for a given thread. The protocol ID (Thread::GetProtocolID()) is usually the same as the thread id (Thread::GetID()), but it can differ when a memory thread has its own id, but is backed by an actual API thread. - Cleaned up the Thread::WillResume() code to do the mandatory parts in Thread::ShouldResume(), and let the thread subclasses override the Thread::WillResume() which is now just a notification. - Cleaned up ClearStackFrames() implementations so that fewer thread subclasses needed to override them - Changed the POSIXThread class a bit since it overrode Thread::WillResume(). It is doing the wrong thing by calling "Thread::SetResumeState()" on its own, this shouldn't be done by thread subclasses, but the current code might rely on it so I left it in with a TODO comment with an explanation. llvm-svn: 180886
* Make sure all the threads get a chance to compute their StopInfo's before we ↵Jim Ingham2013-04-161-1/+12
| | | | | | | | | | | start running ShouldStop on the threads, which might destroy information needed to correctly compute another thread's StopInfo. <rdar://problem/13664026> llvm-svn: 179641
* <rdar://problem/13527167>Greg Clayton2013-03-281-0/+4
| | | | | | | | Partial fix for the above radar. Call ThreadList::Clear() in the ThreadList destructor so if any other threads currently have the thread list mutex, we won't destroy the list for them while they are using it. ThreadList::Clear() takes the mutex and clears the thread list contents. llvm-svn: 178257
* <rdar://problem/13521159>Greg Clayton2013-03-271-6/+6
| | | | | | | | 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
* If we stopped but no threads had a reason for stopping, we should tell the ↵Jim Ingham2013-03-211-1/+16
| | | | | | | | user about it rather than continuing. <rdar://problem/13273125> Astris thread status replies for single-core device confuse lldb; lldb resumes execution on attaching llvm-svn: 177670
* <rdar://problem/12976225>Han Ming Ong2013-01-081-0/+23
| | | | | | Checking in the support for doing index ids reservation when given a thread id. llvm-svn: 171904
* Broadcast an event when the selected thread is changed.Jim Ingham2012-12-111-2/+17
| | | | | | <rdar://problem/10976636> llvm-svn: 169810
* Resolve printf formatting warnings on Linux:Daniel Malea2012-11-291-4/+4
| | | | | | | | - use macros from inttypes.h for format strings instead of OS-specific types Patch from Matt Kopec! llvm-svn: 168945
* Don't lock the thread list during ThreadList::ShouldStop. That does tooJim Ingham2012-11-151-7/+20
| | | | | | | much work for this to make sense. Just copy the current thread list and operate on that. Prevents some deadlocks. llvm-svn: 168106
* Stop using the "%z" size_t modifier and cast all size_t values to uint64_t. ↵Greg Clayton2012-09-181-2/+2
| | | | | | Some platforms don't support this modification. llvm-svn: 164148
OpenPOWER on IntegriCloud