qiling
qiling copied to clipboard
Report memory mapping to GDB client
Is your feature request related to a problem? Please describe.
gdb command info proc mapping returns empty.

Describe the solution you'd like
There seems to be a stub here that may make it easier to implement this feature. maybe make a little bit change to ql.mem.show_mapinfo() could emulate a procmaps file?
https://github.com/qilingframework/qiling/blob/67d35579a78390cf975d81a96c08e361f086ba9e/qiling/debugger/gdbserver/gdbserver.py#L631-L632
I've never played with gdb protocol. I'll send a PR if I figure it out 😅
the thing is we dont have /proc in qiling. To be honest, i still not too sure if we need to emulate that.
or we should figure out why do we need /proc and how we can emulate it.
At least providing memory mapping information is friendly to debuggers.
I have a hacky solution here, https://github.com/ttimasdf/qiling/commit/5142844d9715328462f4917b4e80e40a35938711 . But I'm not sure it's good enough for PR. This patch should be used along with #325 or gdb will crash because of that bug.
Test case:
qltool run -f examples/rootfs/arm_linux/bin/arm_hello_static \
--rootfs examples/rootfs/arm_linux --gdb 127.0.0.1:9999
Before:


After:


PS: I'm trying to add this feature because it's essential for a gdb plugin(ret-sync) to work (also stops gef from complaining), very personal...
i guess u should just parse show_mapinfo. and rearrange in gdb.
this way u dont have to touch ql.os.memory?
maybe u can update and trow in a PR ?
I'm getting to update this fix. There's a problem. How to get the return value of show_mapinfo? It's printed to console/log file. So one way or another it seems we need to modify ql.os.memory. IMHO i'd prefer to add another method to make it reusable.
https://github.com/qilingframework/qiling/blob/078996ce2dbe61c3da0b9b352634876d0e38be0f/qiling/os/memory.py#L119-L136
If you look at the code, show_mapinfo() just parse ql.mem.map_info()
So you can just parse ql.mem.map_info()
@ttimasdf a PR would be super nice 💯.
Will you be able to try the latest version of Qiling and see if you still face same issue. There is lots of rework since 2020. Feel free to open a new issue if you have any similar problem.