Handle various CDB output windows.

Add modules, threads and register view. Refactor register format code.
This commit is contained in:
Friedemann Kleint
2009-04-09 16:51:13 +02:00
parent e6843ff5bc
commit 6d4d19dfa8
16 changed files with 572 additions and 141 deletions

View File

@@ -25,7 +25,9 @@ HEADERS += \
$$PWD/cdbdebugoutput.h \
$$PWD/cdbsymbolgroupcontext.h \
$$PWD/cdbstacktracecontext.h \
$$PWD/cdbbreakpoint.h
$$PWD/cdbbreakpoint.h \
$$PWD/cdbmodules.h \
$$PWD/cdbassembler.h
SOURCES += \
$$PWD/cdbdebugengine.cpp \
@@ -33,7 +35,9 @@ SOURCES += \
$$PWD/cdbdebugoutput.cpp \
$$PWD/cdbsymbolgroupcontext.cpp \
$$PWD/cdbstacktracecontext.cpp \
$$PWD/cdbbreakpoint.cpp
$$PWD/cdbbreakpoint.cpp \
$$PWD/cdbmodules.cpp \
$$PWD/cdbassembler.cpp
} else {
message("Debugging Tools for Windows could not be found in $$CDB_PATH")

View File

@@ -0,0 +1,83 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include "cdbassembler.h"
#include "registerhandler.h"
#include "cdbdebugengine_p.h"
#include "cdbsymbolgroupcontext.h"
#include <QtCore/QVector>
namespace Debugger {
namespace Internal {
bool getRegisters(IDebugControl4 *ctl,
IDebugRegisters2 *ireg,
QList<Register> *registers,
QString *errorMessage, int base)
{
registers->clear();
ULONG count;
HRESULT hr = ireg->GetNumberRegisters(&count);
if (FAILED(hr)) {
*errorMessage= msgComFailed("GetNumberRegisters", hr);
return false;
}
if (!count)
return true;
// Retrieve names
WCHAR wszBuf[MAX_PATH];
for (ULONG r = 0; r < count; r++) {
hr = ireg->GetDescriptionWide(r, wszBuf, MAX_PATH - 1, 0, 0);
if (FAILED(hr)) {
*errorMessage= msgComFailed("GetDescriptionWide", hr);
return false;
}
Register reg;
reg.name = QString::fromUtf16(wszBuf);
registers->push_back(reg);
}
// get values
QVector<DEBUG_VALUE> values(count);
DEBUG_VALUE *valuesPtr = &(*values.begin());
memset(valuesPtr, 0, count * sizeof(DEBUG_VALUE));
hr = ireg->GetValues(count, 0, 0, valuesPtr);
if (FAILED(hr)) {
*errorMessage= msgComFailed("GetValues", hr);
return false;
}
if (base < 2)
base = 10;
for (ULONG r = 0; r < count; r++)
(*registers)[r].value = CdbSymbolGroupContext::debugValueToString(values.at(r), ctl, 0, base);
return true;
}
}
}

View File

@@ -0,0 +1,54 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef CDBASSEMBLER_H
#define CDBASSEMBLER_H
#include <QtCore/QList>
#include <QtCore/QString>
#include <windows.h>
#include <inc/dbgeng.h>
namespace Debugger {
namespace Internal {
// Utilities related to assembler code.
class Register;
bool getRegisters(IDebugControl4 *ctl,
IDebugRegisters2 *ireg,
QList<Register> *registers,
QString *errorMessage,
int base = 10 /* 16 for hex, etc */);
}
}
#endif // CDBASSEMBLER_H

View File

@@ -32,11 +32,16 @@
#include "cdbsymbolgroupcontext.h"
#include "cdbstacktracecontext.h"
#include "cdbbreakpoint.h"
#include "cdbmodules.h"
#include "cdbassembler.h"
#include "debuggeractions.h"
#include "debuggermanager.h"
#include "breakhandler.h"
#include "stackhandler.h"
#include "watchhandler.h"
#include "registerhandler.h"
#include "moduleshandler.h"
#include "watchutils.h"
#include <utils/qtcassert.h>
@@ -308,6 +313,10 @@ CdbDebugEngine::CdbDebugEngine(DebuggerManager *parent) :
connect(&m_d->m_consoleStubProc, SIGNAL(processError(QString)), this, SLOT(slotConsoleStubError(QString)));
connect(&m_d->m_consoleStubProc, SIGNAL(processStarted()), this, SLOT(slotConsoleStubStarted()));
connect(&m_d->m_consoleStubProc, SIGNAL(wrapperStopped()), this, SLOT(slotConsoleStubTerminated()));
connect(&m_d->m_debugOutputCallBack, SIGNAL(debuggerOutput(QString,QString)),
m_d->m_debuggerManager, SLOT(showDebuggerOutput(QString,QString)));
connect(&m_d->m_debugOutputCallBack, SIGNAL(debuggerInputPrompt(QString,QString)),
m_d->m_debuggerManager, SLOT(showDebuggerInput(QString,QString)));
}
CdbDebugEngine::~CdbDebugEngine()
@@ -344,8 +353,16 @@ void CdbDebugEngine::setToolTipExpression(const QPoint & /*pos*/, const QString
{
}
void CdbDebugEnginePrivate::clearDisplay()
{
m_debuggerManagerAccess->threadsHandler()->removeAll();
m_debuggerManagerAccess->modulesHandler()->removeAll();
m_debuggerManagerAccess->registerHandler()->removeAll();
}
bool CdbDebugEngine::startDebugger()
{
m_d->clearDisplay();
m_d->m_debuggerManager->showStatusMessage("Starting Debugger", -1);
QString errorMessage;
bool rc = false;
@@ -1042,8 +1059,35 @@ void CdbDebugEngine::loadAllSymbols()
qDebug() << Q_FUNC_INFO;
}
static inline int registerFormatBase()
{
switch(checkedRegisterFormatAction()) {
case FormatHexadecimal:
return 16;
case FormatDecimal:
return 10;
case FormatOctal:
return 8;
case FormatBinary:
return 2;
break;
case FormatRaw:
case FormatNatural:
break;
}
return 10;
}
void CdbDebugEngine::reloadRegisters()
{
const int intBase = registerFormatBase();
if (debugCDB)
qDebug() << Q_FUNC_INFO << intBase;
QList<Register> registers;
QString errorMessage;
if (!getRegisters(m_d->m_pDebugControl, m_d->m_pDebugRegisters, &registers, &errorMessage, intBase))
qWarning("reloadRegisters() failed: %s\n", qPrintable(errorMessage));
m_d->m_debuggerManagerAccess->registerHandler()->setRegisters(registers);
}
void CdbDebugEngine::timerEvent(QTimerEvent* te)
@@ -1142,21 +1186,34 @@ void CdbDebugEnginePrivate::updateThreadList()
ThreadsHandler* th = m_debuggerManagerAccess->threadsHandler();
QList<ThreadData> threads;
bool success = false;
QString errorMessage;
do {
ULONG numberOfThreads;
HRESULT hr= m_pDebugSystemObjects->GetNumberThreads(&numberOfThreads);
if (FAILED(hr)) {
errorMessage= msgComFailed("GetNumberThreads", hr);
break;
}
const ULONG maxThreadIds = 256;
ULONG threadIds[maxThreadIds];
ULONG biggestThreadId = qMin(maxThreadIds, numberOfThreads - 1);
hr = m_pDebugSystemObjects->GetThreadIdsByIndex(0, biggestThreadId, threadIds, 0);
if (FAILED(hr)) {
errorMessage= msgComFailed("GetThreadIdsByIndex", hr);
break;
}
for (ULONG threadId = 0; threadId <= biggestThreadId; ++threadId) {
ThreadData thread;
thread.id = threadId;
threads.append(thread);
}
HRESULT hr;
ULONG numberOfThreads;
hr = m_pDebugSystemObjects->GetNumberThreads(&numberOfThreads);
const ULONG maxThreadIds = 256;
ULONG threadIds[maxThreadIds];
ULONG biggestThreadId = qMin(maxThreadIds, numberOfThreads - 1);
hr = m_pDebugSystemObjects->GetThreadIdsByIndex(0, biggestThreadId, threadIds, 0);
for (ULONG threadId = 0; threadId <= biggestThreadId; ++threadId) {
ThreadData thread;
thread.id = threadId;
threads.append(thread);
}
th->setThreads(threads);
th->setThreads(threads);
success = true;
} while (false);
if (!success)
qWarning("updateThreadList() failed: %s\n", qPrintable(errorMessage));
}
void CdbDebugEnginePrivate::updateStackTrace()
@@ -1166,6 +1223,7 @@ void CdbDebugEnginePrivate::updateStackTrace()
// Create a new context
clearForRun();
QString errorMessage;
m_engine->reloadRegisters();
m_currentStackTrace =
CdbStackTraceContext::create(m_pDebugControl, m_pDebugSystemObjects,
m_pDebugSymbols, m_currentThreadId, &errorMessage);
@@ -1191,11 +1249,14 @@ void CdbDebugEnginePrivate::updateStackTrace()
}
}
void CdbDebugEnginePrivate::handleDebugOutput(const char *szOutputString)
void CdbDebugEnginePrivate::updateModules()
{
if (debugCDB && strstr(szOutputString, "ModLoad:") == 0)
qDebug() << Q_FUNC_INFO << szOutputString;
m_debuggerManagerAccess->showApplicationOutput(QString::fromLocal8Bit(szOutputString));
QList<Module> modules;
QString errorMessage;
if (!getModuleList(m_pDebugSymbols, &modules, &errorMessage))
qWarning("updateModules() failed: %s\n", qPrintable(errorMessage));
m_debuggerManagerAccess->modulesHandler()->setModules(modules);
}
void CdbDebugEnginePrivate::handleBreakpointEvent(PDEBUG_BREAKPOINT pBP)

