Fixes: cdbdebugger: some cosmetics

This commit is contained in:
hjk
2009-02-09 13:07:38 +01:00
parent 95d8b84404
commit bb146f4da0
7 changed files with 105 additions and 117 deletions

View File

@@ -1,4 +1,4 @@
#include "msvcdebugengine.h" #include "cdbdebugengine.h"
#include "assert.h" #include "assert.h"
#include "debuggermanager.h" #include "debuggermanager.h"
@@ -16,7 +16,7 @@ using namespace Debugger;
using namespace Debugger::Internal; using namespace Debugger::Internal;
MSVCDebugEngine::MSVCDebugEngine(DebuggerManager *parent) CdbDebugEngine::CdbDebugEngine(DebuggerManager *parent)
: IDebuggerEngine(parent), : IDebuggerEngine(parent),
m_hDebuggeeProcess(0), m_hDebuggeeProcess(0),
m_hDebuggeeThread(0), m_hDebuggeeThread(0),
@@ -50,7 +50,7 @@ MSVCDebugEngine::MSVCDebugEngine(DebuggerManager *parent)
} }
} }
MSVCDebugEngine::~MSVCDebugEngine() CdbDebugEngine::~CdbDebugEngine()
{ {
if (m_pDebugClient) if (m_pDebugClient)
m_pDebugClient->Release(); m_pDebugClient->Release();
@@ -64,13 +64,13 @@ MSVCDebugEngine::~MSVCDebugEngine()
m_pDebugRegisters->Release(); m_pDebugRegisters->Release();
} }
void MSVCDebugEngine::startWatchTimer() void CdbDebugEngine::startWatchTimer()
{ {
if (m_watchTimer == -1) if (m_watchTimer == -1)
m_watchTimer = startTimer(0); m_watchTimer = startTimer(0);
} }
void MSVCDebugEngine::killWatchTimer() void CdbDebugEngine::killWatchTimer()
{ {
if (m_watchTimer != -1) { if (m_watchTimer != -1) {
killTimer(m_watchTimer); killTimer(m_watchTimer);
@@ -78,16 +78,16 @@ void MSVCDebugEngine::killWatchTimer()
} }
} }
void MSVCDebugEngine::shutdown() void CdbDebugEngine::shutdown()
{ {
exitDebugger(); exitDebugger();
} }
void MSVCDebugEngine::setToolTipExpression(const QPoint &pos, const QString &exp) void CdbDebugEngine::setToolTipExpression(const QPoint &pos, const QString &exp)
{ {
} }
bool MSVCDebugEngine::startDebugger() bool CdbDebugEngine::startDebugger()
{ {
q->showStatusMessage("Starting Debugger", -1); q->showStatusMessage("Starting Debugger", -1);
@@ -110,7 +110,7 @@ bool MSVCDebugEngine::startDebugger()
//m_pDebugSymbols->AddSymbolOptions(SYMOPT_CASE_INSENSITIVE | SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_DEBUG | SYMOPT_LOAD_LINES | SYMOPT_OMAP_FIND_NEAREST | SYMOPT_AUTO_PUBLICS | SYMOPT_NO_IMAGE_SEARCH); //m_pDebugSymbols->AddSymbolOptions(SYMOPT_CASE_INSENSITIVE | SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS | SYMOPT_DEBUG | SYMOPT_LOAD_LINES | SYMOPT_OMAP_FIND_NEAREST | SYMOPT_AUTO_PUBLICS | SYMOPT_NO_IMAGE_SEARCH);
if (q->startMode() == q->attachExternal) { if (q->startMode() == q->attachExternal) {
qWarning("MSVCDebugEngine: attach to process not yet implemented!"); qWarning("CdbDebugEngine: attach to process not yet implemented!");
} else { } else {
hr = m_pDebugClient->CreateProcess2Wide(NULL, hr = m_pDebugClient->CreateProcess2Wide(NULL,
const_cast<PWSTR>(filename.utf16()), const_cast<PWSTR>(filename.utf16()),
@@ -130,19 +130,19 @@ bool MSVCDebugEngine::startDebugger()
return true; return true;
} }
void MSVCDebugEngine::exitDebugger() void CdbDebugEngine::exitDebugger()
{ {
m_pDebugClient->TerminateCurrentProcess(); m_pDebugClient->TerminateCurrentProcess();
killWatchTimer(); killWatchTimer();
} }
void MSVCDebugEngine::updateWatchModel() void CdbDebugEngine::updateWatchModel()
{ {
} }
void MSVCDebugEngine::stepExec() void CdbDebugEngine::stepExec()
{ {
//qDebug() << "MSVCDebugEngine::stepExec()"; //qDebug() << "CdbDebugEngine::stepExec()";
//m_pDebugControl->Execute(DEBUG_OUTCTL_THIS_CLIENT, "p", 0); //m_pDebugControl->Execute(DEBUG_OUTCTL_THIS_CLIENT, "p", 0);
HRESULT hr; HRESULT hr;
hr = m_pDebugControl->SetExecutionStatus(DEBUG_STATUS_STEP_INTO); hr = m_pDebugControl->SetExecutionStatus(DEBUG_STATUS_STEP_INTO);
@@ -150,9 +150,9 @@ void MSVCDebugEngine::stepExec()
startWatchTimer(); startWatchTimer();
} }
void MSVCDebugEngine::stepOutExec() void CdbDebugEngine::stepOutExec()
{ {
//qDebug() << "MSVCDebugEngine::stepOutExec()"; //qDebug() << "CdbDebugEngine::stepOutExec()";
StackHandler* sh = qq->stackHandler(); StackHandler* sh = qq->stackHandler();
const int idx = sh->currentIndex() + 1; const int idx = sh->currentIndex() + 1;
QList<StackFrame> stackframes = sh->frames(); QList<StackFrame> stackframes = sh->frames();
@@ -191,26 +191,26 @@ void MSVCDebugEngine::stepOutExec()
continueInferior(); continueInferior();
} }
void MSVCDebugEngine::nextExec() void CdbDebugEngine::nextExec()
{ {
//qDebug() << "MSVCDebugEngine::nextExec()"; //qDebug() << "CdbDebugEngine::nextExec()";
HRESULT hr; HRESULT hr;
hr = m_pDebugControl->SetExecutionStatus(DEBUG_STATUS_STEP_OVER); hr = m_pDebugControl->SetExecutionStatus(DEBUG_STATUS_STEP_OVER);
startWatchTimer(); startWatchTimer();
} }
void MSVCDebugEngine::stepIExec() void CdbDebugEngine::stepIExec()
{ {
qWarning("MSVCDebugEngine::stepIExec() not implemented"); qWarning("CdbDebugEngine::stepIExec() not implemented");
} }
void MSVCDebugEngine::nextIExec() void CdbDebugEngine::nextIExec()
{ {
m_pDebugControl->Execute(DEBUG_OUTCTL_THIS_CLIENT, "p", 0); m_pDebugControl->Execute(DEBUG_OUTCTL_THIS_CLIENT, "p", 0);
startWatchTimer(); startWatchTimer();
} }
void MSVCDebugEngine::continueInferior() void CdbDebugEngine::continueInferior()
{ {
killWatchTimer(); killWatchTimer();
q->resetLocation(); q->resetLocation();
@@ -224,12 +224,12 @@ void MSVCDebugEngine::continueInferior()
qq->notifyInferiorRunning(); qq->notifyInferiorRunning();
} }
void MSVCDebugEngine::runInferior() void CdbDebugEngine::runInferior()
{ {
continueInferior(); continueInferior();
} }
void MSVCDebugEngine::interruptInferior() void CdbDebugEngine::interruptInferior()
{ {
//TODO: better use IDebugControl::SetInterrupt? //TODO: better use IDebugControl::SetInterrupt?
if (!m_hDebuggeeProcess) if (!m_hDebuggeeProcess)
@@ -241,27 +241,27 @@ void MSVCDebugEngine::interruptInferior()
qq->notifyInferiorStopped(); qq->notifyInferiorStopped();
} }
void MSVCDebugEngine::runToLineExec(const QString &fileName, int lineNumber) void CdbDebugEngine::runToLineExec(const QString &fileName, int lineNumber)
{ {
} }
void MSVCDebugEngine::runToFunctionExec(const QString &functionName) void CdbDebugEngine::runToFunctionExec(const QString &functionName)
{ {
} }
void MSVCDebugEngine::jumpToLineExec(const QString &fileName, int lineNumber) void CdbDebugEngine::jumpToLineExec(const QString &fileName, int lineNumber)
{ {
} }
void MSVCDebugEngine::assignValueInDebugger(const QString &expr, const QString &value) void CdbDebugEngine::assignValueInDebugger(const QString &expr, const QString &value)
{ {
} }
void MSVCDebugEngine::executeDebuggerCommand(const QString &/*command*/) void CdbDebugEngine::executeDebuggerCommand(const QString &/*command*/)
{ {
} }
void MSVCDebugEngine::activateFrame(int frameIndex) void CdbDebugEngine::activateFrame(int frameIndex)
{ {
if (q->status() != DebuggerInferiorStopped) if (q->status() != DebuggerInferiorStopped)
return; return;
@@ -287,7 +287,7 @@ void MSVCDebugEngine::activateFrame(int frameIndex)
qDebug() << "FULL NAME NOT USABLE: " << frame.file; qDebug() << "FULL NAME NOT USABLE: " << frame.file;
} }
void MSVCDebugEngine::selectThread(int index) void CdbDebugEngine::selectThread(int index)
{ {
//reset location arrow //reset location arrow
q->resetLocation(); q->resetLocation();
@@ -298,7 +298,7 @@ void MSVCDebugEngine::selectThread(int index)
updateStackTrace(); updateStackTrace();
} }
void MSVCDebugEngine::attemptBreakpointSynchronization() void CdbDebugEngine::attemptBreakpointSynchronization()
{ {
BreakHandler *handler = qq->breakHandler(); BreakHandler *handler = qq->breakHandler();
//qDebug() << "attemptBreakpointSynchronization"; //qDebug() << "attemptBreakpointSynchronization";
@@ -333,35 +333,35 @@ void MSVCDebugEngine::attemptBreakpointSynchronization()
} }
} }
void MSVCDebugEngine::loadSessionData() void CdbDebugEngine::loadSessionData()
{ {
} }
void MSVCDebugEngine::saveSessionData() void CdbDebugEngine::saveSessionData()
{ {
} }
void MSVCDebugEngine::reloadDisassembler() void CdbDebugEngine::reloadDisassembler()
{ {
} }
void MSVCDebugEngine::reloadModules() void CdbDebugEngine::reloadModules()
{ {
} }
void MSVCDebugEngine::loadSymbols(const QString &moduleName) void CdbDebugEngine::loadSymbols(const QString &moduleName)
{ {
} }
void MSVCDebugEngine::loadAllSymbols() void CdbDebugEngine::loadAllSymbols()
{ {
} }
void MSVCDebugEngine::reloadRegisters() void CdbDebugEngine::reloadRegisters()
{ {
} }
void MSVCDebugEngine::timerEvent(QTimerEvent* te) void CdbDebugEngine::timerEvent(QTimerEvent* te)
{ {
if (te->timerId() != m_watchTimer) if (te->timerId() != m_watchTimer)
return; return;
@@ -391,7 +391,7 @@ void MSVCDebugEngine::timerEvent(QTimerEvent* te)
} }
} }
void MSVCDebugEngine::handleDebugEvent() void CdbDebugEngine::handleDebugEvent()
{ {
if (m_bIgnoreNextDebugEvent) { if (m_bIgnoreNextDebugEvent) {
startWatchTimer(); startWatchTimer();
@@ -414,7 +414,7 @@ void MSVCDebugEngine::handleDebugEvent()
//} //}
} }
void MSVCDebugEngine::updateThreadList() void CdbDebugEngine::updateThreadList()
{ {
ThreadsHandler* th = qq->threadsHandler(); ThreadsHandler* th = qq->threadsHandler();
QList<ThreadData> threads; QList<ThreadData> threads;
@@ -435,7 +435,7 @@ void MSVCDebugEngine::updateThreadList()
th->setThreads(threads); th->setThreads(threads);
} }
void MSVCDebugEngine::updateStackTrace() void CdbDebugEngine::updateStackTrace()
{ {
//qDebug() << "updateStackTrace()"; //qDebug() << "updateStackTrace()";
HRESULT hr; HRESULT hr;
@@ -503,17 +503,17 @@ void MSVCDebugEngine::updateStackTrace()
//m_pDebugControl->OutputStackTrace(DEBUG_OUTCTL_THIS_CLIENT, frames, numFramesFilled, DEBUG_STACK_SOURCE_LINE); //m_pDebugControl->OutputStackTrace(DEBUG_OUTCTL_THIS_CLIENT, frames, numFramesFilled, DEBUG_STACK_SOURCE_LINE);
} }
void MSVCDebugEngine::handleDebugOutput(const char* szOutputString) void CdbDebugEngine::handleDebugOutput(const char* szOutputString)
{ {
qq->showApplicationOutput("app-dbgoutput", QString::fromLocal8Bit(szOutputString)); qq->showApplicationOutput("app-dbgoutput", QString::fromLocal8Bit(szOutputString));
} }
void MSVCDebugEngine::handleBreakpointEvent(PDEBUG_BREAKPOINT pBP) void CdbDebugEngine::handleBreakpointEvent(PDEBUG_BREAKPOINT pBP)
{ {
qDebug() << "MSVCDebugEngine::handleBreakpointEvent()"; qDebug() << "CdbDebugEngine::handleBreakpointEvent()";
} }
IDebuggerEngine *createWinEngine(DebuggerManager *parent) IDebuggerEngine *createWinEngine(DebuggerManager *parent)
{ {
return new MSVCDebugEngine(parent); return new CdbDebugEngine(parent);
} }

View File

@@ -1,9 +1,10 @@
#ifndef __MSVCDEBUGENGINE_H__ #ifndef DEBUGGER_CDBENGINE_H
#define __MSVCDEBUGENGINE_H__ #define DEBUGGER_CDBENGINE_H
#include "idebuggerengine.h" #include "idebuggerengine.h"
#include "msvcdebugeventcallback.h" #include "cdbdebugeventcallback.h"
#include "msvcdebugoutput.h" #include "cdbdebugoutput.h"
#include <windows.h> #include <windows.h>
namespace Debugger { namespace Debugger {
@@ -12,12 +13,12 @@ namespace Internal {
class DebuggerManager; class DebuggerManager;
class IDebuggerManagerAccessForEngines; class IDebuggerManagerAccessForEngines;
class MSVCDebugEngine : public IDebuggerEngine class CdbDebugEngine : public IDebuggerEngine
{ {
Q_OBJECT Q_OBJECT
public: public:
MSVCDebugEngine(DebuggerManager *parent); CdbDebugEngine(DebuggerManager *parent);
~MSVCDebugEngine(); ~CdbDebugEngine();
virtual void shutdown(); virtual void shutdown();
virtual void setToolTipExpression(const QPoint &pos, const QString &exp); virtual void setToolTipExpression(const QPoint &pos, const QString &exp);
@@ -63,7 +64,7 @@ protected:
private: private:
void startWatchTimer(); void startWatchTimer();
void killWatchTimer(); void killWatchTimer();
bool isDebuggeeRunning() { return m_watchTimer != -1; } bool isDebuggeeRunning() const { return m_watchTimer != -1; }
void handleDebugEvent(); void handleDebugEvent();
void updateThreadList(); void updateThreadList();
void updateStackTrace(); void updateStackTrace();
@@ -82,17 +83,17 @@ private:
IDebugSystemObjects4* m_pDebugSystemObjects; IDebugSystemObjects4* m_pDebugSystemObjects;
IDebugSymbols3* m_pDebugSymbols; IDebugSymbols3* m_pDebugSymbols;
IDebugRegisters2* m_pDebugRegisters; IDebugRegisters2* m_pDebugRegisters;
MSVCDebugEventCallback m_debugEventCallBack; CdbDebugEventCallback m_debugEventCallBack;
MSVCDebugOutput m_debugOutputCallBack; CdbDebugOutput m_debugOutputCallBack;
DebuggerManager *q; DebuggerManager *q;
IDebuggerManagerAccessForEngines *qq; IDebuggerManagerAccessForEngines *qq;
friend class MSVCDebugEventCallback; friend class CdbDebugEventCallback;
friend class MSVCDebugOutput; friend class CdbDebugOutput;
}; };
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger
#endif #endif // DEBUGGER_CDBENGINE_H

View File

@@ -1,18 +1,16 @@
#include "msvcdebugeventcallback.h" #include "cdbdebugeventcallback.h"
#include "msvcdebugengine.h" #include "cdbcdebugengine.h"
#include "debuggermanager.h" #include "debuggermanager.h"
#include <QDebug> #include <QtCore/QDebug>
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
STDMETHODIMP STDMETHODIMP MSVCDebugEventCallback::QueryInterface(
MSVCDebugEventCallback::QueryInterface(
THIS_ THIS_
IN REFIID InterfaceId, IN REFIID InterfaceId,
OUT PVOID* Interface OUT PVOID* Interface)
)
{ {
*Interface = NULL; *Interface = NULL;
@@ -29,30 +27,21 @@ MSVCDebugEventCallback::QueryInterface(
} }
} }
STDMETHODIMP_(ULONG) STDMETHODIMP_(ULONG) MSVCDebugEventCallback::AddRef(THIS)
MSVCDebugEventCallback::AddRef(
THIS
)
{ {
// This class is designed to be static so // This class is designed to be static so
// there's no true refcount. // there's no true refcount.
return 1; return 1;
} }
STDMETHODIMP_(ULONG) STDMETHODIMP_(ULONG) MSVCDebugEventCallback::Release(THIS)
MSVCDebugEventCallback::Release(
THIS
)
{ {
// This class is designed to be static so // This class is designed to be static so
// there's no true refcount. // there's no true refcount.
return 0; return 0;
} }
STDMETHODIMP MSVCDebugEventCallback::GetInterestMask( STDMETHODIMP MSVCDebugEventCallback::GetInterestMask(THIS_ __out PULONG mask)
THIS_
__out PULONG mask
)
{ {
*mask = DEBUG_EVENT_CREATE_PROCESS | DEBUG_EVENT_EXIT_PROCESS *mask = DEBUG_EVENT_CREATE_PROCESS | DEBUG_EVENT_EXIT_PROCESS
//| DEBUG_EVENT_CREATE_THREAD | DEBUG_EVENT_EXIT_THREAD //| DEBUG_EVENT_CREATE_THREAD | DEBUG_EVENT_EXIT_THREAD
@@ -62,10 +51,7 @@ STDMETHODIMP MSVCDebugEventCallback::GetInterestMask(
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::Breakpoint( STDMETHODIMP MSVCDebugEventCallback::Breakpoint(THIS_ __in PDEBUG_BREAKPOINT Bp)
THIS_
__in PDEBUG_BREAKPOINT Bp
)
{ {
qDebug() << "MSVCDebugEventCallback::Breakpoint"; qDebug() << "MSVCDebugEventCallback::Breakpoint";
m_pEngine->handleBreakpointEvent(Bp); m_pEngine->handleBreakpointEvent(Bp);

View File

@@ -1,4 +1,5 @@
#pragma once #ifndef DEBUGGER_CDBDEBUGEVENTCALLBACK_H
#define DEBUGGER_CDBDEBUGEVENTCALLBACK_H
#include <windows.h> #include <windows.h>
#include <dbgeng.h> #include <dbgeng.h>
@@ -6,12 +7,12 @@
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
class MSVCDebugEngine; class CdbDebugEngine;
class MSVCDebugEventCallback : public IDebugEventCallbacks class CdbDebugEventCallback : public IDebugEventCallbacks
{ {
public: public:
MSVCDebugEventCallback(MSVCDebugEngine* dbg) CdbDebugEventCallback(CdbDebugEngine* dbg)
: m_pEngine(dbg) : m_pEngine(dbg)
{} {}
@@ -124,8 +125,10 @@ public:
); );
private: private:
MSVCDebugEngine* m_pEngine; CdbDebugEngine* m_pEngine;
}; };
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger
#endif // DEBUGGER_CDBDEBUGEVENTCALLBACK_H

View File

@@ -1,14 +1,13 @@
#include <windows.h> #include <windows.h>
#include <dbgeng.h> #include <dbgeng.h>
#include "msvcdebugoutput.h" #include "cdbdebugoutput.h"
#include "msvcdebugengine.h" #include "cdbdebugengine.h"
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
STDMETHODIMP STDMETHODIMP MSVCDebugOutput::QueryInterface(
MSVCDebugOutput::QueryInterface(
THIS_ THIS_
IN REFIID InterfaceId, IN REFIID InterfaceId,
OUT PVOID* Interface OUT PVOID* Interface
@@ -29,28 +28,21 @@ MSVCDebugOutput::QueryInterface(
} }
} }
STDMETHODIMP_(ULONG) STDMETHODIMP_(ULONG) MSVCDebugOutput::AddRef(THIS)
MSVCDebugOutput::AddRef(
THIS
)
{ {
// This class is designed to be static so // This class is designed to be static so
// there's no true refcount. // there's no true refcount.
return 1; return 1;
} }
STDMETHODIMP_(ULONG) STDMETHODIMP_(ULONG) MSVCDebugOutput::Release(THIS)
MSVCDebugOutput::Release(
THIS
)
{ {
// This class is designed to be static so // This class is designed to be static so
// there's no true refcount. // there's no true refcount.
return 0; return 0;
} }
STDMETHODIMP STDMETHODIMP MSVCDebugOutput::Output(
MSVCDebugOutput::Output(
THIS_ THIS_
IN ULONG mask, IN ULONG mask,
IN PCSTR text IN PCSTR text

View File

@@ -1,15 +1,15 @@
#ifndef __MSVCDEBUGOUTPUT_H__ #ifndef DEBUGGER_CDBOUTPUT_H
#define __MSVCDEBUGOUTPUT_H__ #define DEBUGGER_CDBOUTPUT_H
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
class MSVCDebugEngine; class CdbDebugEngine;
class MSVCDebugOutput : public IDebugOutputCallbacks class CdbDebugOutput : public IDebugOutputCallbacks
{ {
public: public:
MSVCDebugOutput(MSVCDebugEngine* engine) CdbDebugOutput(CdbDebugEngine* engine)
: m_pEngine(engine) : m_pEngine(engine)
{} {}
@@ -34,10 +34,10 @@ public:
); );
private: private:
MSVCDebugEngine* m_pEngine; CdbDebugEngine* m_pEngine;
}; };
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger
#endif // #ifndef __MSVCDEBUGOUTPUT_H__ #endif // DEBUGGER_CDBOUTPUT_H

View File

@@ -84,13 +84,19 @@ HEADERS += $$PWD/modeltest.h
DEFINES += USE_MODEL_TEST=1 DEFINES += USE_MODEL_TEST=1
} }
false { win32 {
HEADERS += msvcdebugengine.h \
msvcdebugeventcallback.h \ HEADERS += \
msvcdebugoutput.h cdbdebugengine.h \
SOURCES += msvcdebugengine.cpp \ cdbdebugeventcallback.h \
msvcdebugeventcallback.cpp \ cdbdebugoutput.h
msvcdebugoutput.cpp
SOURCES += \
cdbdebugengine.cpp \
cdbdebugeventcallback.cpp \
cdbdebugoutput.cpp
LIBS += dbgeng.lib LIBS += dbgeng.lib
} }