Skip to content
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

Add LLDB support to gdb remote debugging stub #326

Merged
merged 4 commits into from Dec 5, 2018

Conversation

knightsc
Copy link
Contributor

With the current code in master (commit db8aaec) when trying to connect via LLDB with gdb-remote 55555 LLDB can't properly figure out the architecture that it's connecting too. This change adds support for LLDB's qHostInfo remote query string. After this change the gdb stub will respond back with a cpu type of ARM, a cpu subtype v4t, the endianness and the size of pointers.

To test do the following on a machine with lldb installed:

  • Start VBA-M. Set GBD->"Break on load"
  • Load .gba -> waits for connection
  • start lldb
  • "gdb-remote 55555"
  • try to "step" or "continue" from lldb

Additionally, after adding support for the qHostInfo there were some stack overflow crashes occurring that preventing things from fully working. Those fixes have been included in this PR as well.

If the packet passed into remotePutPacket was 1024 bytes or
larger then the buffer array would not be large enough to hold
the $, checksum and zero byte written. This now allocates a buffer
of size count + 5 to accommodate these extra characters.
When doing a remote memory read the debugger can ask for any size.
The buffer being allocated however was only 1024 bytes long and the
code in remoteMemoryRead also attempts to write a zero byte at the
end of the array. This code will now take the count of bytes the debugger
is trying to read and allocates a buffer that is count * 2 + 1 large. This is large
enough to hold the $02x formatted hex byte for each byte as well as the zero
byte written at the end.
https://github.com/llvm-mirror/lldb/blob/master/docs/lldb-gdb-remote.txt

The qHostInfo command is listed as a high priority to implement for gdb
stubs that lldb can connect to. Adding support for this command allows
lldb to properly connect with it's `gdb-remote 55555` command and
correctly determine the target and allow debugging.
@rkitover rkitover merged commit b60a634 into visualboyadvance-m:master Dec 5, 2018
@knightsc knightsc deleted the tasks/add-lldb-support branch December 10, 2018 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants