Debugger: Combine some watch related GDB and LLDB code paths

Change-Id: I20e5f6f04418c931354a07bc3597f6982fcaf942
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2015-02-12 11:31:02 +01:00
parent cf21092ec5
commit f91cc66f9a
7 changed files with 52 additions and 73 deletions

View File

@@ -250,21 +250,9 @@ class Dumper(DumperBase):
self.resultVarName = args.get("resultvarname", "") self.resultVarName = args.get("resultvarname", "")
self.expandedINames = set(args.get("expanded", [])) self.expandedINames = set(args.get("expanded", []))
self.stringCutOff = int(args.get("stringcutoff", 10000)) self.stringCutOff = int(args.get("stringcutoff", 10000))
self.displayStringLimit = int(args.get("displaystringlimit", 10000)) self.displayStringLimit = int(args.get("displaystringlimit", 100))
self.typeformats = args.get("typeformats", {})
self.typeformats = {} self.formats = args.get("formats", {})
for f in args.get("typeformats", "").split(","):
pos = f.find("=")
if pos != -1:
typeName = self.hexdecode(f[0:pos])
self.typeformats[typeName] = int(f[pos+1:])
self.formats = {}
for f in args.get("formats", "").split(","):
pos = f.find("=")
if pos != -1:
self.formats[f[0:pos]] = int(f[pos+1:])
self.watchers = args.get("watchers", {}) self.watchers = args.get("watchers", {})
self.qmlcontext = int(args.get("qmlcontext", "0")) self.qmlcontext = int(args.get("qmlcontext", "0"))
self.useDynamicType = int(args.get("dyntype", "0")) self.useDynamicType = int(args.get("dyntype", "0"))

View File

@@ -1634,29 +1634,14 @@ class Dumper(DumperBase):
self.report('success="%d",output="%s",error="%s"' % (success, output, error)) self.report('success="%d",output="%s",error="%s"' % (success, output, error))
def updateData(self, args): def updateData(self, args):
if 'expanded' in args: self.expandedINames = set(args.get('expanded', []))
self.expandedINames = set(args['expanded'].split(',')) self.autoDerefPointers = int(args.get('autoderef', '0'))
if 'autoderef' in args: self.useDynamicType = int(args.get('dyntype', '0'))
self.autoDerefPointers = int(args['autoderef']) self.useFancy = int(args.get('fancy', '0'))
if 'dyntype' in args: self.passExceptions = int(args.get('passexceptions', '0'))
self.useDynamicType = int(args['dyntype']) self.currentWatchers = args.get('watchers', {})
if 'fancy' in args: self.typeformats = args.get("typeformats", {})
self.useFancy = int(args['fancy']) self.formats = args.get("formats", {})
if 'passexceptions' in args:
self.passExceptions = int(args['passexceptions'])
if 'watchers' in args:
self.currentWatchers = args['watchers']
if 'typeformats' in args:
for f in args['typeformats'].split(','):
pos = f.find("=")
if pos != -1:
typeName = self.hexdecode(f[0:pos])
self.typeformats[typeName] = int(f[pos+1:])
if 'formats' in args:
for f in args['formats'].split(','):
pos = f.find("=")
if pos != -1:
self.formats[f[0:pos]] = int(f[pos+1:])
self.reportVariables(args) self.reportVariables(args)
def disassemble(self, args): def disassemble(self, args):

View File

