Fixes: debugger: work on plugin breakpoints

This commit is contained in:
hjk
2009-02-12 13:04:01 +01:00
parent b928f7b570
commit 6f64b19ebf
5 changed files with 51 additions and 76 deletions

View File

@@ -1082,22 +1082,12 @@ bool DebuggerManager::useCustomDumpers() const
return m_settings.m_useCustomDumpers; return m_settings.m_useCustomDumpers;
} }
bool DebuggerManager::useFastStart() const
{
return 0; // && m_settings.m_useFastStart;
}
void DebuggerManager::setUseCustomDumpers(bool on) void DebuggerManager::setUseCustomDumpers(bool on)
{ {
m_settings.m_useCustomDumpers = on; m_settings.m_useCustomDumpers = on;
engine()->setUseCustomDumpers(on); engine()->setUseCustomDumpers(on);
} }
void DebuggerManager::setUseFastStart(bool on)
{
m_settings.m_useFastStart = on;
}
void DebuggerManager::setDebugDumpers(bool on) void DebuggerManager::setDebugDumpers(bool on)
{ {
m_settings.m_debugDumpers = on; m_settings.m_debugDumpers = on;

View File

@@ -170,7 +170,11 @@ private:
virtual bool skipKnownFrames() const = 0; virtual bool skipKnownFrames() const = 0;
virtual bool debugDumpers() const = 0; virtual bool debugDumpers() const = 0;
virtual bool useCustomDumpers() const = 0; virtual bool useCustomDumpers() const = 0;
virtual bool useFastStart() const = 0;
virtual bool wantsAllPluginBreakpoints() const = 0;
virtual bool wantsSelectedPluginBreakpoints() const = 0;
virtual bool wantsNoPluginBreakpoints() const = 0;
virtual QString selectedPluginBreakpointsPattern() const = 0;
virtual void reloadDisassembler() = 0; virtual void reloadDisassembler() = 0;
virtual void reloadModules() = 0; virtual void reloadModules() = 0;
@@ -288,7 +292,6 @@ public slots:
void setUseCustomDumpers(bool on); void setUseCustomDumpers(bool on);
void setDebugDumpers(bool on); void setDebugDumpers(bool on);
void setSkipKnownFrames(bool on); void setSkipKnownFrames(bool on);
void setUseFastStart(bool on);
private slots: private slots:
void showDebuggerOutput(const QString &prefix, const QString &msg); void showDebuggerOutput(const QString &prefix, const QString &msg);
@@ -323,7 +326,14 @@ private:
bool skipKnownFrames() const; bool skipKnownFrames() const;
bool debugDumpers() const; bool debugDumpers() const;
bool useCustomDumpers() const; bool useCustomDumpers() const;
bool useFastStart() const; bool wantsAllPluginBreakpoints() const
{ return m_settings.m_pluginAllBreakpoints; }
bool wantsSelectedPluginBreakpoints() const
{ return m_settings.m_pluginSelectedBreakpoints; }
bool wantsNoPluginBreakpoints() const
{ return m_settings.m_pluginNoBreakpoints; }
QString selectedPluginBreakpointsPattern() const
{ return m_settings.m_pluginSelectedBreakpointsPattern; }
void notifyStartupFinished(); void notifyStartupFinished();
void notifyInferiorStopped(); void notifyInferiorStopped();

View File

@@ -281,6 +281,8 @@ QWidget *GdbOptionPage::createPage(QWidget *parent)
setChecked(m_settings.m_pluginSelectedBreakpoints); setChecked(m_settings.m_pluginSelectedBreakpoints);
m_ui.radioButtonNoPluginBreakpoints-> m_ui.radioButtonNoPluginBreakpoints->
setChecked(m_settings.m_pluginNoBreakpoints); setChecked(m_settings.m_pluginNoBreakpoints);
m_ui.lineEditSelectedPluginBreakpointsPattern->
setText(m_settings.m_pluginSelectedBreakpointsPattern);
m_ui.lineEditSelectedPluginBreakpointsPattern-> m_ui.lineEditSelectedPluginBreakpointsPattern->
setEnabled(m_settings.m_pluginSelectedBreakpoints); setEnabled(m_settings.m_pluginSelectedBreakpoints);

View File

@@ -254,7 +254,6 @@ void GdbEngine::init()
{ {
m_pendingRequests = 0; m_pendingRequests = 0;
m_gdbVersion = 100; m_gdbVersion = 100;
m_shared = 0;
m_outputCodec = QTextCodec::codecForLocale(); m_outputCodec = QTextCodec::codecForLocale();
m_dataDumperState = DataDumperUninitialized; m_dataDumperState = DataDumperUninitialized;
@@ -988,18 +987,6 @@ void GdbEngine::handleInfoShared(const GdbResultRecord &record)
if (record.resultClass == GdbResultDone) { if (record.resultClass == GdbResultDone) {
// let the modules handler do the parsing // let the modules handler do the parsing
handleModulesList(record); handleModulesList(record);
QList<Module> modules = qq->modulesHandler()->modules();
bool reloadNeeded = false;
foreach (const Module &module, modules) {
// FIXME: read this from some list
if (!module.symbolsRead && !module.moduleName.contains("Q")) {
reloadNeeded = true;
sendCommand("sharedlibrary " + dotEscape(module.moduleName));
}
}
if (reloadNeeded)
reloadModules();
continueInferior();
} }
} }
@@ -1146,7 +1133,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
{ {
const QString reason = data.findChild("reason").data(); const QString reason = data.findChild("reason").data();
QString console = data.findChild("consolestreamoutput").data(); QString msg = data.findChild("consolestreamoutput").data();
if (reason.isEmpty()) { if (reason.isEmpty()) {
GdbMi frame = data.findChild("frame"); GdbMi frame = data.findChild("frame");
if (frame.findChild("func").data() == "_start") { if (frame.findChild("func").data() == "_start") {
@@ -1162,11 +1149,27 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
sendCommand("info pid", GdbInfoProc, QVariant(), true); sendCommand("info pid", GdbInfoProc, QVariant(), true);
#endif #endif
sendCommand("-file-list-exec-source-files", GdbQuerySources); sendCommand("-file-list-exec-source-files", GdbQuerySources);
sendCommand("set auto-solib-add on");
sendCommand("sharedlibrary libc"); // for malloc sendCommand("sharedlibrary libc"); // for malloc
sendCommand("sharedlibrary libdl"); // for dlopen sendCommand("sharedlibrary libdl"); // for dlopen
tryLoadCustomDumpers(); tryLoadCustomDumpers();
sendCommand("info shared", ModulesList, QVariant());
// intentionally after tryLoadCustomDumpers(),
// otherwise we'd interupt solib loading.
if (qq->wantsAllPluginBreakpoints()) {
sendCommand("set auto-solib-add on");
sendCommand("set stop-on-solib-events 0");
sendCommand("sharedlibrary .*");
} else if (qq->wantsSelectedPluginBreakpoints()) {
sendCommand("set auto-solib-add on");
sendCommand("set stop-on-solib-events 1");
sendCommand("sharedlibrary "+qq->selectedPluginBreakpointsPattern());
} else if (qq->wantsNoPluginBreakpoints()) {
// should be like that already
sendCommand("set auto-solib-add off");
sendCommand("set stop-on-solib-events 0");
}
reloadModules();
// this will "continue" if done // this will "continue" if done
attemptBreakpointSynchronization(); attemptBreakpointSynchronization();
return; return;
@@ -1174,36 +1177,19 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
// fall through // fall through
} }
#if 0 static bool modulesDirty = false;
if (console.contains("Stopped due to shared library event") || reason.isEmpty()) { if (msg.contains("Stopped due to shared library event") || reason.isEmpty()) {
++m_shared; if (qq->wantsSelectedPluginBreakpoints()) {
//if (m_shared == 2) qDebug() << "SHARED LIBRARY EVENT " << data.toString();
// tryLoadCustomDumpers(); qDebug() << "PATTERN" << qq->selectedPluginBreakpointsPattern();
//qDebug() << "SHARED LIBRARY EVENT " << data.toString() << m_shared; sendCommand("sharedlibrary " + qq->selectedPluginBreakpointsPattern());
if (qq->useFastStart()) {
if (1 || m_shared <= 16) { // libpthread?
sendCommand("info shared", GdbInfoShared);
//sendCommand("sharedlibrary gdbdebugger ");
//continueInferior();
} else {
// auto-load from now on
sendCommand("info shared");
sendCommand("set auto-solib-add on");
sendCommand("-file-list-exec-source-files", GdbQuerySources);
sendCommand("-break-list", BreakList);
//sendCommand("bt");
//QVariant var = QVariant::fromValue<GdbMi>(data);
//sendCommand("p 1", GdbAsyncOutput2, var); // dummy
continueInferior(); continueInferior();
}
} else {
// slow start requested.
q->showStatusMessage(tr("Loading %1...").arg(QString(data.toString()))); q->showStatusMessage(tr("Loading %1...").arg(QString(data.toString())));
continueInferior();
}
return; return;
} }
#endif modulesDirty = true;
// fall through
}
if (isExitedReason(reason)) { if (isExitedReason(reason)) {
qq->notifyInferiorExited(); qq->notifyInferiorExited();
@@ -1256,11 +1242,17 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
} }
if (isStoppedReason(reason) || reason.isEmpty()) { if (isStoppedReason(reason) || reason.isEmpty()) {
if (modulesDirty) {
sendCommand("-file-list-exec-source-files", GdbQuerySources);
sendCommand("-break-list", BreakList);
reloadModules();
modulesDirty = false;
}
// Need another round trip // Need another round trip
if (reason == "breakpoint-hit") { if (reason == "breakpoint-hit") {
q->showStatusMessage(tr("Stopped at breakpoint")); q->showStatusMessage(tr("Stopped at breakpoint"));
GdbMi frame = data.findChild("frame"); GdbMi frame = data.findChild("frame");
qDebug() << "HIT BREAKPOINT: " << frame.toString(); //qDebug() << "HIT BREAKPOINT: " << frame.toString();
m_currentFrame = frame.findChild("addr").data() + '%' + m_currentFrame = frame.findChild("addr").data() + '%' +
frame.findChild("func").data() + '%'; frame.findChild("func").data() + '%';
@@ -1504,7 +1496,6 @@ void GdbEngine::exitDebugger()
m_fullToShortName.clear(); m_fullToShortName.clear();
m_varToType.clear(); m_varToType.clear();
m_dataDumperState = DataDumperUninitialized; m_dataDumperState = DataDumperUninitialized;
m_shared = 0;
m_outputCollector.shutdown(); m_outputCollector.shutdown();
//q->settings()->m_debugDumpers = false; //q->settings()->m_debugDumpers = false;
} }
@@ -1572,12 +1563,7 @@ bool GdbEngine::startDebugger()
q->showStatusMessage(tr("Gdb Running")); q->showStatusMessage(tr("Gdb Running"));
sendCommand("show version", GdbShowVersion); sendCommand("show version", GdbShowVersion);
if (qq->useFastStart()) {
sendCommand("set auto-solib-add off");
sendCommand("set stop-on-solib-events 1");
}
//sendCommand("-enable-timings"); //sendCommand("-enable-timings");
//sendCommand("set stop-on-solib-events 1");
sendCommand("set print static-members off"); // Seemingly doesn't work. sendCommand("set print static-members off"); // Seemingly doesn't work.
//sendCommand("define hook-stop\n-thread-list-ids\n-stack-list-frames\nend"); //sendCommand("define hook-stop\n-thread-list-ids\n-stack-list-frames\nend");
//sendCommand("define hook-stop\nprint 4\nend"); //sendCommand("define hook-stop\nprint 4\nend");
@@ -4044,8 +4030,6 @@ void GdbEngine::tryLoadCustomDumpers()
QString lib = q->m_buildDir + "/qtc-gdbmacros/libgdbmacros.so"; QString lib = q->m_buildDir + "/qtc-gdbmacros/libgdbmacros.so";
if (QFileInfo(lib).isExecutable()) { if (QFileInfo(lib).isExecutable()) {
//sendCommand("p dlopen"); //sendCommand("p dlopen");
//if (qq->useFastStart())
// sendCommand("set stop-on-solib-events 0");
QString flag = QString::number(RTLD_NOW); QString flag = QString::number(RTLD_NOW);
sendSynchronizedCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", sendSynchronizedCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")",
WatchDumpCustomSetup); WatchDumpCustomSetup);
@@ -4053,8 +4037,6 @@ void GdbEngine::tryLoadCustomDumpers()
sendSynchronizedCommand("call (void)__dlopen(\"" + lib + "\", " + flag + ")", sendSynchronizedCommand("call (void)__dlopen(\"" + lib + "\", " + flag + ")",
WatchDumpCustomSetup); WatchDumpCustomSetup);
sendSynchronizedCommand("sharedlibrary " + dotEscape(lib)); sendSynchronizedCommand("sharedlibrary " + dotEscape(lib));
//if (qq->useFastStart())
// sendCommand("set stop-on-solib-events 1");
} else { } else {
qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: "
<< lib << QFileInfo(lib).isExecutable(); << lib << QFileInfo(lib).isExecutable();
@@ -4064,14 +4046,10 @@ void GdbEngine::tryLoadCustomDumpers()
QString lib = q->m_buildDir + "/qtc-gdbmacros/libgdbmacros.dylib"; QString lib = q->m_buildDir + "/qtc-gdbmacros/libgdbmacros.dylib";
if (QFileInfo(lib).isExecutable()) { if (QFileInfo(lib).isExecutable()) {
//sendCommand("p dlopen"); // FIXME: remove me //sendCommand("p dlopen"); // FIXME: remove me
//if (qq->useFastStart())
// sendCommand("set stop-on-solib-events 0");
QString flag = QString::number(RTLD_NOW); QString flag = QString::number(RTLD_NOW);
sendSynchronizedCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", sendSynchronizedCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")",
WatchDumpCustomSetup); WatchDumpCustomSetup);
sendSynchronizedCommand("sharedlibrary " + dotEscape(lib)); sendSynchronizedCommand("sharedlibrary " + dotEscape(lib));
//if (qq->useFastStart())
// sendCommand("set stop-on-solib-events 1");
} else { } else {
qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: "
<< lib << QFileInfo(lib).isExecutable(); << lib << QFileInfo(lib).isExecutable();
@@ -4080,15 +4058,11 @@ void GdbEngine::tryLoadCustomDumpers()
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
QString lib = q->m_buildDir + "/qtc-gdbmacros/debug/gdbmacros.dll"; QString lib = q->m_buildDir + "/qtc-gdbmacros/debug/gdbmacros.dll";
if (QFileInfo(lib).exists()) { if (QFileInfo(lib).exists()) {
//if (qq->useFastStart())
// sendCommand("set stop-on-solib-events 0");
//sendCommand("handle SIGSEGV pass stop print"); //sendCommand("handle SIGSEGV pass stop print");
//sendCommand("set unwindonsignal off"); //sendCommand("set unwindonsignal off");
sendSynchronizedCommand("call LoadLibraryA(\"" + lib + "\")", sendSynchronizedCommand("call LoadLibraryA(\"" + lib + "\")",
WatchDumpCustomSetup); WatchDumpCustomSetup);
sendSynchronizedCommand("sharedlibrary " + dotEscape(lib)); sendSynchronizedCommand("sharedlibrary " + dotEscape(lib));
//if (qq->useFastStart())
// sendCommand("set stop-on-solib-events 1");
} else { } else {
qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: " qDebug() << "DEBUG HELPER LIBRARY IS NOT USABLE: "
<< lib << QFileInfo(lib).isExecutable(); << lib << QFileInfo(lib).isExecutable();

View File

@@ -217,7 +217,6 @@ private:
int m_oldestAcceptableToken; int m_oldestAcceptableToken;
int m_gdbVersion; // 6.8.0 is 680 int m_gdbVersion; // 6.8.0 is 680
int m_shared;
// awful hack to keep track of used files // awful hack to keep track of used files
QHash<QString, QString> m_shortToFullName; QHash<QString, QString> m_shortToFullName;