From 380cb40f2736e66d56a73ca4696c8d6b02b260e1 Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Mon, 23 Mar 2009 14:34:01 +0100 Subject: [PATCH] debugger: work on optional prebuild dumper library --- src/plugins/debugger/debuggeractions.cpp | 13 +++++- src/plugins/debugger/debuggeractions.h | 2 + src/plugins/debugger/debuggerplugin.cpp | 5 ++- src/plugins/debugger/gdbengine.cpp | 55 +++++++++++++----------- src/plugins/debugger/gdbengine.h | 1 + src/plugins/debugger/gdbmi.cpp | 2 +- 6 files changed, 49 insertions(+), 29 deletions(-) diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index b336b638a3a..d1aa6ff33cb 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -32,6 +32,7 @@ #include <utils/qtcassert.h> #include <utils/pathchooser.h> +#include <QtCore/QDebug> #include <QtCore/QSettings> #include <QtGui/QAction> #include <QtGui/QAbstractButton> @@ -39,9 +40,11 @@ #include <QtGui/QCheckBox> #include <QtGui/QLineEdit> + namespace Debugger { namespace Internal { + ////////////////////////////////////////////////////////////////////////// // // DebuggerAction @@ -119,6 +122,14 @@ void DebuggerAction::setTextPattern(const QString &value) m_textPattern = value; } +QString DebuggerAction::toString() const +{ + return "value: " + m_value.toString() + + " defaultvalue: " + m_defaultValue.toString() + + " settingskey: " + m_settingsGroup + '/' + m_settingsKey + + " deferedValue: " + m_deferedValue.toString(); +} + QAction *DebuggerAction::updatedAction(const QString &text0) { QString text = text0; @@ -155,7 +166,7 @@ void DebuggerAction::writeSettings(QSettings *settings) return; settings->beginGroup(m_settingsGroup); settings->setValue(m_settingsKey, m_value); - //qDebug() << "WRITING: " << m_settingsKey << " -> " << m_value; + //qDebug() << "WRITING: " << m_settingsKey << " -> " << toString(); settings->endGroup(); } diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index a319fa668c2..b635840df06 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -80,6 +80,8 @@ public: virtual QString textPattern() const; Q_SLOT virtual void setTextPattern(const QString &value); + QString toString() const; + signals: void valueChanged(const QVariant &newValue); void boolValueChanged(bool newValue); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 5f5aa0dd834..2a66c1422e7 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -378,6 +378,9 @@ QWidget *DumperOptionPage::createPage(QWidget *parent) m_ui.dumperLocationChooser->setInitialBrowsePathBackup( Core::ICore::instance()->resourcePath() + "../../lib"); + connect(m_ui.radioButtonUsePrebuiltDumpers, SIGNAL(toggled(bool)), + m_ui.dumperLocationChooser, SLOT(setEnabled(bool))); + theDebuggerAction(UsePrebuiltDumpers) ->connectWidget(m_ui.radioButtonUsePrebuiltDumpers); theDebuggerAction(BuildDumpersOnTheFly) @@ -392,8 +395,6 @@ QWidget *DumperOptionPage::createPage(QWidget *parent) m_ui.dumperLocationChooser-> setEnabled(theDebuggerAction(UsePrebuiltDumpers)->value().toBool()); - connect(m_ui.radioButtonUsePrebuiltDumpers, SIGNAL(toggled(bool)), - m_ui.dumperLocationChooser, SLOT(setEnabled(bool))); #ifndef QT_DEBUG #if 0 diff --git a/src/plugins/debugger/gdbengine.cpp b/src/plugins/debugger/gdbengine.cpp index 8b5ed5ea018..2a88a318acf 100644 --- a/src/plugins/debugger/gdbengine.cpp +++ b/src/plugins/debugger/gdbengine.cpp @@ -4230,6 +4230,19 @@ void GdbEngine::assignValueInDebugger(const QString &expression, const QString & sendCommand("-var-assign assign " + value, WatchVarAssign); } +QString GdbEngine::dumperLibraryName() const +{ + if (theDebuggerAction(UsePrebuiltDumpers)) + return theDebuggerAction(PrebuiltDumpersLocation)->value().toString(); +#if defined(Q_OS_WIN) + return q->m_buildDir + "/qtc-gdbmacros/debug/gdbmacros.dll"; +#elif defined(Q_OS_MAC) + retirn q->m_buildDir + "/qtc-gdbmacros/libgdbmacros.dylib"; +#else // generic UNIX + return q->m_buildDir + "/qtc-gdbmacros/libgdbmacros.so"; +#endif +} + void GdbEngine::tryLoadCustomDumpers() { if (m_dataDumperState != DataDumperUninitialized) @@ -4237,26 +4250,18 @@ void GdbEngine::tryLoadCustomDumpers() PENDING_DEBUG("TRY LOAD CUSTOM DUMPERS"); m_dataDumperState = DataDumperUnavailable; + QString lib = dumperLibraryName(); -#if defined(Q_OS_LINUX) - QString lib = q->m_buildDir + "/qtc-gdbmacros/libgdbmacros.so"; if (QFileInfo(lib).exists()) { +#if defined(Q_OS_WIN) m_dataDumperState = DataDumperLoadTried; - //sendCommand("p dlopen"); - QString flag = QString::number(RTLD_NOW); - sendCommand("sharedlibrary libc"); // for malloc - sendCommand("sharedlibrary libdl"); // for dlopen - sendCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", - WatchDumpCustomSetup); - // some older systems like CentOS 4.6 prefer this: - sendCommand("call (void)__dlopen(\"" + lib + "\", " + flag + ")", + sendCommand("sharedlibrary .*"); // for LoadLibraryA + //sendCommand("handle SIGSEGV pass stop print"); + //sendCommand("set unwindonsignal off"); + sendCommand("call LoadLibraryA(\"" + lib + "\")", WatchDumpCustomSetup); sendCommand("sharedlibrary " + dotEscape(lib)); - } -#endif -#if defined(Q_OS_MAC) - QString lib = q->m_buildDir + "/qtc-gdbmacros/libgdbmacros.dylib"; - if (QFileInfo(lib).exists()) { +#elif defined(Q_OS_MAC) m_dataDumperState = DataDumperLoadTried; //sendCommand("sharedlibrary libc"); // for malloc //sendCommand("sharedlibrary libdl"); // for dlopen @@ -4264,20 +4269,20 @@ void GdbEngine::tryLoadCustomDumpers() sendCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", WatchDumpCustomSetup); //sendCommand("sharedlibrary " + dotEscape(lib)); - } -#endif -#if defined(Q_OS_WIN) - QString lib = q->m_buildDir + "/qtc-gdbmacros/debug/gdbmacros.dll"; - if (QFileInfo(lib).exists()) { m_dataDumperState = DataDumperLoadTried; - sendCommand("sharedlibrary .*"); // for LoadLibraryA - //sendCommand("handle SIGSEGV pass stop print"); - //sendCommand("set unwindonsignal off"); - sendCommand("call LoadLibraryA(\"" + lib + "\")", +#else + //sendCommand("p dlopen"); + QString flag = QString::number(RTLD_NOW); + sendCommand("sharedlibrary libc"); // for malloc + sendCommand("sharedlibrary libdl"); // for dlopen + sendCommand("call (void)dlopen(\"" + lib + "\", " + flag + ")", + WatchDumpCustomSetup); + // some older systems like CentOS 4.6 prefer this: + sendCommand("call (void)__dlopen(\"" + lib + "\", " + flag + ")", WatchDumpCustomSetup); sendCommand("sharedlibrary " + dotEscape(lib)); - } #endif + } if (m_dataDumperState == DataDumperLoadTried) { // retreive list of dumpable classes diff --git a/src/plugins/debugger/gdbengine.h b/src/plugins/debugger/gdbengine.h index d0186493972..20c9c222877 100644 --- a/src/plugins/debugger/gdbengine.h +++ b/src/plugins/debugger/gdbengine.h @@ -199,6 +199,7 @@ private: void handleQuerySources(const GdbResultRecord &response); void handleTargetCore(const GdbResultRecord &response); void debugMessage(const QString &msg); + QString dumperLibraryName() const; OutputCollector m_outputCollector; QTextCodec *m_outputCodec; diff --git a/src/plugins/debugger/gdbmi.cpp b/src/plugins/debugger/gdbmi.cpp index e2e11e07ba1..2e778cb8e83 100644 --- a/src/plugins/debugger/gdbmi.cpp +++ b/src/plugins/debugger/gdbmi.cpp @@ -37,7 +37,7 @@ namespace Debugger { namespace Internal { -QTextStream & operator<<(QTextStream & os, const GdbMi & mi) +QTextStream &operator<<(QTextStream &os, const GdbMi &mi) { return os << mi.toString(); } -- GitLab