Page MenuHomePhabricator

[Dexter] Add Debugger Controller To Dexter

Authored by TWeaver on Mar 27 2020, 7:05 AM.



Hello LLVM and Dexter Community,

I present to you the 'Debugger Controller' patch.

Recently there's been interest in running the debugger frame work of Dexter in new and interesting ways. My own work coupled with the work of some other Dexter contributors has highlighted an issue:

The current architecture of Dexter doesn't support new and novel ways of running the debugger. If one wishes to write their own debugger running behaviour, that behaviour has to sit awkwardly with the existing behaviour. But fear not, this patch goes some of the way to fixing this issue.

The original implementation of DebuggerBase was a monolith of 3 things - It's responsible for exposing the features of the debuggers (good), operating the debuggers behaviour to get step information (bad) and responsible for archiving and generating said step behaviour (also bad).

This patch addresses behaviour 2. The operating behaviour of the debugger has been promoted to a first class object, the DebuggerController. If you wish to implement your own debugger operating behaviour simply inherit from DebuggerControllerBase and extend the _run_debugger_custom method.

Also rolled in with this patch is how the debugger controller, context, options and step collections are passed around Dexter. No longer is the get_debugger_steps method in responsible be passing context, options or step collections to the internal_run_debugger_ tool. It's job now is to pass a fully formed debugger controller object that contains all the information required to run the debugger. Context, Options and step information are all stored in the DefaultController now (which represents the default dexter behaviour before this patch). As a result, get_debugger_steps is now known as run_debugger_subprocess as that is all it's responsible for.

We now pass the controller as a pickled object, unpickle and run it in the internal tool and then repickle to be returned back to run_debugger_subprocess, this is then returned to the caller of run_debugger_subprocess. This could be the test tool, the clang-opt-bisect tool or any other tool that exists within dexter. Which debugger controller is passed is up to us as developers, so we can pick and choose for whatever case suits our needs.

A follow up patch for this change is also incoming that will have a new type of debugger controller, the ConditionalSteppingController. In order to bring this new behaviour to dexter it's paramount that we have an extensible debugger operating architecture, and it's my hope that this patch delivers on this premise.

Diff Detail

Event Timeline

TWeaver created this revision.Mar 27 2020, 7:05 AM
Orlando accepted this revision.Mar 27 2020, 7:34 AM

Makes sense to separate out these parts. LGTM, but it's a sizeable patch so maybe wait a little and see if anyone else has anything to say before committing.

This revision is now accepted and ready to land.Mar 27 2020, 7:34 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2020, 8:05 AM
tbosch added a subscriber: tbosch.Apr 20 2020, 4:55 PM

Hello, I believe this broke the test "clang-opt-bisect" (ran at ee12edcb76423c78b55cdddae2edfe45cbb2ccd6):

******************** TEST 'debuginfo-tests :: dexter/feature_tests/subtools/clang-opt-bisect/clang-opt-bisect.cpp' FAILED ********************
: 'RUN: at line 6';   true
: 'RUN: at line 7';   "/usr/bin/python" "/usr/local/google/home/tbosch/llvm-project/debuginfo-tests/dexter/" clang-opt-bisect --debugger 'lldb' --builder 'clang'      --cflags "-O0 -g" -- /usr/local/google/home/tbosch/llvm-project/debuginfo-tests/dexter/feature_tests/subtools/clang-opt-bisect/clang-opt-bisect.cpp      | /usr/local/google/home/tbosch/llvm-project/build/bin/FileCheck /usr/local/google/home/tbosch/llvm-project/debuginfo-tests/dexter/feature_tests/subtools/clang-opt-bisect/clang-opt-bisect.cpp
Exit Code: 2

Command Output (stderr):

**                                    **
** This is a bug in DExTer.           **
**                                    **
**                  Please report it. **
**                                    **


DExTer 1.0.0 [master ee12edcb76423c78b55cdddae2edfe45cbb2ccd6] (
  using Python 3.7.6 (default, Dec 19 2019, 09:25:23)
[GCC 9.2.1 20191109]

['/usr/bin/python', '/usr/local/google/home/tbosch/llvm-project/debuginfo-tests/dexter/', 'clang-opt-bisect', '--debugger', 'lldb', '--builder', 'clang', '--cflags', '-O0 -g', '--', '/usr/local/google/home/tbosch/llvm-project/debuginfo-tests/dexter/feature_tests/subtools/clang-opt-bisect/clang-opt-bisect.cpp']

Traceback (most recent call last):
  File "/usr/local/google/home/tbosch/llvm-project/debuginfo-tests/dexter/", line 15, in <module>
    return_code = main()
  File "/usr/local/google/home/tbosch/llvm-project/debuginfo-tests/dexter/dex/tools/", line 193, in main
    return tool_main(context, module.Tool(context), args)
  File "/usr/local/google/home/tbosch/llvm-project/debuginfo-tests/dexter/dex/tools/", line 162, in tool_main
    return_code = tool.go()
  File "/usr/local/google/home/tbosch/llvm-project/debuginfo-tests/dexter/dex/tools/", line 122, in go
  File "/usr/local/google/home/tbosch/llvm-project/debuginfo-tests/dexter/dex/tools/clang_opt_bisect/", line 141, in _run_test
    self.context, debugger_controller)
  File "/usr/local/google/home/tbosch/llvm-project/debuginfo-tests/dexter/dex/debugger/", line 140, in run_debugger_subprocess
    dir=working_dir_path, delete=False, mode='wb') as fp:
  File "/usr/lib/python3.7/", line 686, in NamedTemporaryFile
    (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
  File "/usr/lib/python3.7/", line 395, in _mkstemp_inner
    file = _os.path.join(dir, pre + name + suf)
  File "/usr/lib/python3.7/", line 80, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not DefaultController
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /usr/local/google/home/tbosch/llvm-project/build/bin/FileCheck /usr/local/google/home/tbosch/llvm-project/debuginfo-tests/dexter/feature_tests/subtools/clang-opt-bisect/clang-opt-bisect.cpp

P.S.: You might have received this comment 2x, I am new to phrabricator...

TWeaver added a comment.EditedApr 21 2020, 5:50 AM


thanks for reporting. this issue should now be fixed.

thanks again,
Tom W

TWeaver added a comment.EditedApr 21 2020, 6:06 AM

fix for reported test failure at:


Thanks, just verified that this is fixed for me too.