implement gdb remote protocol debugger
Opened this issue · 3 comments
wwiv commented
With the start of the lame debugger, we can listen on a socket already. Here's what we get when we attempt to attach the GDB debugger to the lame debugger port:
2021-07-12 11:56:56,596 INFO Listening to LAME_DEBUGGER on port: 2112
LameDebugger: +$qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;xmlRegisters=i386#6a$qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;xmlRegisters=i386#6a$qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;xmlRegisters=i386#6a$qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;xmlRegisters=i386#6a
2021-07-12 11:57:09,156 INFO LameDebugger::handle_line; cmd: +$qsupported:multiprocess+;swbreak+;hwbreak+;qrelocinsn+;fork-events+;vfork-events+;exec-events+;vcontsupported+;qthreadevents+;no-resumed+;xmlregisters=i386#6a$qsupported:multiprocess+;swbreak+;hwbreak+;qrelocinsn+;fork-events+;vfork-events+;exec-events+;vcontsupported+;qthreadevents+;no-resumed+;xmlregisters=i386#6a$qsupported:multiprocess+;swbreak+;hwbreak+;qrelocinsn+;fork-events+;vfork-events+;exec-events+;vcontsupported+;qthreadevents+;no-resumed+;xmlregisters=i386#6a$qsupported:multiprocess+;swbreak+;hwbreak+;qrelocinsn+;fork-events+;vfork-events+;exec-events+;vcontsupported+;qthreadevents+;no-resumed+;xmlregisters=i386#6a; data:
LameDebugger: -
2021-07-12 11:57:13,150 INFO LameDebugger::handle_line; cmd: -; data:
LameDebugger: -
2021-07-12 11:57:15,312 INFO LameDebugger::handle_line; cmd: -; data:
LameDebugger: -+$vMustReplyEmpty#3a$vMustReplyEmpty#3a
2021-07-12 11:57:19,290 INFO LameDebugger::handle_line; cmd: -+$vmustreplyempty#3a$vmustreplyempty#3a; data:
LameDebugger: $vMustReplyEmpty#3a
2021-07-12 11:57:21,368 INFO LameDebugger::handle_line; cmd: $vmustreplyempty#3a; data:
LameDebugger: $vMustReplyEmpty#3a
2021-07-12 11:57:23,417 INFO LameDebugger::handle_line; cmd: $vmustreplyempty#3a; data:
LameDebugger: -
2021-07-12 11:57:27,352 INFO LameDebugger::handle_line; cmd: -; data:
LameDebugger: -
2021-07-12 11:57:29,416 INFO LameDebugger::handle_line; cmd: -; data:
LameDebugger: -+
2021-07-12 11:57:29,419 INFO LameDebugger::handle_line; cmd: -+; data:
2021-07-12 11:57:29,421 ERROR empty line. client disconnected?
wwiv commented
Here's a good example with gdbserver
Remote debugging using localhost:2112
Sending packet: $qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;xmlRegisters=i386#6a...Ack
Packet received: PacketSize=47ff;QPassSignals+;QProgramSignals+;QStartupWithShell+;QEnvironmentHexEncoded+;QEnvironmentReset+;QEnvironmentUnset+;QSetWorkingDir+;QCatchSyscalls+;qXfer:libraries-svr4:read+;augmented-libraries-svr4-read+;qXfer:auxv:read+;qXfer:spu:read+;qXfer:spu:write+;qXfer:siginfo:read+;qXfer:siginfo:write+;qXfer:features:read+;QStartNoAckMode+;qXfer:osdata:read+;multiprocess+;fork-events+;vfork-events+;exec-events+;QNonStop+;QDisableRandomization+;qXfer:threads:read+;ConditionalTracepoints+;TraceStateVaria
Packet qSupported (supported-packets) is supported
Sending packet: $vMustReplyEmpty#3a...Ack
Packet received:
Sending packet: $QStartNoAckMode#b0...Ack
Packet received: OK
Sending packet: $QProgramSignals:0;1;3;4;6;7;8;9;a;b;c;d;e;f;10;11;12;13;14;15;16;17;18;19;1a;1b;1c;1d;1e;1f;20;21;22;23;24;25;26;27;28;29;2a;2b;2c;2d;2e;2f;30;31;32;33;34;35;36;37;38;39;3a;3b;3c;3d;3e;3f;40;41;42;43;44;45;46;47;48;49;4a;4b;4c;4d;4e;4f;50;51;52;53;54;55;56;57;58;59;5a;5b;5c;5d;5e;5f;60;61;62;63;64;65;66;67;68;69;6a;6b;6c;6d;6e;6f;70;71;72;73;74;75;76;77;78;79;7a;7b;7c;7d;7e;7f;80;81;82;83;84;85;86;87;88;89;8a;8b;8c;8d;8e;8f;90;91;92;93;94;95;96;97;#75...Packe
t received: OK
Sending packet: $Hgp0.0#ad...Packet received: OK
Sending packet: $qXfer:features:read:target.xml:0,fff#7d...Packet received: m<?xml version="1.0"?>\n<!DOCTYPE target SYSTEM "gdb-target.dtd">\n<target>\n<architecture>i386:x86-64</architecture>\n<osabi>GNU/Linux</osabi><feature name="org.gnu.gdb.i386.core">\n<flags id="i386_eflags" size="4">\n <field name="CF" start="0" end="0"/>\n <field name="" start="1"
end="1"/>\n <field name="PF" start="2" end="2"/>\n <field name="AF" start="4" end="4"/>\n <field name="ZF" start="6" end="6"/>\n <field name="SF" start="7" end="7"/>\n <field name="TF" start="8" end="8"/>\n <field name="IF" start="9" [13 bytes omitted]
Sending packet: $qXfer:features:read:target.xml:fff,1000#0e...Packet received: lield name="UE" start="4" end="4"/>\n <field name="PE" start="5" end="5"/>\n <field name="DAZ" start="6" end="6"/>\n <field name="IM" start="7" end="7"/>\n <field name="DM" start="8" end="8"/>\n <field name="ZM" start="9" end="9"/>\n <field name="OM" start="10" end="10"/>\n <field name="UM" start="11" end="11"/>\n <field name="PM" start="12" end="12"/>\n <field name="FZ" start="15" end="15"/>\n</flags>\n<reg name="xmm0" bitsize="128" type="vec128" regnum="40"/>\n<reg name="xmm1" bitsize="128" type="vec128" reg[12 bytes omitted]
warning: A handler for the OS ABI "GNU/Linux" is not built into this configuration
of GDB. Attempting to continue with the default i386:x86-64 settings.
warning: Architecture rejected target-supplied description
Sending packet: $QNonStop:0#8c...Packet received: OK
Sending packet: $qTStatus#49...Packet received: T0;tnotrun:0;tframes:0;tcreated:0;tfree:500000;tsize:500000;circular:0;disconn:0;starttime:0;stoptime:0;username:;notes::
Packet qTStatus (trace-status) is supported
Sending packet: $qTfV#81...Packet received: 1:0:1:74726163655f74696d657374616d70
Sending packet: $qTsV#8e...Packet received: l
Sending packet: $?#3f...Packet received: T0506:0000000000000000;07:10e4ffffff7f0000;10:9060fdf7ff7f0000;thread:p2937.2937;core:4;
Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2937.2937" core="4" name="vi"/>\n</threads>\n
Sending packet: $qAttached:2937#9e...Packet received: 0
Packet qAttached (query-attached) is supported
Sending packet: $qXfer:exec-file:read:2937:0,fff#5f...Packet received: l/usr/bin/vim.basic
Sending packet: $vFile:setfs:0#bf...Packet received: F0
Packet vFile:setfs (hostio-setfs) is supported
Sending packet: $vFile:open:6a7573742070726f62696e67,0,1c0#ed...Packet received: F-1,2
Packet vFile:open (hostio-open) is supported
Reading /usr/bin/vim.basic from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Sending packet: $vFile:setfs:2937#64...Packet received: F0
Sending packet: $vFile:open:2f7573722f62696e2f76696d2e6261736963,0,0#6b...Packet received: F5
Sending packet: $vFile:fstat:5#c1...Packet received: F40;\000\000\b\020\000\000ß\021\000\000\201í\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000)Cè\000\000\000\000\000\000\020\000\000\000\000\000\000\000\024"`ìSP]\005\037«`Aß
Packet vFile:fstat (hostio-fstat) is supported
Sending packet: $vFile:fstat:5#c1...Packet received: F40;\000\000\b\020\000\000ß\021\000\000\201í\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000)Cè\000\000\000\000\000\000\020\000\000\000\000\000\000\000\024"`ìSP]\005\037«`Aß
Sending packet: $vFile:fstat:5#c1...Packet received: F40;\000\000\b\020\000\000ß\021\000\000\201í\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000)Cè\000\000\000\000\000\000\020\000\000\000\000\000\000\000\024"`ìSP]\005\037«`Aß
readahead cache miss 1
Sending packet: $vFile:pread:5,47ff,0#6a...Packet received: F47e8;\177ELF\002\001\001\000\000\000\000\000\000\000\000\000\003\000>\000\001\000\000\000A·\002\000\000\000\000\000@\000\000\000\000\000\000\000è<)\000\000\000\000\000\000\000\000\000@\0008\000\013\000@\000\034\000\e\000\006\000\000\000\004\000\000\000@\000\000\000\000\000\000\000@\000\000\000\000\000\000\000@\000\000\000\000\000\000\000h\002\000\000\000\000\000\000h\002\000\000\000\000\000\000\b\000\000\000\000\000\000\000\003\000\000\000\004\000\000\000"\002\000\000\000\000\000\000"\002\000\000\000\000\000\000"\002\000\000\000\000\000\000\034\000\000\000\000\000\000\000\034\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\206\002\000\000\000\000\000\000\206\002\000\000\000\000\000\000\020\000\000\000\000\000\000\001\000\000\000\005\000\000\000\000\220\002\000\000\000\000\000\000\220\002\000\000\000\000\000\000\220\002\000\000\000\000\000\235\n\036\000\000\000\000\000\235\n\036\000\000\000\000\000\000\020\000\000\000\000\000\000\001\000\000\000\004\000\000\000\000 \000\000\000\000\000\000 \000\000\000\000\000\000 \000\000\000\000\00080\006\000\000\000\000\00080\006\000\000\000\000\000\000\020\000\000\000\000\000\000\001\000\000\000\006\000\000\000\220x&\000\000\000\000\000\220ç&\000\000\000\000\000\220ç&\000\000\
000\000\000 d\002\000\000\000\000\000H\030\003\000\000\000\000\000\000\020\000\000\000\000\000\000\002\000\000\000\006\000\000\000\230\226'\000\000\000\000\000\230▌'\000\000\000\000\000\230▌'\000\000\000\000\000P\002\000\000\000\000\000\000P\002\000\000\000\000\000\000\b\000\000\000\000\000\000\000\004\000\000\000\004\000\000\000Ä\002\000\000\000\000\000\000Ä\002\000\000\000\000\000\000Ä\002\000\000\000\000\000\000D\000\000\000\000\000\000\000D\000\000\000\000\000\000\000\004\000[1352 bytes omitted]
Packet vFile:pread (hostio-pread) is supported
readahead cache hit 1
readahead cache hit 2
readahead cache hit 3
readahead cache hit 4
readahead cache hit 5
readahead cache hit 6
readahead cache hit 7
readahead cache hit 8
readahead cache hit 9
readahead cache hit 10
Sending packet: $vFile:close:5#b5...Packet received: F0
Packet vFile:close (hostio-close) is supported
warning: "target:/usr/bin/vim.basic": not in executable format: File format not recognized
Reading /usr/bin/vim.basic from remote target...
Sending packet: $vFile:open:2f7573722f62696e2f76696d2e6261736963,0,0#6b...Packet received: F5
Sending packet: $vFile:fstat:5#c1...Packet received: F40;\000\000\b\020\000\000ß\021\000\000\201í\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000)Cè\000\000\000\000\000\000\020\000\000\000\000\000\000\000\024"`ìSP]\005\037«`Aß
Sending packet: $vFile:fstat:5#c1...Packet received: F40;\000\000\b\020\000\000ß\021\000\000\201í\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000)Cè\000\000\000\000\000\000\020\000\000\000\000\000\000\000\024"`ìSP]\005\037«`Aß
Sending packet: $vFile:fstat:5#c1...Packet received: F40;\000\000\b\020\000\000ß\021\000\000\201í\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000)Cè\000\000\000\000\000\000\020\000\000\000\000\000\000\000\024"`ìSP]\005\037«`Aß
readahead cache miss 2
Sending packet: $vFile:pread:5,47ff,0#6a...Packet received: F47e8;\177ELF\002\001\001\000\000\000\000\000\000\000\000\000\003\000>\000\001\000\000\000A·\002\000\000\000\000\000@\000\000\000\000\000\000\000è<)\000\000\000\000\000\000\000\000\000@\0008\000\013\000@\000\034\000\e\000\006\000\000\000\004\000\000\000@\000\000\000\000\000\000\000@\000\000\000\000\000\000\000@\000\000\000\000\000\000\000h\002\000\000\000\000\000\000h\002\000\000\000\000\000\000\b\000\000\000\000\000\000\000\003\000\000\000\004\000\000\000"\002\000\000\000\000\000\000"\002\000\000\000\000\000\000"\002\000\000\000\000\000\000\034\000\000\000\000\000\000\000\034\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\001\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\206\
002\000\000\000\000\000\000\206\002\000\000\000\000\000\000\020\000\000\000\000\000\000\001\000\000\000\005\000\000\000\000\220\002\000\000\000\000\000\000\220\002\000\000\000\000\000\000\220\002\000\000\000\000\000\235\n\036\000\000\000\000\000\235\n\036\000\000\000\000\000\000\020\000\000\000\000\000\000\001\000\000\000\004\000\000\000\000 \000\000\000\000\000\000 \000\000\000\000\000\000 \000\000\000\000\00080\006\000\000\000\000\00080\006\000\000\000\000\000\000\020\000\000\000\000\000\000\001\000\000\000\006\000\000\000\220x&\000\000\000\000\000\220ç&\000\000\000\000\000\220ç&\000\000\000\000\000 d\002\000\000\000\000\000H\030\003\000\000\000\000\000\000\020\000\000\000\000\000\000\002\000\000\000\006\000\000\000\230\226'\000\000\000\000\000\230▌'\000\000\000\000\000\230▌'\000\000\000\000\000P\002\000\000\000\000\000\000P\002\000\000\000\000\000\000\b\000\000\000\000\000\000\000\004\000\000\000\004\000\000\000Ä\002\000\000\000\000\000\000Ä\002\000\000\000\000\000\000Ä\002\000\000\000\000\000\000D\000\000\000\000\000\000\000D\000\000\000\000\000\000\000\004\000[1352 bytes omitted]
readahead cache hit 11
readahead cache hit 12
readahead cache hit 13
readahead cache hit 14
readahead cache hit 15
readahead cache hit 16
readahead cache hit 17
readahead cache hit 18
readahead cache hit 19
readahead cache hit 20
Sending packet: $vFile:close:5#b5...Packet received: F0
warning: `target:/usr/bin/vim.basic': can't read symbols: File format not recognized.
Sending packet: $Hc-1#09...Packet received: E01
Remote register badly formatted: T0506:0000000000000000;07:10e4ffffff7f0000;10:9060fdf7ff7f0000;thread:p2937.2937;core:4;
here: 00000000;07:10e4ffffff7f0000;10:9060fdf7ff7f0000;thread:p2937.2937;core:4;
wwiv commented
and here's how to attach
set debug remote 1
target remote host:port
wwiv commented
This much works now:
0x00008901 in ?? ()
(gdb) i r
eax 0x0 0
ecx 0x1 1
edx 0x0 0
ebx 0x26c 620
esp 0xc6a 0xc6a
ebp 0x0 0x0
esi 0x0 0
edi 0x0 0
eip 0x8901 0x8901
eflags 0x44 [ PF ZF ]