@@ -4753,19 +4753,14 @@ void addGdbOptionPages(QList<IOptionsPage *> *opts)
opts->push_back(new GdbOptionsPage2()); opts->push_back(new GdbOptionsPage2());
} }
void GdbEngine::updateLocalsPython(const UpdateParameters &params) void GdbEngine::updateLocalsPython(const UpdateParameters &params)
{ {
//m_pendingWatchRequests = 0; //m_pendingWatchRequests = 0;
m_pendingBreakpointRequests = 0; m_pendingBreakpointRequests = 0;
m_processedNames.clear(); m_processedNames.clear();
WatchHandler *handler = watchHandler();
DebuggerCommand cmd("showData"); DebuggerCommand cmd("showData");
cmd.arg("expanded", handler->expansionRequests()); watchHandler()->appendFormatRequests(&cmd);
cmd.arg("typeformats", handler->typeFormatRequests());
cmd.arg("formats", handler->individualFormatRequests());
cmd.arg("stringcutoff", action(MaximalStringLength)->value().toByteArray()); cmd.arg("stringcutoff", action(MaximalStringLength)->value().toByteArray());
cmd.arg("displaystringlimit", action(DisplayStringLimit)->value().toByteArray()); cmd.arg("displaystringlimit", action(DisplayStringLimit)->value().toByteArray());

View File

@@ -848,13 +848,9 @@ void LldbEngine::updateLocals()
void LldbEngine::doUpdateLocals(UpdateParameters params) void LldbEngine::doUpdateLocals(UpdateParameters params)
{ {
WatchHandler *handler = watchHandler();
DebuggerCommand cmd("updateData"); DebuggerCommand cmd("updateData");
cmd.arg("nativeMixed", isNativeMixedActive()); cmd.arg("nativeMixed", isNativeMixedActive());
cmd.arg("expanded", handler->expansionRequests()); watchHandler()->appendFormatRequests(&cmd);
cmd.arg("typeformats", handler->typeFormatRequests());
cmd.arg("formats", handler->individualFormatRequests());
const static bool alwaysVerbose = !qgetenv("QTC_DEBUGGER_PYTHON_VERBOSE").isEmpty(); const static bool alwaysVerbose = !qgetenv("QTC_DEBUGGER_PYTHON_VERBOSE").isEmpty();
cmd.arg("passexceptions", alwaysVerbose); cmd.arg("passexceptions", alwaysVerbose);

View File

@@ -725,7 +725,7 @@ void PdbEngine::updateLocals()
options.chop(1); options.chop(1);
postCommand("qdebug('" + options + "','" postCommand("qdebug('" + options + "','"
+ handler->expansionRequests() + "','" // + handler->expansionRequests() + "','"
+ handler->typeFormatRequests() + "','" + handler->typeFormatRequests() + "','"
+ handler->individualFormatRequests() + "','" + handler->individualFormatRequests() + "','"
+ watchers.toHex() + "')", CB(handleListLocals)); + watchers.toHex() + "')", CB(handleListLocals));

View File

@@ -1130,15 +1130,12 @@ void WatchModel::insertBulkData(const QList<WatchData> &list)
emit columnAdjustmentRequested(); emit columnAdjustmentRequested();
} }
void WatchItem::formatRequests(QByteArray *out) const int WatchItem::requestedFormat() const
{ {
int format = theIndividualFormats.value(d.iname, AutomaticFormat); int format = theIndividualFormats.value(d.iname, AutomaticFormat);
if (format == AutomaticFormat) if (format == AutomaticFormat)
format = theTypeFormats.value(stripForFormat(d.type), AutomaticFormat); format = theTypeFormats.value(stripForFormat(d.type), AutomaticFormat);
if (format != AutomaticFormat) return format;
*out += d.iname + ":format=" + QByteArray::number(format) + ',';
foreach (const TreeItem *child, children())
static_cast<const WatchItem *>(child)->formatRequests(out);
} }
void WatchItem::showInEditorHelper(QString *contents, int depth) const void WatchItem::showInEditorHelper(QString *contents, int depth) const
@@ -1639,22 +1636,6 @@ int WatchHandler::format(const QByteArray &iname) const
return result; return result;
} }
QByteArray WatchHandler::expansionRequests() const
{
QByteArray ba;
m_model->root()->formatRequests(&ba);
if (!m_model->m_expandedINames.isEmpty()) {
QSetIterator<QByteArray> jt(m_model->m_expandedINames);
while (jt.hasNext()) {
QByteArray iname = jt.next();
ba.append(iname);
ba.append(',');
}
ba.chop(1);
}
return ba;
}
QByteArray WatchHandler::typeFormatRequests() const QByteArray WatchHandler::typeFormatRequests() const
{ {
QByteArray ba; QByteArray ba;
@@ -1695,6 +1676,39 @@ QByteArray WatchHandler::individualFormatRequests() const
return ba; return ba;
} }
void WatchHandler::appendFormatRequests(DebuggerCommand *cmd)
{
cmd->beginList("expanded");
QSetIterator<QByteArray> jt(m_model->m_expandedINames);
while (jt.hasNext()) {
QByteArray iname = jt.next();
//WatchItem *item = m_model->findItem(iname);
cmd->arg(iname);
//cmd->arg("format", item->requestedFormat());
}
cmd->endList();
cmd->beginGroup("typeformats");
QHashIterator<QByteArray, int> it(theTypeFormats);
while (it.hasNext()) {
it.next();
const int format = it.value();
if (format >= RawFormat && format < ArtificialFormatBase)
cmd->arg(it.key(), format);
}
cmd->endGroup();
cmd->beginGroup("formats");
QHashIterator<QByteArray, int> it2(theIndividualFormats);
while (it2.hasNext()) {
it2.next();
const int format = it2.value();
if (format >= RawFormat && format < ArtificialFormatBase)
cmd->arg(it2.key(), format);
}
cmd->endGroup();
}
void WatchHandler::addDumpers(const GdbMi &dumpers) void WatchHandler::addDumpers(const GdbMi &dumpers)
{ {
foreach (const GdbMi &dumper, dumpers.children()) { foreach (const GdbMi &dumper, dumpers.children()) {

View File

@@ -41,6 +41,7 @@
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
class DebuggerCommand;
class SeparatedView; class SeparatedView;
class WatchModel; class WatchModel;
@@ -74,7 +75,7 @@ public:
int editType() const; int editType() const;
QColor color() const; QColor color() const;
void formatRequests(QByteArray *out) const; int requestedFormat() const;
void showInEditorHelper(QString *contents, int depth) const; void showInEditorHelper(QString *contents, int depth) const;
WatchItem *findItem(const QByteArray &iname); WatchItem *findItem(const QByteArray &iname);
void parseWatchData(const GdbMi &input); void parseWatchData(const GdbMi &input);
@@ -211,7 +212,6 @@ public:
static QStringList watchedExpressions(); static QStringList watchedExpressions();
static QHash<QByteArray, int> watcherNames(); static QHash<QByteArray, int> watcherNames();
QByteArray expansionRequests() const;
QByteArray typeFormatRequests() const; QByteArray typeFormatRequests() const;
QByteArray individualFormatRequests() const; QByteArray individualFormatRequests() const;
@@ -234,6 +234,7 @@ public:
void setCurrentItem(const QByteArray &iname); void setCurrentItem(const QByteArray &iname);
void updateWatchersWindow(); void updateWatchersWindow();
void appendFormatRequests(DebuggerCommand *cmd);
void insertData(const WatchData &data); // Convenience. void insertData(const WatchData &data); // Convenience.
void insertData(const QList<WatchData> &list); void insertData(const QList<WatchData> &list);