[lldb-dev] Accessing physical memory while remote debugging
Daniel Shaulov via lldb-dev
lldb-dev at lists.llvm.org
Sat Nov 24 12:34:36 PST 2018
Hi,
I recently started debugging early OS boot stages. I mainly do it by using
a VM with a gdbstub (I use both vmware and qemu). I am using lldb with the
"gdb-remote" command to connect to the stub.
The one thing that is really missing is the ability to read/write to
physical memory addresses.
I looked a bit at the gdb protocol and it only supports 'm' and 'M' for
reading and writing to virtual memory, and nothing for physical memory.
So I suggest we add a new extensions to the gdb protocol:
QReadPhysicalMemory - works just like 'm', but with physical memory.
QWritePhysicalMemory - works just like 'M', but with physical memory.
I am willing to work on adding support for this in lldb and in qemu. In
fact, the qemu part was so easy and straightforward, that I already
have a branch
ready with the change. <https://github.com/DanielShaulov/qemu/pull/1>
The lldb part is a bit more tricky. At the core, changing
ProcessGDBRemote.cpp:2776, writing "QReadPhysicalMemory" instead of 'm',
is enough to change ALL the reads to physical memory. But we don't want
that. So we need to add a new flag to CommandObjectMemoryRead, and pass it
in CommandObjectMemory.cpp:669, then pass the flag to Process::ReadMemory.
Here it gets a bit tricky, since Process::ReadMemory has a cache, so we
can't just pass the flag to ReadMemoryFromInferior, we need to have a
separate cache for it.
I guess I need a similar change for physical writes, but haven't yet looked
at the code flow.
This will take a bit of time to write, so I wanted to make sure that it's
the right way to go before starting.
So, my questions are:
1. Is this the best way to implement what I want in lldb?
2. Is this a change that the lldb community will accept?
3. I know it's the wrong place to ask, but does anyone know how accepting
the qemu community will be with the patch? Have they ever accepted patches
aimed at making lldb work better with the gdbstub, or is it strictly for
debugging with gdb proper?
Thanks, Daniel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20181124/f897c968/attachment.html>
More information about the lldb-dev
mailing list