[all-commits] [llvm/llvm-project] 0d77e0: [lldb/API] Introduce SBProcess::ForceScriptedState...

Med Ismail Bennani via All-commits all-commits at lists.llvm.org
Tue Apr 25 15:04:24 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0d77e034749f57676fd79e4a5b560be4d5b52b48
      https://github.com/llvm/llvm-project/commit/0d77e034749f57676fd79e4a5b560be4d5b52b48
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2023-04-25 (Tue, 25 Apr 2023)

  Changed paths:
    M lldb/include/lldb/API/SBProcess.h
    M lldb/include/lldb/Target/Process.h
    M lldb/source/API/SBProcess.cpp
    M lldb/source/Plugins/Process/scripted/ScriptedProcess.h

  Log Message:
  -----------
  [lldb/API] Introduce SBProcess::ForceScriptedState method

This patch introduces a new method to the SBProcess API called
ForceScriptedState. As the name suggests, this affordance will allow the
user to alter the state of the scripted process programatically.

This is necessary to update the scripted process state when perform
interactive debugging.

Differential Revision: https://reviews.llvm.org/D145294

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


  Commit: 6c961ae1b5073699285fcdec242cdb4e84602c05
      https://github.com/llvm/llvm-project/commit/6c961ae1b5073699285fcdec242cdb4e84602c05
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2023-04-25 (Tue, 25 Apr 2023)

  Changed paths:
    M lldb/examples/python/scripted_process/scripted_process.py
    M lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
    M lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
    M lldb/source/Plugins/Process/scripted/ScriptedProcess.h
    M lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
    M lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
    M lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
    M lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h

  Log Message:
  -----------
  [lldb] Move ScriptedProcess private state update to implementation

While debugging a Scripted Process, in order to update its state and
work nicely with lldb's execution model, it needs to toggle its private
state from running to stopped, which will result in broadcasting a
process state changed event to the debugger listener.

Originally, this state update was done systematically in the Scripted
Process C++ plugin, however in order to make scripted process
interactive, we need to be able to update their state dynamically.

This patch makes use of the recent addition of the
SBProcess::ForceScriptedState to programatically, and moves the
process private state update to the python implementation of the resume
method instead of doing it in ScriptedProcess::DoResume.

This patch also removes the unused ShouldStop & Stop scripted
process APIs, and adds new ScriptedInterface transform methods for
boolean arguments. This allow the user to programmatically decide if
after running the process, we should stop it (which is the default setting).

Differential Revision: https://reviews.llvm.org/D145295

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


  Commit: 46e93c9df287bc06854c66e08658f757ff6cf6f1
      https://github.com/llvm/llvm-project/commit/46e93c9df287bc06854c66e08658f757ff6cf6f1
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2023-04-25 (Tue, 25 Apr 2023)

  Changed paths:
    M lldb/include/lldb/Host/ProcessLaunchInfo.h
    M lldb/include/lldb/Target/Process.h
    M lldb/include/lldb/Utility/ProcessInfo.h
    M lldb/source/Host/common/ProcessLaunchInfo.cpp
    M lldb/source/Utility/ProcessInfo.cpp

  Log Message:
  -----------
  [lldb] Unify default/hijack listener between Process{Attach,Launch}Info (NFC)

This patch is a simple refactor that unifies the default and hijack
listener methods and attributes between ProcessAttachInfo and
ProcessLaunchInfo.

These 2 classes are both derived from the ProcessInfo base class so this
patch moves the listeners attributes and getter/setter methods to the
base class.

Differential Revision: https://reviews.llvm.org/D148395

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


  Commit: 6382fcb16def5ae4a47082466fd8dc93e8fdf988
      https://github.com/llvm/llvm-project/commit/6382fcb16def5ae4a47082466fd8dc93e8fdf988
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2023-04-25 (Tue, 25 Apr 2023)

  Changed paths:
    M lldb/include/lldb/API/SBAttachInfo.h
    M lldb/include/lldb/API/SBLaunchInfo.h
    M lldb/include/lldb/Target/Process.h
    M lldb/include/lldb/Utility/Broadcaster.h
    M lldb/include/lldb/Utility/Listener.h
    M lldb/include/lldb/Utility/ProcessInfo.h
    M lldb/source/API/SBAttachInfo.cpp
    M lldb/source/API/SBLaunchInfo.cpp
    M lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
    M lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
    M lldb/source/Target/Target.cpp
    M lldb/source/Utility/Broadcaster.cpp
    M lldb/source/Utility/Listener.cpp
    M lldb/source/Utility/ProcessInfo.cpp

  Log Message:
  -----------
  [lldb/Utility] Add opt-in shadow mode to event listeners

