summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2026-08-13 18:41:45 -0400
committerMatt Turner <mattst88@gmail.com>2026-11-08 14:07:17 -0500
commitf70fb444f08ee05794a70a744bcd78c4ae611107 (patch)
treecb156fd2898da8578bf666d98bfdb14d1f902e96 /gdb
parent79a4188fe347b5b159812b0fc90f96e1859c5247 (diff)
gdb: set intel disassembly flavor only for x86 targets
"set disassembly-flavor" is an x86-only setting, so running it from gdbinit fails with 'Undefined item: "intel"' whenever gdb starts up on another architecture. Hook new_objfile and executable_changed instead and apply the setting once the loaded file tells us the target is x86.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/.config/gdb/gdbinit16
1 files changed, 15 insertions, 1 deletions
diff --git a/gdb/.config/gdb/gdbinit b/gdb/.config/gdb/gdbinit
index 71fb88e..a599c42 100644
--- a/gdb/.config/gdb/gdbinit
+++ b/gdb/.config/gdb/gdbinit
@@ -1,4 +1,18 @@
set history save on
set history remove-duplicates unlimited
set history filename ~/.gdb_history
-set disassembly-flavor intel
+# "set disassembly-flavor" only exists for x86, so applying it unconditionally
+# breaks gdb when the current architecture is anything else. Apply it lazily,
+# once an objfile or executable tells us we are looking at x86.
+python
+def _set_intel_flavor(event=None):
+ try:
+ arch = gdb.selected_inferior().architecture().name()
+ except gdb.error:
+ return
+ if arch.startswith("i386") or arch.startswith("i8086"):
+ gdb.execute("set disassembly-flavor intel", to_string=True)
+
+gdb.events.new_objfile.connect(_set_intel_flavor)
+gdb.events.executable_changed.connect(_set_intel_flavor)
+end