View File

@@ -82,11 +82,13 @@ struct CdbDebugEnginePrivate
void updateThreadList();
void updateStackTrace();
bool updateLocals(int frameIndex, WatchHandler *wh, QString *errorMessage);
void handleDebugOutput(const char* szOutputString);
void updateModules();
void handleBreakpointEvent(PDEBUG_BREAKPOINT pBP);
void cleanStackTrace();
void clearForRun();
CdbSymbolGroupContext *getStackFrameSymbolGroupContext(int frameIndex, QString *errorMessage) const;
void clearDisplay();
bool interruptInterferiorProcess(QString *errorMessage);

View File

@@ -76,8 +76,9 @@ STDMETHODIMP_(ULONG) CdbDebugEventCallback::Release(THIS)
STDMETHODIMP CdbDebugEventCallback::GetInterestMask(THIS_ __out PULONG mask)
{
*mask = DEBUG_EVENT_CREATE_PROCESS | DEBUG_EVENT_EXIT_PROCESS
//| DEBUG_EVENT_CREATE_THREAD | DEBUG_EVENT_EXIT_THREAD
*mask = DEBUG_EVENT_CREATE_PROCESS | DEBUG_EVENT_EXIT_PROCESS
| DEBUG_EVENT_LOAD_MODULE | DEBUG_EVENT_UNLOAD_MODULE
| DEBUG_EVENT_CREATE_THREAD | DEBUG_EVENT_EXIT_THREAD
| DEBUG_EVENT_BREAKPOINT
| DEBUG_EVENT_EXCEPTION
;
@@ -125,13 +126,9 @@ STDMETHODIMP CdbDebugEventCallback::CreateThread(
Q_UNUSED(Handle)
Q_UNUSED(DataOffset)
Q_UNUSED(StartOffset)
if (debugCDB)
qDebug() << Q_FUNC_INFO;
//Debugger::ThreadInfo ti;
//ti.handle = Handle;
//ti.dataOffset = DataOffset;
//ti.startOffset = StartOffset;
m_pEngine->m_d->updateThreadList();
return S_OK;
}
@@ -142,7 +139,8 @@ STDMETHODIMP CdbDebugEventCallback::ExitThread(
{
if (debugCDB)
qDebug() << Q_FUNC_INFO << ExitCode;
// @TODO: It seems the terminated thread is still in the list...
m_pEngine->m_d->updateThreadList();
return S_OK;
}
@@ -211,14 +209,14 @@ STDMETHODIMP CdbDebugEventCallback::LoadModule(
{
Q_UNUSED(ImageFileHandle)
Q_UNUSED(BaseOffset)
Q_UNUSED(ModuleSize)
Q_UNUSED(ModuleName)
Q_UNUSED(ModuleSize)
Q_UNUSED(ImageName)
Q_UNUSED(CheckSum)
Q_UNUSED(TimeDateStamp)
if (debugCDB)
if (debugCDB > 1)
qDebug() << Q_FUNC_INFO << ModuleName;
m_pEngine->m_d->updateModules();
return S_OK;
}
@@ -230,9 +228,9 @@ STDMETHODIMP CdbDebugEventCallback::UnloadModule(
{
Q_UNUSED(ImageBaseName)
Q_UNUSED(BaseOffset)
if (debugCDB)
if (debugCDB > 1)
qDebug() << Q_FUNC_INFO << ImageBaseName;
m_pEngine->m_d->updateModules();
return S_OK;
}

View File

@@ -76,14 +76,49 @@ STDMETHODIMP_(ULONG) CdbDebugOutput::Release(THIS)
return 0;
}
// Return a prefix for debugger messages
static QString prefix(ULONG mask)
{
if (mask & (DEBUG_OUTPUT_DEBUGGEE|DEBUG_OUTPUT_DEBUGGEE_PROMPT|DEBUG_OUTPUT_DEBUGGEE_PROMPT)) {
static const QString p = QLatin1String("target:");
return p;
}
if (mask & (DEBUG_OUTPUT_PROMPT_REGISTERS)) {
static const QString p = QLatin1String("registers:");
return p;
}
if (mask & (DEBUG_OUTPUT_EXTENSION_WARNING|DEBUG_OUTPUT_WARNING)) {
static const QString p = QLatin1String("warning:");
return p;
}
if (mask & (DEBUG_OUTPUT_ERROR)) {
static const QString p = QLatin1String("error:");
return p;
}
if (mask & DEBUG_OUTPUT_SYMBOLS) {
static const QString p = QLatin1String("symbols:");
return p;
}
static const QString commonPrefix = QLatin1String("cdb:");
return commonPrefix;
}
STDMETHODIMP CdbDebugOutput::Output(
THIS_
IN ULONG mask,
IN PCSTR text
)
{
UNREFERENCED_PARAMETER(mask);
m_pEngine->m_d->handleDebugOutput(text);
const QString msg = QString::fromLocal8Bit(text);
if (debugCDB > 1)
qDebug() << Q_FUNC_INFO << "\n " << msg;
if (mask & (DEBUG_OUTPUT_PROMPT|DEBUG_OUTPUT_DEBUGGEE_PROMPT)) {
emit debuggerInputPrompt(prefix(mask), msg);
} else {
emit debuggerOutput(prefix(mask), msg);
}
return S_OK;
}

View File

@@ -33,13 +33,16 @@
#include <windows.h>
#include <inc/dbgeng.h>
#include <QtCore/QObject>
namespace Debugger {
namespace Internal {
class CdbDebugEngine;
class CdbDebugOutput : public IDebugOutputCallbacks
class CdbDebugOutput : public QObject, public IDebugOutputCallbacks
{
Q_OBJECT
public:
explicit CdbDebugOutput(CdbDebugEngine* engine);
@@ -63,6 +66,10 @@ public:
IN PCSTR text
);
signals:
void debuggerOutput(const QString &prefix, const QString &message);
void debuggerInputPrompt(const QString &prefix, const QString &message);
private:
CdbDebugEngine* m_pEngine;
};

View File

@@ -0,0 +1,81 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include "cdbmodules.h"
#include "moduleshandler.h"
#include "cdbdebugengine_p.h"
namespace Debugger {
namespace Internal {
bool getModuleList(IDebugSymbols3 *syms, QList<Module> *modules, QString *errorMessage)
{
modules->clear();
ULONG loadedCount, unloadedCount;
HRESULT hr = syms->GetNumberModules(&loadedCount, &unloadedCount);
if (FAILED(hr)) {
*errorMessage= msgComFailed("GetNumberModules", hr);
return false;
}
// retrieve array of parameters
const ULONG count = loadedCount + unloadedCount;
QVector<DEBUG_MODULE_PARAMETERS> parameters(count);
DEBUG_MODULE_PARAMETERS *parmPtr = &(*parameters.begin());
memset(parmPtr, 0, sizeof(DEBUG_MODULE_PARAMETERS) * count);
hr = syms->GetModuleParameters(count, 0, 0u, parmPtr);
// E_INVALIDARG indicates 'Partial results' according to docu
if (FAILED(hr) && hr != E_INVALIDARG) {
*errorMessage= msgComFailed("GetModuleParameters", hr);
return false;
}
// fill array
const QString hexPrefix = QLatin1String("0x");
WCHAR wszBuf[MAX_PATH];
for (ULONG m = 0; m < count; m++) {
const DEBUG_MODULE_PARAMETERS &p = parameters.at(m);
if (p.Base != DEBUG_INVALID_OFFSET) { // Partial results?
Module module;
module.symbolsRead = (p.Flags & DEBUG_MODULE_USER_MODE)
&& (p.SymbolType != DEBUG_SYMTYPE_NONE);
module.startAddress = hexPrefix + QString::number(p.Base, 16);
module.endAddress = hexPrefix + QString::number((p.Base + p.Size), 16);
hr = syms ->GetModuleNameStringWide(DEBUG_MODNAME_IMAGE, m, 0, wszBuf, MAX_PATH - 1, 0);
if (FAILED(hr) && hr != E_INVALIDARG) {
*errorMessage= msgComFailed("GetModuleNameStringWide", hr);
return false;
}
module.moduleName = QString::fromUtf16(wszBuf);
modules->push_back(module);
}
}
return true;
}
}
}

View File

@@ -0,0 +1,49 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef CDBMODULES_H
#define CDBMODULES_H
#include <QtCore/QList>
#include <QtCore/QString>
#include <windows.h>
#include <inc/dbgeng.h>
namespace Debugger {
namespace Internal {
class Module;
bool getModuleList(IDebugSymbols3 *syms, QList<Module> *modules, QString *errorMessage);
}
}
#endif // CDBMODULES_H

View File

@@ -403,45 +403,67 @@ bool CdbSymbolGroupContext::assignValue(const QString &iname, const QString &val
// format an array of integers as "0x323, 0x2322, ..."
template <class Integer>
static QString hexFormatArrayHelper(const Integer *array, int size)
static QString formatArrayHelper(const Integer *array, int size, int base = 10)
{
QString rc;
const QString hexPrefix = QLatin1String("0x");
const QString separator= QLatin1String(", ");
const bool hex = base == 16;
for (int i = 0; i < size; i++) {
if (i)
rc += separator;
rc += hexPrefix;
rc += QString::number(array[i], 16);
if (hex)
rc += hexPrefix;
rc += QString::number(array[i], base);
}
return rc;
}
QString CdbSymbolGroupContext::hexFormatArray(const unsigned short *array, int size)
{
return hexFormatArrayHelper(array, size);
return formatArrayHelper(array, size, 16);
}
QString CdbSymbolGroupContext::debugValueToString(const DEBUG_VALUE &dv, IDebugControl4 *ctl, QString *type)
// Helper to format an integer with
// a hex prefix in case base = 16
template <class Integer>
inline QString formatInteger(Integer value, int base)
{
QString rc;
if (base == 16)
rc = QLatin1String("0x");
rc += QString::number(value, base);
return rc;
}
QString CdbSymbolGroupContext::debugValueToString(const DEBUG_VALUE &dv, IDebugControl4 *ctl,
QString *qType,
int integerBase)
{
switch (dv.Type) {
case DEBUG_VALUE_INT8:
*type = QLatin1String("char");
return QString::number(dv.I8);
if (qType)
*qType = QLatin1String("char");
return formatInteger(dv.I8, integerBase);
case DEBUG_VALUE_INT16:
*type = QLatin1String("short");
return QString::number(static_cast<short>(dv.I16));
if (qType)
*qType = QLatin1String("short");
return formatInteger(static_cast<short>(dv.I16), integerBase);
case DEBUG_VALUE_INT32:
*type = QLatin1String("long");
return QString::number(static_cast<long>(dv.I32));
if (qType)
*qType = QLatin1String("long");
return formatInteger(static_cast<long>(dv.I32), integerBase);
case DEBUG_VALUE_INT64:
*type = QLatin1String("long long");
return QString::number(static_cast<long long>(dv.I64));
if (qType)
*qType = QLatin1String("long long");
return formatInteger(static_cast<long long>(dv.I64), integerBase);
case DEBUG_VALUE_FLOAT32:
*type = QLatin1String("float");
if (qType)
*qType = QLatin1String("float");
return QString::number(dv.F32);
case DEBUG_VALUE_FLOAT64:
*type = QLatin1String("double");
if (qType)
*qType = QLatin1String("double");
return QString::number(dv.F64);
case DEBUG_VALUE_FLOAT80:
case DEBUG_VALUE_FLOAT128: { // Convert to double
@@ -449,28 +471,32 @@ QString CdbSymbolGroupContext::debugValueToString(const DEBUG_VALUE &dv, IDebugC
double d = 0.0;
if (SUCCEEDED(ctl->CoerceValue(const_cast<DEBUG_VALUE*>(&dv), DEBUG_VALUE_FLOAT64, &doubleValue)))
d = dv.F64;
*type = dv.Type == DEBUG_VALUE_FLOAT80 ? QLatin1String("80bit-float") : QLatin1String("128bit-float");
if (qType)
*qType = QLatin1String(dv.Type == DEBUG_VALUE_FLOAT80 ? "80bit-float" : "128bit-float");
return QString::number(d);
}
case DEBUG_VALUE_VECTOR64: {
*type = QLatin1String("64bit-vector");
QString rc = QLatin1String("bytes: ");
rc += hexFormatArrayHelper(dv.VI8, 8);
rc += QLatin1String(" long: ");
rc += hexFormatArrayHelper(dv.VI32, 2);
return rc;
}
if (qType)
*qType = QLatin1String("64bit-vector");
QString rc = QLatin1String("bytes: ");
rc += formatArrayHelper(dv.VI8, 8, integerBase);
rc += QLatin1String(" long: ");
rc += formatArrayHelper(dv.VI32, 2, integerBase);
return rc;
}
case DEBUG_VALUE_VECTOR128: {
*type = QLatin1String("128bit-vector");
QString rc = QLatin1String("bytes: ");
rc += hexFormatArrayHelper(dv.VI8, 16);
rc += QLatin1String(" long long: ");
rc += hexFormatArrayHelper(dv.VI64, 2);
return rc;
if (qType)
*qType = QLatin1String("128bit-vector");
QString rc = QLatin1String("bytes: ");
rc += formatArrayHelper(dv.VI8, 16, integerBase);
rc += QLatin1String(" long long: ");
rc += formatArrayHelper(dv.VI64, 2, integerBase);
return rc;
}
}
}
*type = QString::fromLatin1("Unknown type #%1:").arg(dv.Type);
return hexFormatArrayHelper(dv.RawBytes, 24);
if (qType)
*qType = QString::fromLatin1("Unknown type #%1:").arg(dv.Type);
return formatArrayHelper(dv.RawBytes, 24, integerBase);
}
// - Watch model functions

View File

@@ -92,7 +92,7 @@ public:
inline bool isExpanded(const QString &prefix) const { return symbolState(prefix) == ExpandedSymbol; }
// Helper to convert a DEBUG_VALUE structure to a string representation
static QString debugValueToString(const DEBUG_VALUE &dv, IDebugControl4 *ctl, QString *type);
static QString debugValueToString(const DEBUG_VALUE &dv, IDebugControl4 *ctl, QString *type = 0, int integerBase = 10);
// format an array of unsigned longs as "0x323, 0x2322, ..."
static QString hexFormatArray(const unsigned short *array, int size);

View File

@@ -54,7 +54,7 @@ namespace Internal {
//////////////////////////////////////////////////////////////////////////
DebuggerSettings::DebuggerSettings(QObject *parent)
: QObject(parent)
: QObject(parent), m_registerFormatGroup(0)
{}
DebuggerSettings::~DebuggerSettings()
@@ -74,25 +74,25 @@ void DebuggerSettings::readSettings(QSettings *settings)
item->readSettings(settings);
}
void DebuggerSettings::writeSettings(QSettings *settings)
void DebuggerSettings::writeSettings(QSettings *settings) const
{
foreach (SavedAction *item, m_items)
item->writeSettings(settings);
}
SavedAction *DebuggerSettings::item(int code)
SavedAction *DebuggerSettings::item(int code) const
{
QTC_ASSERT(m_items.value(code, 0), return 0);
return m_items.value(code, 0);
}
QString DebuggerSettings::dump()
QString DebuggerSettings::dump() const
{
QString out;
QTextStream ts(&out);
ts << "Debugger settings: ";
foreach (SavedAction *item, m_items)
ts << "\n" << item->value().toString();
ts << '\n' << item->value().toString();
return out;
}
@@ -153,27 +153,27 @@ DebuggerSettings *DebuggerSettings::instance()
//
// DebuggingHelper
//
const QString debugModeGroup = QLatin1String("DebugMode");
item = new SavedAction(instance);
instance->insertItem(UseDebuggingHelpers, item);
item->setDefaultValue(true);
item->setSettingsKey("DebugMode", "UseDebuggingHelper");
item->setSettingsKey(debugModeGroup, QLatin1String("UseDebuggingHelper"));
item->setText(tr("Use Debugging Helper"));
item->setCheckable(true);
item->setDefaultValue(true);
item = new SavedAction(instance);
instance->insertItem(UseCustomDebuggingHelperLocation, item);
item->setSettingsKey("DebugMode", "CustomDebuggingHelperLocation");
item->setSettingsKey(debugModeGroup, QLatin1String("CustomDebuggingHelperLocation"));
item->setCheckable(true);
item = new SavedAction(instance);
instance->insertItem(CustomDebuggingHelperLocation, item);
item->setSettingsKey("DebugMode", "CustomDebuggingHelperLocation");
item->setSettingsKey(debugModeGroup, QLatin1String("CustomDebuggingHelperLocation"));
item = new SavedAction(instance);
instance->insertItem(DebugDebuggingHelpers, item);
item->setSettingsKey("DebugMode", "DebugDebuggingHelpers");
item->setSettingsKey(debugModeGroup, QLatin1String("DebugDebuggingHelpers"));
item->setText(tr("Debug debugging helper"));
item->setCheckable(true);
@@ -193,115 +193,120 @@ DebuggerSettings *DebuggerSettings::instance()
// Registers
//
QActionGroup *registerFormatGroup = new QActionGroup(instance);
registerFormatGroup->setExclusive(true);
instance->m_registerFormatGroup = new QActionGroup(instance);
instance->m_registerFormatGroup->setExclusive(true);
item = new SavedAction(instance);
item->setText(tr("Hexadecimal"));
item->setCheckable(true);
item->setSettingsKey("DebugMode", "FormatHexadecimal");
item->setSettingsKey(debugModeGroup, QLatin1String("FormatHexadecimal"));
item->setChecked(true);
item->setData(FormatHexadecimal);
instance->insertItem(FormatHexadecimal, item);
registerFormatGroup->addAction(item);
instance->m_registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(tr("Decimal"));
item->setCheckable(true);
item->setSettingsKey("DebugMode", "FormatDecimal");
item->setSettingsKey(debugModeGroup, QLatin1String("FormatDecimal"));
item->setData(FormatDecimal);
instance->insertItem(FormatDecimal, item);
registerFormatGroup->addAction(item);
instance->m_registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(tr("Octal"));
item->setCheckable(true);
item->setSettingsKey("DebugMode", "FormatOctal");
item->setSettingsKey(debugModeGroup, QLatin1String("FormatOctal"));
item->setData(FormatOctal);
instance->insertItem(FormatOctal, item);
registerFormatGroup->addAction(item);
instance->m_registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(tr("Binary"));
item->setCheckable(true);
item->setSettingsKey("DebugMode", "FormatBinary");
item->setSettingsKey(debugModeGroup, QLatin1String("FormatBinary"));
item->setData(FormatBinary);
instance->insertItem(FormatBinary, item);
registerFormatGroup->addAction(item);
instance->m_registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(tr("Raw"));
item->setCheckable(true);
item->setSettingsKey("DebugMode", "FormatRaw");
item->setSettingsKey(debugModeGroup, QLatin1String("FormatRaw"));
instance->insertItem(FormatRaw, item);
registerFormatGroup->addAction(item);
item->setData(FormatRaw);
instance->m_registerFormatGroup->addAction(item);
item = new SavedAction(instance);
item->setText(tr("Natural"));
item->setCheckable(true);
item->setSettingsKey("DebugMode", "FormatNatural");
item->setSettingsKey(debugModeGroup, QLatin1String("FormatNatural"));
item->setData(FormatNatural);
instance->insertItem(FormatNatural, item);
registerFormatGroup->addAction(item);
instance->m_registerFormatGroup->addAction(item);
//
// Settings
//
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "Location");
item->setSettingsKey(debugModeGroup, QLatin1String("Location"));
instance->insertItem(GdbLocation, item);
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "Environment");
item->setSettingsKey(debugModeGroup, QLatin1String("Environment"));
instance->insertItem(GdbEnvironment, item);
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "ScriptFile");
item->setSettingsKey(debugModeGroup, QLatin1String("ScriptFile"));
instance->insertItem(GdbScriptFile, item);
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "AutoQuit");
item->setSettingsKey(debugModeGroup, QLatin1String("AutoQuit"));
item->setText(tr("Automatically quit debugger"));
item->setCheckable(true);
instance->insertItem(AutoQuit, item);
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "UseToolTips");
item->setSettingsKey(debugModeGroup, QLatin1String("UseToolTips"));
item->setText(tr("Use tooltips when debugging"));
item->setCheckable(true);
instance->insertItem(UseToolTips, item);
item = new SavedAction(instance);
item->setDefaultValue("xterm");
item->setSettingsKey("DebugMode", "Terminal");
item->setDefaultValue(QLatin1String("xterm"));
item->setSettingsKey(debugModeGroup, QLatin1String("Terminal"));
instance->insertItem(TerminalApplication, item);
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "ListSourceFiles");
item->setSettingsKey(debugModeGroup, QLatin1String("ListSourceFiles"));
item->setText(tr("List source files"));
item->setCheckable(true);
instance->insertItem(ListSourceFiles, item);
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "SkipKnownFrames");
item->setSettingsKey(debugModeGroup, QLatin1String("SkipKnownFrames"));
item->setText(tr("Skip known frames"));
item->setCheckable(true);
instance->insertItem(SkipKnownFrames, item);
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "AllPluginBreakpoints");
item->setSettingsKey(debugModeGroup, QLatin1String("AllPluginBreakpoints"));
instance->insertItem(AllPluginBreakpoints, item);
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "SelectedPluginBreakpoints");
item->setSettingsKey(debugModeGroup, QLatin1String("SelectedPluginBreakpoints"));
instance->insertItem(SelectedPluginBreakpoints, item);
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "NoPluginBreakpoints");
item->setSettingsKey(debugModeGroup, QLatin1String("NoPluginBreakpoints"));
instance->insertItem(NoPluginBreakpoints, item);
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "SelectedPluginBreakpointsPattern");
item->setSettingsKey(debugModeGroup, QLatin1String("SelectedPluginBreakpointsPattern"));
instance->insertItem(SelectedPluginBreakpointsPattern, item);
item = new SavedAction(instance);
item->setSettingsKey("DebugMode", "MaximalStackDepth");
item->setSettingsKey(debugModeGroup, QLatin1String("MaximalStackDepth"));
item->setDefaultValue(20);
instance->insertItem(MaximalStackDepth, item);
@@ -316,6 +321,11 @@ DebuggerSettings *DebuggerSettings::instance()
return instance;
}
int DebuggerSettings::checkedRegisterFormatAction() const
{
return m_registerFormatGroup->checkedAction()->data().toInt();
}
//////////////////////////////////////////////////////////////////////////
//
// DebuggerActions
@@ -327,6 +337,11 @@ SavedAction *theDebuggerAction(int code)
return DebuggerSettings::instance()->item(code);
}
int checkedRegisterFormatAction()
{
return DebuggerSettings::instance()->checkedRegisterFormatAction();
}
bool theDebuggerBoolSetting(int code)
{
return DebuggerSettings::instance()->item(code)->value().toBool();

View File

@@ -34,6 +34,9 @@
#include <utils/savedaction.h>
QT_BEGIN_NAMESPACE
class QActionGroup;
QT_END_NAMESPACE
namespace Debugger {
namespace Internal {
@@ -46,18 +49,22 @@ public:
~DebuggerSettings();
void insertItem(int code, Core::Utils::SavedAction *item);
Core::Utils::SavedAction *item(int code);
Core::Utils::SavedAction *item(int code) const;
QString dump();
QString dump() const;
static DebuggerSettings *instance();
// Return one of FormatHexadecimal, FormatDecimal,...
int checkedRegisterFormatAction() const;
public slots:
void readSettings(QSettings *settings);
void writeSettings(QSettings *settings);
void writeSettings(QSettings *settings) const;
private:
QHash<int, Core::Utils::SavedAction *> m_items;
QActionGroup *m_registerFormatGroup;
};
@@ -125,7 +132,10 @@ enum DebuggerActionCode
// singleton access
Core::Utils::SavedAction *theDebuggerAction(int code);
// convienience
// Return one of FormatHexadecimal, FormatDecimal,...
int checkedRegisterFormatAction();
// convenience
bool theDebuggerBoolSetting(int code);
QString theDebuggerStringSetting(int code);

View File

@@ -650,6 +650,19 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
connect(resetToSimpleAction, SIGNAL(triggered()),
m_manager, SLOT(setSimpleDockWidgetArrangement()));
connect(theDebuggerAction(FormatHexadecimal), SIGNAL(triggered()),
m_manager, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatDecimal), SIGNAL(triggered()),
m_manager, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatOctal), SIGNAL(triggered()),
m_manager, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatBinary), SIGNAL(triggered()),
m_manager, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatRaw), SIGNAL(triggered()),
m_manager, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatNatural), SIGNAL(triggered()),
m_manager, SLOT(reloadRegisters()));
// FIXME:
m_generalOptionPage = new GdbOptionPage;
addObject(m_generalOptionPage);

