[lldb-dev] How can lldb debug a remote bare-metal platform?

cui bixiong via lldb-dev lldb-dev at lists.llvm.org
Mon Sep 18 21:58:20 PDT 2017


Hi Greg:

    It's worked, thank you!, but I still have a question, in GNU-GDB which
provide `load` command to download a ELF file into bare-board, in LLDB
support those features? should I dump a binary file and use lldb "target
module load" to replace 'load' command?

​Best Regards
--cuibixiong​


2017-09-18 23:53 GMT+08:00 Greg Clayton <clayborg at gmail.com>:

> So when launching a GDB server there are two flows:
>
> 1 - When you connect you already have a process
> 2 - You will connect, then launch or attach to a process
>
> LLDB tries to see if there is a process by sending the "qfThreadInfo"
> packet. As you see below, it responds with on character "l" which means
>  "end of the thread list". Since no thread IDs were returned, this makes
> LLDB believe that there is no process on the other end. So later when you
> try to say "process launch", it tries to send the "A" packet which tries to
> launch your program by sending the name of the process file to launch.
>
> There was recently an OpenOCD patch to work around this with:
>
> https://reviews.llvm.org/D37934
>
> This fixed this issue and also made it read both sets of registers via the
> XML target packets.
>
> That should make things work, but it would be better if we modified the
> OpenOCD GDB server to respond with a thread ID when asked about its thread
> with the "qfThreadInfo" packet. Since it is a bare board connection, it
> should respond with "1" (one) to the "qfThreadInfo" packet followed by "l"
> to the next ThreadInfo packet (read GDB protocol docs on this.
>
> Let me know if the patch mentioned above (which is already checked in)
> fixed your issues.
>
>
>
> On Sep 17, 2017, at 3:50 AM, cui bixiong via lldb-dev <
> lldb-dev at lists.llvm.org> wrote:
>
> Hi:
>
>     Currently I porting lldb for Hifive1 (riscv bare board) w/ openocd
> 0.10.0, but it always show "error: Process must be launched."
>
>     I use GNU gdb to remote connect and debugging w/ the same openocd +
> elf, it work OK.
>
>     I want to know how to launch Process in bare board?
>
>     thanks a lot!
>
> $ lldb
> (lldb) log enable gdb-remote packets
> (lldb) target create Build3/riscv-hello.elf
> Current executable set to 'Build3/riscv-hello.elf' (riscv).
> (lldb) gdb-remote 172.27.113.29:3333
> <   1> send ack packet: +
> history[1] tid=0x44c8 <   1> send packet: +
> <   1> read packet: +
> <  19> send SendPacketNoLock 2 packet: $QStartNoAckMode#b0
> <   1> read packet: +
> <   6> read packet: $OK#9a
> <   1> send ack packet: +
> <  41> send SendPacketNoLock 2 packet: $qSupported:xmlRegisters=i386,
> arm,mips#12
> <  80> read packet: $PacketSize=3fff;qXfer:memory-
> map:read+;qXfer:features:read-;QStartNoAckMode+#08
> <  26> send SendPacketNoLock 2 packet: $QThreadSuffixSupported#e4
> <   4> read packet: $#00
> <  27> send SendPacketNoLock 2 packet: $QListThreadsInStopReply#21
> <   4> read packet: $#00
> <  13> send SendPacketNoLock 2 packet: $qHostInfo#9b
> <   4> read packet: $#00
> <  10> send SendPacketNoLock 2 packet: $vCont?#49
> <   4> read packet: $#00
> <  27> send SendPacketNoLock 2 packet: $qVAttachOrWaitSupported#38
> <   4> read packet: $#00
> <  16> send SendPacketNoLock 2 packet: $qProcessInfo#dc
> <   4> read packet: $#00
> <   6> send SendPacketNoLock 2 packet: $qC#b4
> <   7> read packet: $QC0#c4
> <  16> send SendPacketNoLock 2 packet: $qfThreadInfo#bb
> <   5> read packet: $l#6c
> (lldb) thread list
> error: Process must be launched.
> (lldb) b main
> Breakpoint 1: where = riscv-hello.elf`main at hello.c:3, address =
> 0x20400230
> (lldb) thread continue
> error: invalid thread
> (lldb) process launch
> <  38> send SendPacketNoLock 2 packet: $QSetSTDIN:2f6465762f7074732f3
> 43238#b6
> <   4> read packet: $#00
> <  39> send SendPacketNoLock 2 packet: $QSetSTDOUT:2f6465762f7074732f
> 343238#17
> <   4> read packet: $#00
> <  39> send SendPacketNoLock 2 packet: $QSetSTDERR:2f6465762f7074732f
> 343238#08
> <   4> read packet: $#00
> <  21> send SendPacketNoLock 2 packet: $QSetDisableASLR:1#ce
> <   4> read packet: $#00
> <  23> send SendPacketNoLock 2 packet: $QSetDetachOnError:1#f8
> <   4> read packet: $#00
> <  21> send SendPacketNoLock 2 packet: $QLaunchArch:riscv#8b
> <   4> read packet: $#00
> <  33> send SendPacketNoLock 2 packet: $QEnvironment:BINARY_TYPE_HPC=#fd
> <   4> read packet: $#00
> < 115> send SendPacketNoLock 2 packet: $A104,0,2f70726f6a2f6d746b3133
> 3836372f727369632d762f74657374696e672f4275696c64332f72697363
> 762d68656c6c6f2e656c66#6c
> <   4> read packet: $#00
> error: process launch failed: 'A' packet returned an error: -1
>
>
>
> Best Regards
> --cuibixiong
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20170919/57e2ae4e/attachment-0001.html>


More information about the lldb-dev mailing list