Commit 20d5c1a8 authored by David Schulz's avatar David Schulz Committed by hjk

Cdbext: Add option to return alphabetically sorted locals.

Change-Id: Ida0e8aec41bade10ad1e3ac517812a3a8c120473
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent ec4d242b
......@@ -124,13 +124,14 @@ static const CommandDescription commandDescriptions[] = {
"-c complex dumpers"},
{"locals",
"Prints local variables of symbol group in GDBMI or debug format",
"[-t token] [-v] [T formats] [-I formats] [-f debugfilter] [-c] [-h] [-d]\n[-e expand-list] [-u uninitialized-list]\n"
"[-t token] [-v] [T formats] [-I formats] [-f debugfilter] [-a] [-c] [-h] [-d]\n[-e expand-list] [-u uninitialized-list]\n"
"[-W] [-w watch-iname watch-expression] <frame-number> [iname]\n"
"-h human-readable output\n"
"-v increase verboseness of dumping\n"
"-d debug output\n"
"-f debug_filter\n"
"-c complex dumpers\n"
"-a sort alphabetically\n"
"-e expand-list Comma-separated list of inames to be expanded beforehand\n"
"-u uninitialized-list Comma-separated list of uninitialized inames\n"
"-I formatmap map of 'hex-encoded-iname=typecode'\n"
......@@ -372,6 +373,9 @@ DumpCommandParameters::ParseOptionResult DumpCommandParameters::parseOption(Stri
case 'c':
dumpParameters.dumpFlags |= DumpParameters::DumpComplexDumpers;
break;
case 'a':
dumpParameters.dumpFlags |= DumpParameters::DumpAlphabeticallySorted;
break;
case 'f':
if (options->size() < 2)
return Error;
......
......@@ -167,7 +167,12 @@ bool AbstractSymbolGroupNode::accept(SymbolGroupNodeVisitor &visitor,
case SymbolGroupNodeVisitor::VisitSkipChildren:
break;
case SymbolGroupNodeVisitor::VisitContinue: {
const AbstractSymbolGroupNodePtrVector &c = children();
AbstractSymbolGroupNodePtrVector c = children();
if (visitor.sortChildrenAlphabetically()) {
std::sort(c.begin(), c.end(), [](AbstractSymbolGroupNode *a, AbstractSymbolGroupNode *b) {
return a->name() < b->name();
});
}
const unsigned childCount = unsigned(c.size());
for (unsigned i = 0; i < childCount; ++i)
if (c.at(i)->accept(visitor, fullIname, i, childDepth))
......
......@@ -80,11 +80,13 @@ struct DumpParameters
enum DumpFlags
{
DumpHumanReadable = 0x1,
DumpComplexDumpers = 0x2
DumpComplexDumpers = 0x2,
DumpAlphabeticallySorted = 0x4
};
DumpParameters();
bool humanReadable() const { return dumpFlags & DumpHumanReadable; }
bool isAlphabeticallySorted() const { return (dumpFlags & DumpAlphabeticallySorted) != 0; }
// Helper to decode format option arguments.
static FormatMap decodeFormatArgument(const std::string &f, bool isHex);
......@@ -398,6 +400,7 @@ protected:
unsigned child, unsigned depth) = 0;
// Helper for formatting output.
virtual void childrenVisited(const AbstractSymbolGroupNode * /* node */, unsigned /* depth */) {}
virtual bool sortChildrenAlphabetically() const { return false; }
};
class DebugSymbolGroupNodeVisitor : public SymbolGroupNodeVisitor {
......@@ -440,6 +443,7 @@ protected:
const std::string &fullIname,
unsigned child, unsigned depth);
virtual void childrenVisited(const AbstractSymbolGroupNode * node, unsigned depth);
bool sortChildrenAlphabetically() const override { return m_parameters.isAlphabeticallySorted(); }
private:
std::ostream &m_os;
......
......@@ -992,6 +992,8 @@ void CdbEngine::addLocalsOptions(ByteArrayInputStream &str) const
str << blankSeparator << "-v";
if (boolSetting(UseDebuggingHelpers))
str << blankSeparator << "-c";
if (boolSetting(SortStructMembers))
str << blankSeparator << "-a";
const QByteArray typeFormats = watchHandler()->typeFormatRequests();
if (!typeFormats.isEmpty())
str << blankSeparator << "-T " << typeFormats;
......@@ -1473,6 +1475,11 @@ void CdbEngine::updateLocals(bool newFrame)
[this, newFrame](const CdbResponse &r) { handleLocals(r, newFrame); });
}
void CdbEngine::updateAll()
{
updateLocals(true);
}
void CdbEngine::selectThread(ThreadId threadId)
{
if (!threadId.isValid() || threadId == threadsHandler()->currentThread())
......
......@@ -248,6 +248,7 @@ private:
NormalizedSourceFileName sourceMapNormalizeFileNameFromDebugger(const QString &f);
void updateLocalVariable(const QByteArray &iname);
void updateLocals(bool forNewStackFrame);
void updateAll() override;
int elapsedLogTime() const;
void addLocalsOptions(ByteArrayInputStream &s) const;
unsigned parseStackTrace(const GdbMi &data, bool sourceStepInto);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment