[lldb-dev] gdb-remote protocol questions

Alexander Zhang via lldb-dev lldb-dev at lists.llvm.org
Sat Jan 25 15:08:13 PST 2020


Hi,

I've been implementing a basic RSP protocol server for remotely debugging a
MIPS simulator, and have been having some trouble getting certain lldb
features to work there, in particular backtraces (bt) and instruction step
over (ni). Does someone know what packets these commands rely on to work?
I've attached some communication logs, and if it helps my code is at
https://github.com/CQCumbers/nmulator/blob/master/src/debugger.h

Please forgive me if this isn't the right place to ask - I know this isn't
directly part of lldb development but I've tried several other places and
haven't been able to find anyone familiar with the subject.

Also, just a user question, but is there a way to show register values in
hex format without leading zeros?

Thanks,
Alexander
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20200125/edd490fd/attachment.html>
-------------- next part --------------
(lldb) log enable gdb-remote all
(lldb) gdb-remote 4343
 ProcessGDBRemote::ConnectToDebugserver Connecting to connect://localhost:4343
 <   1> send packet: +
 history[1] tid=0x0307 <   1> send packet: +
 <   7> read packet: $S05#b8
 <   1> send packet: +
 <  19> send packet: $QStartNoAckMode#b0
 <   1> read packet: +
 <   4> read packet: $#00
 <   1> send packet: +
 <  41> send packet: $qSupported:xmlRegisters=i386,arm,mips#12
 <   1> read packet: +
 <  19> read packet: $PacketSize=2047#fd
 <   1> send packet: +
 <  26> send packet: $QThreadSuffixSupported#e4
 <   1> read packet: +
 <   4> read packet: $#00
 <   1> send packet: +
 <  27> send packet: $QListThreadsInStopReply#21
 <   1> read packet: +
 <   4> read packet: $#00
 <   1> send packet: +
 <  13> send packet: $qHostInfo#9b
 <   1> read packet: +
 <  61> read packet: $triple:6d6970732d6c696e75782d676e75;ptrsize:8;endian:big;#d1
 <   1> send packet: +
 GDBRemoteCommunicationClient::GetHostInfo parsed host architecture as mips, triple as mips-unknown-linux-gnu from triple text mips-linux-gnu
 <  10> send packet: $vCont?#49
 <   1> read packet: +
 <   4> read packet: $#00
 <   1> send packet: +
 <  27> send packet: $qVAttachOrWaitSupported#38
 <   1> read packet: +
 <   4> read packet: $#00
 <   1> send packet: +
 <  23> send packet: $QEnableErrorStrings#8c
 <   1> read packet: +
 <   4> read packet: $#00
 <   1> send packet: +
 ProcessGDBRemote::StartAsyncThread ()
 <  16> send packet: $qProcessInfo#dc
 ProcessGDBRemote::AsyncThread (arg = 0x7f8eff006218, pid = 0) thread starting...
 ProcessGDBRemote::AsyncThread (arg = 0x7f8eff006218, pid = 0) listener.WaitForEvent (NULL, event_sp)...
 <   1> read packet: +
 <  46> read packet: $triple:6d6970732d6c696e75782d676e75;pid:1;#e0
 <   1> send packet: +
 <   5> send packet: $?#3f
 <   1> read packet: +
 <   7> read packet: $S05#b8
 <   1> send packet: +
 <  18> send packet: $qRegisterInfo0#72
 <   1> read packet: +
 <  57> read packet: $name:r0;bitsize:64;offset:0;encoding:sint;format:hex;#7a
 <   1> send packet: +
 <  18> send packet: $qRegisterInfo1#73
 <   1> read packet: +
 <  57> read packet: $name:at;bitsize:64;offset:8;encoding:sint;format:hex;#b5
 <   1> send packet: +
 <  18> send packet: $qRegisterInfo2#74
 <   1> read packet: +
 <  58> read packet: $name:v0;bitsize:64;offset:16;encoding:sint;format:hex;#b5
 <   1> send packet: +
 <  18> send packet: $qRegisterInfo3#75
 <   1> read packet: +
 <  58> read packet: $name:v1;bitsize:64;offset:24;encoding:sint;format:hex;#b5
 <   1> send packet: +
 <  18> send packet: $qRegisterInfo4#76
 <   1> read packet: +
 <  58> read packet: $name:a0;bitsize:64;offset:32;encoding:sint;format:hex;#9e
 <   1> send packet: +
 <  18> send packet: $qRegisterInfo5#77
 <   1> read packet: +
 <  58> read packet: $name:a1;bitsize:64;offset:40;encoding:sint;format:hex;#9e
 <   1> send packet: +
 <  18> send packet: $qRegisterInfo6#78
 <   1> read packet: +
 <  58> read packet: $name:a2;bitsize:64;offset:48;encoding:sint;format:hex;#a7
 <   1> send packet: +
 <  18> send packet: $qRegisterInfo7#79
 <   1> read packet: +
 <  58> read packet: $name:a3;bitsize:64;offset:56;encoding:sint;format:hex;#a7
 <   1> send packet: +
 <  18> send packet: $qRegisterInfo8#7a
 <   1> read packet: +
 <  58> read packet: $name:t0;bitsize:64;offset:64;encoding:sint;format:hex;#b6
 <   1> send packet: +
 <  18> send packet: $qRegisterInfo9#7b
 <   1> read packet: +
 <  58> read packet: $name:t1;bitsize:64;offset:72;encoding:sint;format:hex;#b6
 <   1> send packet: +
 <  18> send packet: $qRegisterInfoa#a3
 <   1> read packet: +
 <  58> read packet: $name:t2;bitsize:64;offset:80;encoding:sint;format:hex;#b6
 <   1> send packet: +
 <  18> send packet: $qRegisterInfob#a4
 <   1> read packet: +
 <  58> read packet: $name:t3;bitsize:64;offset:88;encoding:sint;format:hex;#bf
 <   1> send packet: +
 <  18> send packet: $qRegisterInfoc#a5
 <   1> read packet: +
 <  58> read packet: $name:t4;bitsize:64;offset:96;encoding:sint;format:hex;#bf
 <   1> send packet: +
 <  18> send packet: $qRegisterInfod#a6
 <   1> read packet: +
 <  59> read packet: $name:t5;bitsize:64;offset:104;encoding:sint;format:hex;#e6
 <   1> send packet: +
 <  18> send packet: $qRegisterInfoe#a7
 <   1> read packet: +
 <  59> read packet: $name:t6;bitsize:64;offset:112;encoding:sint;format:hex;#e6
 <   1> send packet: +
 <  18> send packet: $qRegisterInfof#a8
 <   1> read packet: +
 <  59> read packet: $name:t7;bitsize:64;offset:120;encoding:sint;format:hex;#e6
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo10#a3
 <   1> read packet: +
 <  59> read packet: $name:s0;bitsize:64;offset:128;encoding:sint;format:hex;#e6
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo11#a4
 <   1> read packet: +
 <  59> read packet: $name:s1;bitsize:64;offset:136;encoding:sint;format:hex;#e6
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo12#a5
 <   1> read packet: +
 <  59> read packet: $name:s2;bitsize:64;offset:144;encoding:sint;format:hex;#e6
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo13#a6
 <   1> read packet: +
 <  59> read packet: $name:s3;bitsize:64;offset:152;encoding:sint;format:hex;#e6
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo14#a7
 <   1> read packet: +
 <  59> read packet: $name:s4;bitsize:64;offset:160;encoding:sint;format:hex;#e6
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo15#a8
 <   1> read packet: +
 <  59> read packet: $name:s5;bitsize:64;offset:168;encoding:sint;format:hex;#ef
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo16#a9
 <   1> read packet: +
 <  59> read packet: $name:s6;bitsize:64;offset:176;encoding:sint;format:hex;#ef
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo17#aa
 <   1> read packet: +
 <  59> read packet: $name:s7;bitsize:64;offset:184;encoding:sint;format:hex;#ef
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo18#ab
 <   1> read packet: +
 <  59> read packet: $name:t8;bitsize:64;offset:192;encoding:sint;format:hex;#f0
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo19#ac
 <   1> read packet: +
 <  59> read packet: $name:t9;bitsize:64;offset:200;encoding:sint;format:hex;#e7
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo1a#d4
 <   1> read packet: +
 <  59> read packet: $name:k0;bitsize:64;offset:208;encoding:sint;format:hex;#dd
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo1b#d5
 <   1> read packet: +
 <  59> read packet: $name:k1;bitsize:64;offset:216;encoding:sint;format:hex;#dd
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo1c#d6
 <   1> read packet: +
 <  59> read packet: $name:gp;bitsize:64;offset:224;encoding:sint;format:hex;#17
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo1d#d7
 <   1> read packet: +
 <  70> read packet: $name:sp;bitsize:64;offset:232;encoding:sint;format:hex;generic:sp;#57
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo1e#d8
 <   1> read packet: +
 <  70> read packet: $name:fp;bitsize:64;offset:240;encoding:sint;format:hex;generic:fp;#3c
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo1f#d9
 <   1> read packet: +
 <  70> read packet: $name:ra;bitsize:64;offset:248;encoding:sint;format:hex;generic:ra;#3e
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo20#a4
 <   1> read packet: +
 <  70> read packet: $name:pc;bitsize:64;offset:256;encoding:sint;format:hex;generic:pc;#3d
 <   1> send packet: +
 <  19> send packet: $qRegisterInfo21#a5
 <   1> read packet: +
 <   7> read packet: $E45#ae
 <   1> send packet: +
 <  16> send packet: $qfThreadInfo#bb
 <   1> read packet: +
 <   7> read packet: $m-1#cb
 <   1> send packet: +
 <  16> send packet: $qsThreadInfo#c8
 <   1> read packet: +
 <   5> read packet: $l#6c
 <   1> send packet: +
 <   7> send packet: $Hg1#e0
 <   1> read packet: +
 <   6> read packet: $OK#9a
 <   1> send packet: +
 <   6> send packet: $p0#a0
 <   1> read packet: +
 <  20> read packet: $0000000000000000#00
 <   1> send packet: +
 ProcessGDBRemote::DoConnectRemote pid 1: normalizing target architecture initial triple: mips-unknown-linux-gnu (GetTarget().GetArchitecture().IsValid() true, m_gdb_comm.GetHostArchitecture().IsValid(): true)
 ProcessGDBRemote::DoConnectRemote pid 1: normalized target architecture triple: mips-unknown-linux-gnu
 ProcessGDBRemote::DidLaunchOrAttach()
 ProcessGDBRemote::DidLaunchOrAttach gdb-remote had process architecture, using mips mips-unknown-linux-gnu
 ProcessGDBRemote::DidLaunchOrAttach analyzing target arch, currently mips mips-unknown-linux-gnu
 ProcessGDBRemote::DidLaunchOrAttach final target arch after adjustments for remote architecture: mips mips-unknown-linux-gnu
 <  26> send packet: $qStructuredDataPlugins#02
 <   1> read packet: +
 <   4> read packet: $#00
 <   1> send packet: +
 <  16> send packet: $qfThreadInfo#bb
 <   1> read packet: +
 <   7> read packet: $m-1#cb
 <   1> send packet: +
 <  16> send packet: $qsThreadInfo#c8
 <   1> read packet: +
 <   5> read packet: $l#6c
 <   1> send packet: +
 <  16> send packet: $qfThreadInfo#bb
 <   1> read packet: +
 <   7> read packet: $m-1#cb
 <   1> send packet: +
 <  16> send packet: $qsThreadInfo#c8
 <   1> read packet: +
 <   5> read packet: $l#6c
 <   1> send packet: +
 <   7> send packet: $p20#d2
 <   1> read packet: +
 <  20> read packet: $00000000a4000040#39
 <   1> send packet: +
 <  30> send packet: $qMemoryRegionInfo:a4000040#cd
 <   1> read packet: +
 <   4> read packet: $#00
 <   1> send packet: +
 <   7> send packet: $p1d#05
 <   1> read packet: +
 <  20> read packet: $ffffffffa4001ff0#52
 <   1> send packet: +
 <  16> send packet: $jThreadsInfo#c1
 <   1> read packet: +
(lldb)  <   4> read packet: $#00
 <   1> send packet: +
(lldb)  <  24> send packet: $jThreadExtendedInfo:#b9
 <   1> read packet: +
 <   4> read packet: $#00
 <   1> send packet: +
 <   8> send packet: $x0,0#04
 <   1> read packet: +
 <   4> read packet: $#00
 <   1> send packet: +
 <  17> send packet: $ma4000000,200#e0
 <   1> read packet: +
 <1028> read packet: $803712400000000f80025c000000144c77db03f3bea05d73000000000000000000000000000000000000000000000000000000000000000000000000000000004080680040804800408058003c08a470250800008d09000c152000ed0000000027bdffe8afb30000afb40004afb50008afb6000cafb700103c08a470250800003c0aa3f83c0ba3f03c0ca430258c000034090040ad09000424111f40000000002231ffff1620fffd00000000ad00000834090014ad09000cad00000024110004000000002231ffff1620fffd000000003409000ead090000241100202231ffff1620fffe3409010fad8900003c09180835292838ad490008ad4000143c098000ad49000400006825000070253c0fa3f00000c0253c19a3f03c16a0000000b8253c06a3f03c07a000000090253c14a00027bdffb803a0f0253c10a4308e1000043c110101263101011611000500000000241002003571400010000003000000002410040035718000ae2e000425f5000c0d0001de000000001040003800000000afa2000024092000ad8900008deb00003c08f0ff01685824afab000423bd000824091000ad8900003c08b0191568000c000000003c0808000308c0200330c8200330c8203c08002002c8b0200288a020001290402252000110000003000000003c0800100288a02024082000ad8800008de900248dfa000024081000ad880000#9d
 <   1> send packet: +
