[Lldb-commits] [PATCH] D62502: Implement xfer:libraries-svr4:read packet

António Afonso via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon May 27 15:26:37 PDT 2019


aadsm created this revision.
aadsm added reviewers: clayborg, xiaobai.
Herald added subscribers: lldb-commits, krytarowski, srhines.
Herald added a project: LLDB.
aadsm added a parent revision: D62501: Implement GetSharedLibraryInfoAddress.
aadsm added a child revision: D62503: Add ReadCStringFromMemory for faster string reads.

This is the fourth patch to improve module loading in a series that started here (where I explain the motivation and solution): D62499 <https://reviews.llvm.org/D62499>

Implement the `xfer:libraries-svr4` packet by adding a new function that generates the list and then in Handle_xfer I generate the XML for it. The XML is really simple so I'm just using string concatenation because I believe it's more readable than having to deal with a DOM api.

Concerns
--------

- I'm not sure about the having the ELFLinkMap and the SharedLibraryInfo struct in there. I thought about creating a function or class outside of NativeProcessLinux so it could be reusable in other contexts but the core functions need to use ReadMemory so it was not convinent and I guess would have forced me to pass a lambda as a wrapper to ReadMemory. This would introduce more complexity to the code and I'm not sure if it would be worthwhile.

- On Handle_xfer function the backing buffer structure uses MemoryBuffers so I had to create one out of the StreamString response I generate with the XML. This kind of sucks because I'm copying all this data when I usually don't even need it. And if I do need it still sucks because I'm copying something that I just generated right there. I couldn't find a way to generate the XML into a MemoryBuffer (as it requires to know the size before hand) or use another structure that would make this easier. I've thought about changing the backing structure to StringRefs but that object doesn't really own the underlying "const char*" so I can't keep it without copying again. Any suggestions here?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62502

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62502.201590.patch
Type: text/x-patch
Size: 6626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190527/57d51af1/attachment.bin>


More information about the lldb-commits mailing list