aboutsummaryrefslogtreecommitdiff
path: root/gcc/gdbhooks.py
diff options
context:
space:
mode:
authorAlex Coplan <alex.coplan@arm.com>2024-08-05 08:45:58 +0100
committerAlex Coplan <alex.coplan@arm.com>2024-08-05 08:45:58 +0100
commitf01df5e47b2551e0f435a9efa8e0a30142f3d46b (patch)
tree63bc390dfb318849db7771c5136fd8d0e40f4ec1 /gcc/gdbhooks.py
parent08cc516a8cfe553064f84a86be4c30f05a614342 (diff)
downloadgcc-f01df5e47b2551e0f435a9efa8e0a30142f3d46b.zip
gcc-f01df5e47b2551e0f435a9efa8e0a30142f3d46b.tar.gz
gcc-f01df5e47b2551e0f435a9efa8e0a30142f3d46b.tar.bz2
gdbhooks: Add attempt to invoke on-gcc-hooks-load
This extends GCC's GDB hooks to attempt invoking the user-defined command "on-gcc-hooks-load". The idea is that users can define the command in their .gdbinit to override the default values of parameters defined by GCC's GDB extensions. For example, together with the previous patch, I can add the following fragment to my .gdbinit: define on-gcc-hooks-load set gcc-dot-cmd xdot end which means, once the GCC extensions get loaded, whenever I invoke dot-fn then the graph will be rendered using xdot. The try/except should make this patch a no-op for users that don't currently define this command. I looked for a way to test explicitly for whether a GDB command exists but didn't find one. This is needed because the user's .gdbinit is sourced before GCC's GDB extensions are loaded, and GCC-specific parameters can't be configured before they are defined. gcc/ChangeLog: * gdbhooks.py: Add attempted call to "on-gcc-hooks-load" once we've finished loading the hooks.
Diffstat (limited to 'gcc/gdbhooks.py')
-rw-r--r--gcc/gdbhooks.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/gdbhooks.py b/gcc/gdbhooks.py
index db8ce0d..7a64c03 100644
--- a/gcc/gdbhooks.py
+++ b/gcc/gdbhooks.py
@@ -865,4 +865,12 @@ class DotFn(gdb.Command):
DotFn()
+# Try and invoke the user-defined command "on-gcc-hooks-load". Doing
+# this allows users to customize the GCC extensions once they've been
+# loaded by defining the hook in their .gdbinit.
+try:
+ gdb.execute('on-gcc-hooks-load')
+except gdb.error:
+ pass
+
print('Successfully loaded GDB hooks for GCC')