Process 1 stopped
* thread #1, stop reason = signal SIGTRAP
    frame #0: 0xa4000040
->  0xa4000040: mtc0   $zero, $13, 0x0
    0xa4000044: mtc0   $zero, $9, 0x0
    0xa4000048: mtc0   $zero, $11, 0x0
    0xa400004c: lui    $8, 0xa470
(lldb) breakpoint set -a 0x8002c9ec
 ProcessGDBRemote::EnableBreakpointSite (size_id = 1) address = 0x8002c9ec
 <  17> send packet: $Z0,8002c9ec,4#44
 <   1> read packet: +
 <   6> read packet: $OK#9a
 <   1> send packet: +
Breakpoint 1: address = 0x8002c9ec
(lldb) continue
 Check if need to update ignored signals
 ProcessGDBRemote::Resume()
 <   8> send packet: $Hc-1#09
 <   1> read packet: +
 <   6> read packet: $OK#9a
 <   1> send packet: +
 ProcessGDBRemote::AsyncThread (arg = 0x7f8eff006218, pid = 1) Got an event of type: 1...
 ProcessGDBRemote::AsyncThread (arg = 0x7f8eff006218, pid = 1) got eBroadcastBitAsyncContinue: c
 GDBRemoteClientBase::ContinueLock::lock() resuming with c
 <   5> send packet: $c#63
 <   1> read packet: +
Process 1 resuming
(lldb)  <   7> read packet: $S05#b8
 <   1> send packet: +
 GDBRemoteClientBase::SendContinuePacketAndWaitForResponse () got packet: S05
 ProcessGDBRemote::AsyncThread (arg = 0x7f8eff006218, pid = 1) listener.WaitForEvent (NULL, event_sp)...
 <  16> send packet: $qfThreadInfo#bb
 <   1> read packet: +
 <   7> read packet: $m-1#cb
 <   1> send packet: +
 <  16> send packet: $qsThreadInfo#c8
 <   1> read packet: +
 <   5> read packet: $l#6c
 <   1> send packet: +
 <  16> send packet: $qfThreadInfo#bb
 <   1> read packet: +
 <   7> read packet: $m-1#cb
 <   1> send packet: +
 <  16> send packet: $qsThreadInfo#c8
 <   1> read packet: +
 <   5> read packet: $l#6c
 <   1> send packet: +
 <   7> send packet: $Hg1#e0
 <   1> read packet: +
 <   6> read packet: $OK#9a
 <   1> send packet: +
 <   7> send packet: $p20#d2
 <   1> read packet: +
 <  20> read packet: $000000008002c9ec#ae
 <   1> send packet: +
 <   7> send packet: $p1d#05
 <   1> read packet: +
 <  20> read packet: $ffffffff8005a3b8#2b
 <   1> send packet: +
 <  17> send packet: $m8002c800,200#f0
 <   1> read packet: +
 <1028> read packet: $2463d7708c6a00008c6b00048c6c00088c6d000cac4a0000ac4b0004ac4c0008ac4d000c3c028000344201803c0380032463d7708c6a00008c6b00048c6c00088c6d000cac4a0000ac4b0004ac4c0008ac4d000c3c0480000c00bbfc240501903c0480000c00bbdc240501900c00b194000000000c00c6f0000000000c00c6d8000000003c0280048c4200003c0380048c630004004040210060482100083040000927c200c430250009384000e3382100e3282b00c2302100c5302100c0202100e02821240600000c00dd80240700043c018004ac2200003c018004ac2300043c0280008c42030c14400005000000003c0480002484031c0c00a6f8240500403c0280008c42030014400006000000003c0202f53442b2d23c0180040800b257ac2200083c0280008c4203002403000214430006000000003c0202e63442025c3c0180040800b257ac2200083c0202e63442d3543c018004ac2200080c00c500000000003043100010600007000000000800b260000000000800b262000000000800b25c00000000240200013c01a450ac22000824023fff3c01a450ac2200102402000f3c01a450ac22001403c0e8218fbf001c8fbe001803e0000827bd002027bdffe8afbf0014afbe00100c00b55703a0f02110400005000000000c00b4c3000000000800b28d000000000c00b3e30000000010400005000000000c00b34f#cf
 <   1> send packet: +
