diff --git a/.gdbinit b/.gdbinit index 411a7ce141d..58630f7d0fc 100644 --- a/.gdbinit +++ b/.gdbinit @@ -1 +1 @@ -source tools/gdb/pretty_printers/utils/static_vector_pp.py +source tools/gdb/devilution_gdb/__init__.py diff --git a/.lldbinit b/.lldbinit index 6e6a4ef79ae..c73269937d0 100644 --- a/.lldbinit +++ b/.lldbinit @@ -1,4 +1,4 @@ script topsrcdir = topsrcdir if "topsrcdir" in locals() else os.getcwd() -script sys.path.append(os.path.join(topsrcdir, "tools/lldbutils")) -script import lldbutils -script lldbutils.init() +script sys.path.append(os.path.join(topsrcdir, "tools/lldb")) +script import devilution_lldb +script devilution_lldb.init() diff --git a/tools/gdb/README.md b/tools/gdb/README.md new file mode 100644 index 00000000000..eb563f3477d --- /dev/null +++ b/tools/gdb/README.md @@ -0,0 +1,34 @@ +# gdb debugging enhancements + +Requires gdb v14.1+. + +The code in this directory is imported via `.gdbinit`. + +Working directory `.gdb` is not loaded by default. + +You can run gdb with `-iex 'add-auto-load-safe-path .'` to load it. + +For example: + +```bash +gdb -iex 'add-auto-load-safe-path .' build/devilutionx +``` + +If you're using VS Code with CMake, you can instead add the following to your `.vscode/settings.json`: + +```json +"cmake.debugConfig": { + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Load gdb enhancements", + "text": "source ${workspaceFolder}/tools/gdb/devilution_gdb/__init__.py", + "ignoreFailures": false + } + ] +} +``` diff --git a/tools/gdb/devilution_gdb/__init__.py b/tools/gdb/devilution_gdb/__init__.py new file mode 100644 index 00000000000..42263d6d586 --- /dev/null +++ b/tools/gdb/devilution_gdb/__init__.py @@ -0,0 +1,6 @@ +import sys +import pathlib + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent)) + +import devilution_gdb.pretty_printers.utils.static_vector_pp as _ diff --git a/tools/gdb/pretty_printers/utils/static_vector_pp.py b/tools/gdb/devilution_gdb/pretty_printers/utils/static_vector_pp.py similarity index 100% rename from tools/gdb/pretty_printers/utils/static_vector_pp.py rename to tools/gdb/devilution_gdb/pretty_printers/utils/static_vector_pp.py diff --git a/tools/lldbutils/README.md b/tools/lldb/README.md similarity index 100% rename from tools/lldbutils/README.md rename to tools/lldb/README.md diff --git a/tools/lldb/devilution_lldb/__init__.py b/tools/lldb/devilution_lldb/__init__.py new file mode 100644 index 00000000000..c122096997a --- /dev/null +++ b/tools/lldb/devilution_lldb/__init__.py @@ -0,0 +1,7 @@ +import lldb + +import devilution_lldb.pretty_printers.utils.static_vector_pp + + +def init(): + devilution_lldb.pretty_printers.utils.static_vector_pp.init(lldb.debugger) diff --git a/tools/lldbutils/lldbutils/pretty_printers/utils/static_vector_pp.py b/tools/lldb/devilution_lldb/pretty_printers/utils/static_vector_pp.py similarity index 86% rename from tools/lldbutils/lldbutils/pretty_printers/utils/static_vector_pp.py rename to tools/lldb/devilution_lldb/pretty_printers/utils/static_vector_pp.py index 2f48e2877f8..477db293f54 100644 --- a/tools/lldbutils/lldbutils/pretty_printers/utils/static_vector_pp.py +++ b/tools/lldb/devilution_lldb/pretty_printers/utils/static_vector_pp.py @@ -28,5 +28,5 @@ def get_child_at_index(self, index): def init(debugger: lldb.debugger): debugger.HandleCommand( - 'type synthetic add -x "devilution::StaticVector<" -l lldbutils.pretty_printers.utils.static_vector_pp.StaticVectorSyntheticChildrenProvider' + 'type synthetic add -x "devilution::StaticVector<" -l devilution_lldb.pretty_printers.utils.static_vector_pp.StaticVectorSyntheticChildrenProvider' ) diff --git a/tools/lldbutils/lldbutils/__init__.py b/tools/lldbutils/lldbutils/__init__.py deleted file mode 100644 index b49a60da79f..00000000000 --- a/tools/lldbutils/lldbutils/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -import lldb - -import lldbutils.pretty_printers.utils.static_vector_pp - -def init(): - lldbutils.pretty_printers.utils.static_vector_pp.init(lldb.debugger)