[lldb-dev] LLDB problems on remote debugging

Ted Woodward via lldb-dev lldb-dev at lists.llvm.org
Thu Apr 16 10:12:25 PDT 2020


Hi Rui,

What you describe is almost identical to what we do with the Hexagon simulator.

There are 2 ways to launch your program - “run” (process launch) and gdb-remote (an attach).

“run” will require some plumbing to launch your simulator the same way that lldb-server/debugserver is launched. That’s fairly involved, so I’m going to skip it for now.


For the attach case, you run your simulator, with the program on the command line. Then in a separate shell you launch lldb with the program, and run the gdb-remote command to connect to it. You’ve got this already, from your message below.

When you attach to the simulator, it comes up stopped, probably at the entrypoint, but that’s dependent on your simulator. To continue, issue a “continue” command. You’ll probably want to set a breakpoint first!

To answer your questions:

  1.  There is no “load” command, but if you make a platform for your target you can add one. Existing platforms (like the remote Linux platform) have the capability to send the binary to the remote server and tell it to run. For Hexagon we don’t do that; instead when we “run” we build a hexagon-sim command line that tells the simulator to load the program. If you’re launching the simulator separately for the attach case it’s easiest to include the binary on the simulator command line.
  2.  No, “gdb-remote” only makes the RSP connection.
  3.  That depends on your simulator. It looks like it just does an attach, and you’ll need to do the continue manually. That’s probably best, because lldb expects the remote gdbserver to be stopped when you connect to it.
  4.  No, but it’s probably easiest.

Ted

From: lldb-dev <lldb-dev-bounces at lists.llvm.org> On Behalf Of Rui Hong via lldb-dev
Sent: Thursday, April 16, 2020 4:31 AM
To: lldb-dev <lldb-dev at lists.llvm.org>
Subject: [EXT] [lldb-dev] LLDB problems on remote debugging

Hi LLDB devs,

I'm working on porting LLDB to work with an existing simulator(which has GDB stub, remote debugging). This simulator used to work with GDB. When using with GDB, the target file(ELF) is loaded by GDB command "load" or "remote put".
>From a LLVM talk project which is very similar to my project, their target file is loaded by the simulator itself(   ./sim a.out   , something like that), and lldb sets breakpoint, use "gdb-remote" command to connect to the simulator, the program starts to run immediately and stop at the breakpoint.
I can't find any lldb command that is equal to "load" in GDB. And right now when I use "gdb-remote" to connect lldb to my simulator, lldb has command line output "Process 10115 stopped,thread #1, stop reason = signal SIGTRAP,frame #0: 0xffffffffffffffff". Does this mean the program has already started to run? I haven't loaded the binary.

To sum my questions:
1. Does lldb has similar command like "load/remote put" in GDB?
2. Does "gdb-remote" command in lldb do the "loading binary" job?
3. Will the program start to run immediately after "gdb-remote" command in lldb?
4. Do I have to let my simulator to load the binary by itself?

Kind regards,
Rui

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20200416/5a0f021a/attachment.html>


More information about the lldb-dev mailing list