gdbinit.tmpl (682B)
1 set $lastcs = -1 2 3 define hook-stop 4 # There doesn't seem to be a good way to detect if we're in 16- or 5 # 32-bit mode, but in 32-bit mode we always run with CS == 8 in the 6 # kernel and CS == 35 in user space 7 if $cs == 8 || $cs == 35 8 if $lastcs != 8 && $lastcs != 35 9 set architecture i386 10 end 11 x/i $pc 12 else 13 if $lastcs == -1 || $lastcs == 8 || $lastcs == 35 14 set architecture i8086 15 end 16 # Translate the segment:offset into a physical address 17 printf "[%4x:%4x] ", $cs, $eip 18 x/i $cs*16+$eip 19 end 20 set $lastcs = $cs 21 end 22 23 echo + target remote localhost:1234\n 24 target remote localhost:1234 25 26 echo + symbol-file kernel\n 27 symbol-file kernel