[Lldb-commits] [PATCH] D74398: [lldb-server] jThreadsInfo returns stack memory

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 12 14:42:06 PST 2020


jasonmolenda added a comment.

Nice improvement.  debugserver does a similar thing in our jThreadsInfo implementation as well as our ? packet response (T05, etc) where we include the current & caller stack frame, assuming the frame pointer and pc are saved to the stack,

1581545891.235902071 < 627> read packet: $T05thread:d4414d;threads:d4414d;thread-pcs:7fff7149ffd0;00:0000000000000000;01:28f9bfeffe7f0000;02:0200000000000000; [...] memory:0x7ffeefbfe4a0=d0e4bfeffe7f0000f20d2971ff7f0000;memory:0x7ffeefbfe4d0=f0e4bfeffe7f000066cf2971ff7f0000;#00

This gives the thread plans enough information that we can eliminate extra reads while instruction stepping.  We try to do a full stack walk using the same "follow the $fp chain" algorithm for the jThreadsInfo packet for all threads.

It's interesting to send up the entire stack frame contents for frame 0.  There's a good chance we'll need to fetch some/all of this for the selected frame (the frame the user is looking at), but it's probably not helping anything for the other threads.

As Pavel was suggesting, I'd get the size of the inferior's pointers from lldb, and I would read the bytes for the saved frame pointer into a buffer, wrap it in a DataExtractor, and let it do the correct byte swapping.

We'll still have an assumption that the stack moves downward, and that the saved pc and frame pointer are at the start of every stack frame.  It's fine for x86/arm, but we probably have support for an architecture where this isn't true by this point, I wouldn't be surprised.  We'll stop on the first memory read, so if we get back a bogus spilled-fp value, we will stop scanning, so I wouldn't expect it to cause problems, but those targets may not benefit from this.  (debugserver only works on x86/arm, so it didn't have to figure this out.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74398/new/

https://reviews.llvm.org/D74398





More information about the lldb-commits mailing list