-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First time using gdbstub, lldb stuck during setup #146
Comments
Oh hey, I remember reading about your project at some point. Before I take a closer look, could you re-run your emulator with TRACE level logs for (One of these days I should probably add a Bug template as well... but that's besides the fact) Also, you should configure lldb to log any packets its sending as well. A cursory google search suggests this is as simple as including Once we have those logs, we can start digging into where things might be getting stuck. |
(do I need to enable a feature or something?)
and hangs there. After maybe 5 seconds, it prints
|
In case it's helpful, in the hung state it's attempting to read here
|
Based on some of the lldb logs, it certainly looks like you're getting some response from Could you attempt to connect using regular The command to enable packet debugging in GDB is
What logging frontend are you using in your project?
|
I'm using an in-tree simple logger, which doesn't have any configuration, all my logs are enabled. But it's blocked within gdbstub so I don't expect any of those logs. Is there some mechanism where gdbstub logs the packets it gets? I think maybe I am misunderstanding the intent of the RUST_LOG=trace recommendation. :) |
I thought to try gdb but:
But I just discovered there are arm builds of gdb (targeting elf, but that is irrelevant for remote debugging purposes), and that successfully triggers my code! So it does appear to be something about lldb in particular.
(and the TODO is expected)
|
Yes, this is precisely why I am suggesting you enable trace-level logging in your application :)
gdbstub/src/protocol/recv_packet.rs Line 59 in 927a961
As you can imagine, getting a clear picture of what each party is sending / receiving really helps when it comes to debugging. Good to see that stock As I touch on in #99, If you get to the bottom of it, feel free to let me know (in this thread, or via a new issue), and we can consider landing any missing functionality to unblock your particular usage of In the meantime though, you might just want to stick to using stock |
Ah, I think what I was missing is that gdbstub using the log crate requires my executable to provide some hooks for it to log anything. I will investigate that and get back to you. |
Startup, using the same lldb script as above:
and then after hit
( pair with #146 (comment) ) |
Dug a bit in the llvm github repo (the search is broken, yuck) and found I think the relevant code |
I looked into this a little more. For reasons not clear to me it appears lldb expects there to be an additional process in the mix. See discussion of 'debugserver' on https://lldb.llvm.org/use/remote.html . In practice I think what this means is the initial connection is used to negotiate some metadata (see e.g. qHostInfo above) and then spawn an additional gdb server(!), and lldb in my above trace is failing because it is expecting connection info such as a port in the response which prompts the In all, I conclude supporting lldb might be a decent amount of work. Given we figured out the gdb things here, feel free to close this bug. |
Given that I've definitely confirmed that lldb works with In any case - I'll go ahead and close out this particular issue for now, since there's nothing really actionable here. If you run into any other issues, feel free to open a new issue / start a discussion thread. Cheers! |
I also was misled by the LLDB code in this repo, given that this is lldb straight out of the box without configuration. Their docs mention:
The "platform binary" is the third process involved here, so perhaps it's something about how it determines whether you're using "local debugging" or not. |
Sorry to keep updating this, but I figure it will be helpful for you in case someone else shows up with my questions: I was using the lldb command If I instead use the lldb command |
I attempted to integrate gdbstub into my emulator, following the basics in the (very extensive!) docs. I sprinkled some todo!()s and logs to see which codepaths I'll need to implement next. I'm now trying to run things for the first time and things are failing silently -- lldb is hung, and I see no logs or todos.
You can see my code (mostly a cut'n'paste from the docs) here.
I tried invoking lldb via the script in the above, and here's a trace of what it prints:
and here's what's printed in the process running gdbstub:
and both print nothing further. How can I debug what lldb is attempting? Do you have docs on how you actually should connect a remote debugger for the first time, like which gdb commands to invoke?
(I suspect I may have possibly misunderstood how
run_blocking
is supposed to work?)If I break my gdbstub process in a debugger (oof, debugging a process that is itself a remote debugging target, haha) it appears stuck here:
which indicates there is some protocol communication going on, but none of my code I think.
The text was updated successfully, but these errors were encountered: