[Lldb-commits] [PATCH] D122882: Add JSONGenerator::DumpBinaryEscaped method in debugserver, update most callers to use this, skip escaping step

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 1 01:48:44 PDT 2022

jasonmolenda created this revision.
jasonmolenda added reviewers: JDevlieghere, jingham.
jasonmolenda added a project: LLDB.
Herald added a project: All.
jasonmolenda requested review of this revision.
Herald added a subscriber: lldb-commits.

Most packets which return JSON use JSONGenerator::Dump to print the string representation of the data, and then pass that string to another method to escape the #, $, }, and * characters which have special meaning in the gdb remote serial protocol.  This generate-then-escape two step process involves duplicating the entire string, and for large data, can result in a lot of memory use.

This patch adds JSONGenerator::DumpBinaryEscaped methods for those cases where this is needed.  The Dictionary, Array, and String methods involve duplicating the existing Dump methods, mostly to call the corresponding DumpBinaryEscaped methods on their children.  The other JSON types do not need escaping, and call the regular Dump methods.

This is the follow on patch to https://reviews.llvm.org/D122848 , the two of them get us down from 3 string copies being held in heap, plus the JSON object tree, to the JSON object tree and one copy.  For a large list of shared libraries, it can add up to quite a bit of memory use, and debugserver should try to be low impact on the system.

  rG LLVM Github Monorepo



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122882.419668.patch
Type: text/x-patch
Size: 6195 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220401/258936f5/attachment-0001.bin>

More information about the lldb-commits mailing list