This patch augments lldb's event listeners with a new shadow mode.

As the name suggests, this mode allows events to be copied to an
additional listener to perform event monitoring, without interferring
with the event life cycle.

One of our use case for this, is to be able to listen to public process
events while making sure the events will still be delivered to the
default process listener (the debugger listener in most cases).

Differential Revision: https://reviews.llvm.org/D148397

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


  Commit: 482a0ad5ba72d2c306afd2d529f155554eadcd8a
      https://github.com/llvm/llvm-project/commit/482a0ad5ba72d2c306afd2d529f155554eadcd8a
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2023-04-25 (Tue, 25 Apr 2023)

  Changed paths:
    M lldb/source/Target/Process.cpp

  Log Message:
  -----------
  [lldb] Improve logging for process state change (NFC)

This patch improves process state change logging messages to include to
process plugin name.

It also replaces the `LLDB_LOGF` macro by `LLDB_LOG` macro that adds the
class and method name in the log message using the compiler instead of
having to change the string litteral for every method.

This is very useful when investigating interactions between different
types of process plugins. That comes very handy when investigating bugs
related to interactive scripted process debugging.

Differential Revision: https://reviews.llvm.org/D148399

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


  Commit: ad03aeadfb72e9c872b297bbaedbf46ebac3572c
      https://github.com/llvm/llvm-project/commit/ad03aeadfb72e9c872b297bbaedbf46ebac3572c
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2023-04-25 (Tue, 25 Apr 2023)

  Changed paths:
    M lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
    M lldb/source/Plugins/Process/scripted/ScriptedProcess.h

  Log Message:
  -----------
  [lldb/Plugin] Add breakpoint setting support to ScriptedProcess

This patch adds support for breakpoint setting to Scripted Processes.

For now, Scripted Processes only support setting software breakpoints.

When doing interactive scripted process debugging, it makes use of the
memory writing capability to write the trap opcodes in the memory of the
driving process. However the real process' target doesn't keep track of
the breakpoints that got added by the scripted process. This is a design
that we might need to change in the future, since we'll probably need to
do some book keeping to handle breakpoints that were set by different
scripted processes.

Differential Revision: https://reviews.llvm.org/D145296

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


  Commit: af1fea818391f20d585414493adb3fcdc70b4756
      https://github.com/llvm/llvm-project/commit/af1fea818391f20d585414493adb3fcdc70b4756
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2023-04-25 (Tue, 25 Apr 2023)

  Changed paths:
    M lldb/include/lldb/API/SBError.h
    M lldb/source/API/SBError.cpp

  Log Message:
  -----------
  [lldb/API] Add convenience constructor for SBError (NFC)

This patch adds a new convience constructor to the SBError to initialize
it with a string message to avoid having to create the object and call
the `SetErrorString` method afterwards.

This is very handy to report errors from lldb scripted affordances.

Differential Revision: https://reviews.llvm.org/D148401

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


  Commit: 6cf668016efde05db8c9f179843ec457ad017ff7
      https://github.com/llvm/llvm-project/commit/6cf668016efde05db8c9f179843ec457ad017ff7
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2023-04-25 (Tue, 25 Apr 2023)

  Changed paths:
    A lldb/test/API/functionalities/interactive_scripted_process/Makefile
    A lldb/test/API/functionalities/interactive_scripted_process/TestInteractiveScriptedProcess.py
    A lldb/test/API/functionalities/interactive_scripted_process/interactive_scripted_process.py
    A lldb/test/API/functionalities/interactive_scripted_process/main.cpp

  Log Message:
  -----------
  [lldb] Add an example of interactive scripted process debugging

This patch is a proof of concept that shows how a scripted process could
be used with real process to perform interactive debugging.

In this example, we run a process that spawns 10 threads.
That process gets launched by an intermediary scripted process who's job
is to intercept all of it's process events and dispatching them
back either to the real process or to other child scripted processes.