View File

@@ -221,19 +221,6 @@ void GdbEngine::initializeConnections()
connect(theDebuggerAction(RecheckDebuggingHelpers), SIGNAL(triggered()),
this, SLOT(recheckDebuggingHelperAvailability()));
connect(theDebuggerAction(FormatHexadecimal), SIGNAL(triggered()),
this, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatDecimal), SIGNAL(triggered()),
this, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatOctal), SIGNAL(triggered()),
this, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatBinary), SIGNAL(triggered()),
this, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatRaw), SIGNAL(triggered()),
this, SLOT(reloadRegisters()));
connect(theDebuggerAction(FormatNatural), SIGNAL(triggered()),
this, SLOT(reloadRegisters()));
connect(theDebuggerAction(ExpandStack), SIGNAL(triggered()),
this, SLOT(reloadFullStack()));
connect(theDebuggerAction(MaximalStackDepth), SIGNAL(triggered()),
@@ -2619,22 +2606,28 @@ void GdbEngine::handleStackListThreads(const GdbResultRecord &record, int id)
//
//////////////////////////////////////////////////////////////////////
static inline char registerFormatChar()
{
switch(checkedRegisterFormatAction()) {
case FormatHexadecimal:
return 'x';
case FormatDecimal:
return 'd';
case FormatOctal:
return 'o';
case FormatBinary:
return 't';
case FormatRaw:
return 'r';
default:
break;
}
return 'N';
}
void GdbEngine::reloadRegisters()
{
QString format;
if (theDebuggerAction(FormatHexadecimal)->isChecked())
format = "x";
else if (theDebuggerAction(FormatDecimal)->isChecked())
format = "d";
else if (theDebuggerAction(FormatOctal)->isChecked())
format = "o";
else if (theDebuggerAction(FormatBinary)->isChecked())
format = "t";
else if (theDebuggerAction(FormatRaw)->isChecked())
format = "r";
else
format = "N";
sendCommand("-data-list-register-values " + format, RegisterListValues);
sendCommand(QLatin1String("-data-list-register-values ") + QLatin1Char(registerFormatChar()), RegisterListValues);
}
void GdbEngine::handleRegisterListNames(const GdbResultRecord &record)