Process 1 stopped
* thread #1, stop reason = breakpoint 1.1
    frame #0: 0x8002c9ec
->  0x8002c9ec: jal    0x2cf8c
    0x8002c9f0: nop    
    0x8002c9f4: beqz   $2, 0x18
    0x8002c9f8: nop    
(lldb) nexti
 Check if need to update ignored signals
 ProcessGDBRemote::DisableBreakpointSite (site_id = 1) addr = 0x8002c9ec
 <  17> send packet: $z0,8002c9ec,4#64
 <   1> read packet: +
 <   6> read packet: $OK#9a
 <   1> send packet: +
 ProcessGDBRemote::Resume()
 ProcessGDBRemote::AsyncThread (arg = 0x7f8eff006218, pid = 1) Got an event of type: 1...
 ProcessGDBRemote::AsyncThread (arg = 0x7f8eff006218, pid = 1) got eBroadcastBitAsyncContinue: s
 GDBRemoteClientBase::ContinueLock::lock() resuming with s
 <   5> send packet: $s#73
 <   1> read packet: +
(lldb)  <   7> read packet: $S05#b8
 <   1> send packet: +
 GDBRemoteClientBase::SendContinuePacketAndWaitForResponse () got packet: S05
 ProcessGDBRemote::AsyncThread (arg = 0x7f8eff006218, pid = 1) listener.WaitForEvent (NULL, event_sp)...
 <  16> send packet: $qfThreadInfo#bb
 <   1> read packet: +
 <   7> read packet: $m-1#cb
 <   1> send packet: +
 <  16> send packet: $qsThreadInfo#c8
 <   1> read packet: +
 <   5> read packet: $l#6c
 <   1> send packet: +
 <  16> send packet: $qfThreadInfo#bb
 <   1> read packet: +
 <   7> read packet: $m-1#cb
 <   1> send packet: +
 <  16> send packet: $qsThreadInfo#c8
 <   1> read packet: +
 <   5> read packet: $l#6c
 <   1> send packet: +
 <   7> send packet: $Hg1#e0
 <   1> read packet: +
 <   6> read packet: $OK#9a
 <   1> send packet: +
 <   7> send packet: $p20#d2
 <   1> read packet: +
 <  20> read packet: $000000008002cf8c#ae
 <   1> send packet: +
 <   7> send packet: $p1d#05
 <   1> read packet: +
 <  20> read packet: $ffffffff8005a3b8#2b
 <   1> send packet: +
 ProcessGDBRemote::EnableBreakpointSite (size_id = 1) address = 0x8002c9ec
 <  17> send packet: $Z0,8002c9ec,4#44
 <   1> read packet: +
 <   6> read packet: $OK#9a
 <   1> send packet: +
 <  17> send packet: $m8002ce00,200#1d
 <   1> read packet: +
 <1028> read packet: $8c630000ac4300008fc2001424430008afc300148fc2001824430008afc300188fc2001824430004afc300188fc3001424640004afc400148c630000ac4300008fc2001824430004afc300188fc3001424640004afc400148c630000ac4300008fc2001824430004afc300188fc3001424640004afc400148c630000ac4300003c048000348401800c00bbfc240500243c048000348401800c00bbdc24050024240200013c018005ac2276a08fc200248c430000306200101440002b000000008fc30020246200048c430000afc3001c8fc2001c3c03bff01043001b000000008fc2001c3c03200000431025afc2002c24020800afc200303c02bff0afc200288fc2003014400003000000000800b3d2000000008fc2002c24430004afc3002c8fc3002824640004afc400288c630000ac4300008fc300302462ffff004018210800b3c0afc300308fc2001c24430008afc300108fc200103c044b4d348443000040f809000028213c0280032442cadc3c018004ac22001403c0e8218fbf003c8fbe003803e0000827bd004027bdfff0afbe000803a0f0213c02bff0afc200008fc200008c4300003c024b4d3442430014620012000000003c02bff034420010afc200008fc200008c4300003c02b0ff3442b00014620005000000000800b401240200010800b3fd000000000800b401000010210800b401000000000800b401#fd
 <   1> send packet: +