In this example, we have 2 child scripted processes, with even and odd
thread indices. The goal is to be able to do thread filtering and
explore the various interactive debugging approaches, by letting a child
process running when stopping the other process and inspecting it.
Another approach would be to have the child processes execution in-sync
to force running every child process when one of them starts running.

Differential Revision: https://reviews.llvm.org/D145297

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


  Commit: e31d0c20e411f22a943f1ed5f8b618c529436c59
      https://github.com/llvm/llvm-project/commit/e31d0c20e411f22a943f1ed5f8b618c529436c59
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2023-04-25 (Tue, 25 Apr 2023)

  Changed paths:
    M lldb/bindings/interface/SBTargetExtensions.i
    M lldb/bindings/python/python-wrapper.swig
    M lldb/examples/python/scripted_process/scripted_process.py
    M lldb/include/lldb/API/SBBreakpoint.h
    M lldb/include/lldb/Interpreter/ScriptInterpreter.h
    M lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
    M lldb/source/Interpreter/ScriptInterpreter.cpp
    M lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
    M lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
    M lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
    M lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
    M lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
    M lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
    M lldb/test/API/functionalities/interactive_scripted_process/TestInteractiveScriptedProcess.py
    M lldb/test/API/functionalities/interactive_scripted_process/interactive_scripted_process.py
    M lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

  Log Message:
  -----------
  [lldb] Improve breakpoint management for interactive scripted process

This patch improves breakpoint management when doing interactive
scripted process debugging.

In other to know which process set a breakpoint, we need to do some book
keeping on the multiplexer scripted process. When initializing the
multiplexer, we will first copy breakpoints that are already set on the
driving target.

Everytime we launch or resume, we should copy breakpoints from the
multiplexer to the driving process.

When creating a breakpoint from a child process, it needs to be set both
on the multiplexer and on the driving process. We also tag the created
breakpoint with the name and pid of the originator process.

This patch also implements all the requirement to achieve proper
breakpoint management. That involves:

- Adding python interator for breakpoints and watchpoints in SBTarget
- Add a new `ScriptedProcess.create_breakpoint` python method

Differential Revision: https://reviews.llvm.org/D148548

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


  Commit: 34bd15798ede2bc003783ed61d08f8d6c74c38f9
      https://github.com/llvm/llvm-project/commit/34bd15798ede2bc003783ed61d08f8d6c74c38f9
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2023-04-25 (Tue, 25 Apr 2023)

  Changed paths:
    M lldb/packages/Python/lldbsuite/test/lldbutil.py

  Log Message:
  -----------
  [lldb/test] Update lldbutil.fetch_next_event to match broadcaster class

This patch updates the `lldbutil.fetch_next_event` helper function to
either match a specific broadcaster or match a whole broadcaster class.

This is very handy when testing process events for interactive scripted
process debugging.

This also fixes a bug in the failing case, where `SBEvent.GetDescription`
expects a `SBStream` argument. We never took that code path in the
original implementation so we didn't hit that bug.

Differential Revision: https://reviews.llvm.org/D149175

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


  Commit: d3a6b93135cd344737b2877b78afe9c862e40041
      https://github.com/llvm/llvm-project/commit/d3a6b93135cd344737b2877b78afe9c862e40041
  Author: Med Ismail Bennani <medismail.bennani at gmail.com>
  Date:   2023-04-25 (Tue, 25 Apr 2023)

  Changed paths:
    M lldb/test/API/functionalities/interactive_scripted_process/TestInteractiveScriptedProcess.py

  Log Message:
  -----------
  [lldb/test] Consolidate interactive scripted process debugging test

This patch improve the interactive scripted process debugging test by
adding test coverage for child process breakpoint setting and execution
state change.

This patch introduces a new test case for a multiplexed launch, which
does the same thing as the simple passthrough launch. After the
multiplexer process stops, this new test launches 2 other scripted processes
that should contain respectively the even and odd threads from the
multiplexer scripted process.

Then, we create a breakpoint on one the child scripted process, make
sure it was set probably on the child process, the multiplexer process
and the real process. This also test the breakpoint name tagging at the
multiplexer level.

Finally, we resume the child process that had a breakpoint and make sure
that all the processes has stopped at the right location.

Differential Revision: https://reviews.llvm.org/D149179

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


Compare: https://github.com/llvm/llvm-project/compare/7be8341f19bf...d3a6b93135cd


More information about the All-commits mailing list