[Lldb-commits] [PATCH] D68174: Allow private-state-thread to call SB API's that take the TargetAPI mutex

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 27 18:30:20 PDT 2019


jingham created this revision.
jingham added a reviewer: clayborg.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

When we do synchronous process execution in lldb, the call that restarted the target will generally have acquired first the TargetAPI lock, and then the Process RunLock.  If in the process of handling that continue we need to run Python code in the private-state-thread (e.g. for an OS plugin or scripted ThreadPlan) if that Python code calls another API that takes the Target API mutex, we will deadlock.  However, the private state thread is always doing work on behalf of whatever thread initiated the continue.  So the private state thread should always formally be allowed to pass the lock check.

We already handled this in the case of the Process RunLock by passing out separate locks depending on whether you were running code in the private state thread or anywhere else.  This patch just does the same thing for the Target API mutex.

I also added a test using a scripted ThreadPlan that calls various SBFrame and SBValue API's which take the API lock in the should_stop method of the plan (which is always run on the private state thread).


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D68174

Files:
  lldb/include/lldb/Target/Process.h
  lldb/include/lldb/Target/Target.h
  lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/Steps.py
  lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py
  lldb/packages/Python/lldbsuite/test/functionalities/step_scripted/main.c
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68174.222274.patch
Type: text/x-patch
Size: 8509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190928/ea258605/attachment.bin>


More information about the lldb-commits mailing list