Process 1 stopped
* thread #1, stop reason = instruction step over
    frame #0: 0x8002cf8c
->  0x8002cf8c: addiu  $sp, $sp, -0x10
    0x8002cf90: sw     $fp, 0x8($sp)
    0x8002cf94: move   $fp, $sp
    0x8002cf98: lui    $2, 0xbff0
(lldb) bt
* thread #1, stop reason = instruction step over
  * frame #0: 0x8002cf8c
(lldb) exit
Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] y
 ProcessGDBRemote::DisableBreakpointSite (site_id = 1) addr = 0x8002c9ec
 <  17> send packet: $z0,8002c9ec,4#64
 <   1> read packet: +
 <   6> read packet: $OK#9a
 <   1> send packet: +
 ProcessGDBRemote::DoDestroy()
 <   5> send packet: $k#6b
 <   1> read packet: +
 ProcessGDBRemote::DoDestroy - failed to send k packet
 ProcessGDBRemote::StopAsyncThread ()
 ProcessGDBRemote::AsyncThread (arg = 0x7f8eff006218, pid = 1) Got an event of type: 2...
 ProcessGDBRemote::AsyncThread (arg = 0x7f8eff006218, pid = 1) got eBroadcastBitAsyncThreadShouldExit...
 ProcessGDBRemote::AsyncThread (arg = 0x7f8eff006218, pid = 1) thread exiting...
 ProcessGDBRemote::StopAsyncThread ()
 ProcessGDBRemote::StopAsyncThread () - Called when Async thread was not running.


More information about the lldb-dev mailing list