summaryrefslogtreecommitdiff
path: root/config/gdbinit
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-08 10:39:48 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-08 10:39:48 -0400
commit8a19547957a86bed3f58c9abc1ac218d04698faf (patch)
treeed7ccc6f3a8902915dfe6c9bf763fc45d752b3c4 /config/gdbinit
parentfmt (diff)
downloadcomus-8a19547957a86bed3f58c9abc1ac218d04698faf.tar.gz
comus-8a19547957a86bed3f58c9abc1ac218d04698faf.tar.bz2
comus-8a19547957a86bed3f58c9abc1ac218d04698faf.zip
break apart c libaray
Diffstat (limited to 'config/gdbinit')
-rw-r--r--config/gdbinit31
1 files changed, 31 insertions, 0 deletions
diff --git a/config/gdbinit b/config/gdbinit
new file mode 100644
index 0000000..ca2c885
--- /dev/null
+++ b/config/gdbinit
@@ -0,0 +1,31 @@
+# adapted from the xv6 .gdbinit.tmpl file
+set $lastcs = -1
+
+define hook-stop
+ # There doesn't seem to be a good way to detect if we're in 16- or
+ # 32-bit mode, but we always run with CS == 8 in 32-bit mode.
+ if $cs == 8 || $cs == 27
+ if $lastcs != 8 && $lastcs != 27
+ set architecture i386
+ end
+ x/i $pc
+ else
+ if $lastcs == -1 || $lastcs == 8 || $lastcs == 27
+ set architecture i8086
+ end
+ # Translate the segment:offset into a physical address
+ printf "[%4x:%4x] ", $cs, $eip
+ x/i $cs*16+$eip
+ end
+ set $lastcs = $cs
+end
+
+echo + target remote localhost:1337\n
+target remote localhost:1337
+
+# If this fails, it's probably because your GDB doesn't support ELF.
+# Look at the tools page at
+# http://pdos.csail.mit.edu/6.828/2009/tools.html
+# for instructions on building GDB with ELF support.
+echo + symbol-file build/kernel/kernel\n
+symbol-file build/kernel/kernel