Page MenuHomePhabricator

Add LogDump methods to lldb_private::StringList to ease printing of iterable string containers
ClosedPublic

Authored by ldrumm on Dec 24 2015, 10:38 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

ldrumm updated this revision to Diff 43609.Dec 24 2015, 10:38 AM
ldrumm retitled this revision from to Add LogDump methods to lldb_private::StringList to ease printing of iterable string containers.
ldrumm updated this object.
ldrumm added reviewers: clayborg, jingham.
ldrumm updated this revision to Diff 43613.Dec 24 2015, 12:03 PM
ldrumm abandoned this revision.Dec 24 2015, 12:17 PM
ldrumm updated this revision to Diff 43615.Dec 24 2015, 12:21 PM
clayborg requested changes to this revision.Jan 4 2016, 11:14 AM
clayborg edited edge metadata.

See inlined comments.

source/Core/StringList.cpp
365–370 ↗(On Diff #43615)

Since this is going out to a Log, we should have all the strings together in one log line. I would suggest making a local StreamString object and using StreamString::Printf() instead of the "log->Debug" calls, and then output the stream all at once:

StreamString strm;
if (name)
    strm.Printf("Begin %s:\n", name);
for (const auto &s : m_strings)
{
    strm.Indent();
    strm.Printf("%s\n", s.c_str());
}
if (name)
    strm.Printf("End %s.\n", name);
log->Debug("%s", strm.GetData());

Otherwise we might get the strings out of order and intermixed with other log lines.

This revision now requires changes to proceed.Jan 4 2016, 11:14 AM
ldrumm updated this revision to Diff 44000.Jan 5 2016, 7:57 AM
ldrumm edited edge metadata.
ldrumm added a subscriber: lldb-commits.
clayborg accepted this revision.Jan 5 2016, 10:05 AM
clayborg edited edge metadata.
This revision is now accepted and ready to land.Jan 5 2016, 10:05 AM
This revision was automatically updated to reflect the committed changes.