From 3152b2ae078f83145774d2dbfaf6f471b8b766e8 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Tue, 25 Mar 2025 18:00:51 -0400 Subject: more qemu opts and gdb --- util/gdbinit | 31 +++++++++++++++++++++++++++++++ util/gdbinit.tmpl | 31 ------------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) create mode 100644 util/gdbinit delete mode 100644 util/gdbinit.tmpl (limited to 'util') diff --git a/util/gdbinit b/util/gdbinit new file mode 100644 index 0000000..ca2c885 --- /dev/null +++ b/util/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 diff --git a/util/gdbinit.tmpl b/util/gdbinit.tmpl deleted file mode 100644 index d9a981d..0000000 --- a/util/gdbinit.tmpl +++ /dev/null @@ -1,31 +0,0 @@ -# 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:1234\n -target remote localhost:1234 - -# 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 -- cgit v1.2.3-freya