Start experimental VS debugger support

This commit is contained in:
Friedemann Kleint
2009-02-20 14:56:36 +01:00
committed by unknown
parent 2047426bf8
commit 7959460ffb
8 changed files with 83 additions and 45 deletions

View File

@@ -11,12 +11,11 @@
#include <QFileInfo> #include <QFileInfo>
#define DBGHELP_TRANSLATE_TCHAR #define DBGHELP_TRANSLATE_TCHAR
#include <Dbghelp.h> #include <inc/Dbghelp.h>
using namespace Debugger; using namespace Debugger;
using namespace Debugger::Internal; using namespace Debugger::Internal;
CdbDebugEngine::CdbDebugEngine(DebuggerManager *parent) CdbDebugEngine::CdbDebugEngine(DebuggerManager *parent)
: IDebuggerEngine(parent), : IDebuggerEngine(parent),
m_hDebuggeeProcess(0), m_hDebuggeeProcess(0),
@@ -84,7 +83,7 @@ void CdbDebugEngine::shutdown()
exitDebugger(); exitDebugger();
} }
void CdbDebugEngine::setToolTipExpression(const QPoint &pos, const QString &exp) void CdbDebugEngine::setToolTipExpression(const QPoint & /*pos*/, const QString & /*exp*/)
{ {
} }
@@ -110,7 +109,7 @@ bool CdbDebugEngine::startDebugger()
m_pDebugSymbols->SetSymbolOptions(SYMOPT_CASE_INSENSITIVE | SYMOPT_UNDNAME | SYMOPT_LOAD_LINES | SYMOPT_OMAP_FIND_NEAREST | SYMOPT_AUTO_PUBLICS); m_pDebugSymbols->SetSymbolOptions(SYMOPT_CASE_INSENSITIVE | SYMOPT_UNDNAME | SYMOPT_LOAD_LINES | SYMOPT_OMAP_FIND_NEAREST | SYMOPT_AUTO_PUBLICS);
//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() == DebuggerManager::AttachExternal) {
qWarning("CdbDebugEngine: 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,
@@ -225,11 +224,6 @@ void CdbDebugEngine::continueInferior()
qq->notifyInferiorRunning(); qq->notifyInferiorRunning();
} }
void CdbDebugEngine::runInferior()
{
continueInferior();
}
void CdbDebugEngine::interruptInferior() void CdbDebugEngine::interruptInferior()
{ {
//TODO: better use IDebugControl::SetInterrupt? //TODO: better use IDebugControl::SetInterrupt?
@@ -244,18 +238,25 @@ void CdbDebugEngine::interruptInferior()
void CdbDebugEngine::runToLineExec(const QString &fileName, int lineNumber) void CdbDebugEngine::runToLineExec(const QString &fileName, int lineNumber)
{ {
Q_UNUSED(fileName)
Q_UNUSED(lineNumber)
} }
void CdbDebugEngine::runToFunctionExec(const QString &functionName) void CdbDebugEngine::runToFunctionExec(const QString &functionName)
{ {
Q_UNUSED(functionName)
} }
void CdbDebugEngine::jumpToLineExec(const QString &fileName, int lineNumber) void CdbDebugEngine::jumpToLineExec(const QString &fileName, int lineNumber)
{ {
Q_UNUSED(fileName)
Q_UNUSED(lineNumber)
} }
void CdbDebugEngine::assignValueInDebugger(const QString &expr, const QString &value) void CdbDebugEngine::assignValueInDebugger(const QString &expr, const QString &value)
{ {
Q_UNUSED(expr)
Q_UNUSED(value)
} }
void CdbDebugEngine::executeDebuggerCommand(const QString &/*command*/) void CdbDebugEngine::executeDebuggerCommand(const QString &/*command*/)
@@ -352,6 +353,7 @@ void CdbDebugEngine::reloadModules()
void CdbDebugEngine::loadSymbols(const QString &moduleName) void CdbDebugEngine::loadSymbols(const QString &moduleName)
{ {
Q_UNUSED(moduleName)
} }
void CdbDebugEngine::loadAllSymbols() void CdbDebugEngine::loadAllSymbols()
@@ -506,11 +508,12 @@ void CdbDebugEngine::updateStackTrace()
void CdbDebugEngine::handleDebugOutput(const char* szOutputString) void CdbDebugEngine::handleDebugOutput(const char* szOutputString)
{ {
qq->showApplicationOutput("app-dbgoutput", QString::fromLocal8Bit(szOutputString)); qq->showApplicationOutput(QString::fromLocal8Bit(szOutputString));
} }
void CdbDebugEngine::handleBreakpointEvent(PDEBUG_BREAKPOINT pBP) void CdbDebugEngine::handleBreakpointEvent(PDEBUG_BREAKPOINT pBP)
{ {
Q_UNUSED(pBP)
qDebug() << "CdbDebugEngine::handleBreakpointEvent()"; qDebug() << "CdbDebugEngine::handleBreakpointEvent()";
} }
@@ -518,3 +521,17 @@ IDebuggerEngine *createWinEngine(DebuggerManager *parent)
{ {
return new CdbDebugEngine(parent); return new CdbDebugEngine(parent);
} }
void CdbDebugEngine::setDebugDumpers(bool on)
{
Q_UNUSED(on)
}
void CdbDebugEngine::setUseCustomDumpers(bool on)
{
Q_UNUSED(on)
}
void CdbDebugEngine::reloadSourceFiles()
{
}

View File

@@ -5,8 +5,6 @@
#include "cdbdebugeventcallback.h" #include "cdbdebugeventcallback.h"
#include "cdbdebugoutput.h" #include "cdbdebugoutput.h"
#include <windows.h>
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
@@ -32,8 +30,7 @@ public:
virtual void stepIExec(); virtual void stepIExec();
virtual void nextIExec(); virtual void nextIExec();
virtual void continueInferior(); virtual void continueInferior();
virtual void runInferior();
virtual void interruptInferior(); virtual void interruptInferior();
virtual void runToLineExec(const QString &fileName, int lineNumber); virtual void runToLineExec(const QString &fileName, int lineNumber);
@@ -58,6 +55,11 @@ public:
virtual void reloadRegisters(); virtual void reloadRegisters();
virtual void setDebugDumpers(bool on);
virtual void setUseCustomDumpers(bool on);
virtual void reloadSourceFiles();
protected: protected:
void timerEvent(QTimerEvent*); void timerEvent(QTimerEvent*);

View File

@@ -1,5 +1,5 @@
#include "cdbdebugeventcallback.h" #include "cdbdebugeventcallback.h"
#include "cdbcdebugengine.h" #include "cdbdebugengine.h"
#include "debuggermanager.h" #include "debuggermanager.h"
#include <QtCore/QDebug> #include <QtCore/QDebug>
@@ -7,7 +7,7 @@
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
STDMETHODIMP MSVCDebugEventCallback::QueryInterface( STDMETHODIMP CdbDebugEventCallback::QueryInterface(
THIS_ THIS_
IN REFIID InterfaceId, IN REFIID InterfaceId,
OUT PVOID* Interface) OUT PVOID* Interface)
@@ -27,21 +27,21 @@ STDMETHODIMP MSVCDebugEventCallback::QueryInterface(
} }
} }
STDMETHODIMP_(ULONG) MSVCDebugEventCallback::AddRef(THIS) STDMETHODIMP_(ULONG) CdbDebugEventCallback::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) MSVCDebugEventCallback::Release(THIS) STDMETHODIMP_(ULONG) CdbDebugEventCallback::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(THIS_ __out PULONG mask) STDMETHODIMP CdbDebugEventCallback::GetInterestMask(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
@@ -51,14 +51,14 @@ STDMETHODIMP MSVCDebugEventCallback::GetInterestMask(THIS_ __out PULONG mask)
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::Breakpoint(THIS_ __in PDEBUG_BREAKPOINT Bp) STDMETHODIMP CdbDebugEventCallback::Breakpoint(THIS_ __in PDEBUG_BREAKPOINT Bp)
{ {
qDebug() << "MSVCDebugEventCallback::Breakpoint"; qDebug() << "MSVCDebugEventCallback::Breakpoint";
m_pEngine->handleBreakpointEvent(Bp); m_pEngine->handleBreakpointEvent(Bp);
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::Exception( STDMETHODIMP CdbDebugEventCallback::Exception(
THIS_ THIS_
__in PEXCEPTION_RECORD64 Exception, __in PEXCEPTION_RECORD64 Exception,
__in ULONG FirstChance __in ULONG FirstChance
@@ -68,7 +68,7 @@ STDMETHODIMP MSVCDebugEventCallback::Exception(
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::CreateThread( STDMETHODIMP CdbDebugEventCallback::CreateThread(
THIS_ THIS_
__in ULONG64 Handle, __in ULONG64 Handle,
__in ULONG64 DataOffset, __in ULONG64 DataOffset,
@@ -82,7 +82,7 @@ STDMETHODIMP MSVCDebugEventCallback::CreateThread(
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::ExitThread( STDMETHODIMP CdbDebugEventCallback::ExitThread(
THIS_ THIS_
__in ULONG ExitCode __in ULONG ExitCode
) )
@@ -90,7 +90,7 @@ STDMETHODIMP MSVCDebugEventCallback::ExitThread(
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::CreateProcess( STDMETHODIMP CdbDebugEventCallback::CreateProcess(
THIS_ THIS_
__in ULONG64 ImageFileHandle, __in ULONG64 ImageFileHandle,
__in ULONG64 Handle, __in ULONG64 Handle,
@@ -120,7 +120,7 @@ STDMETHODIMP MSVCDebugEventCallback::CreateProcess(
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::ExitProcess( STDMETHODIMP CdbDebugEventCallback::ExitProcess(
THIS_ THIS_
__in ULONG ExitCode __in ULONG ExitCode
) )
@@ -132,7 +132,7 @@ STDMETHODIMP MSVCDebugEventCallback::ExitProcess(
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::LoadModule( STDMETHODIMP CdbDebugEventCallback::LoadModule(
THIS_ THIS_
__in ULONG64 ImageFileHandle, __in ULONG64 ImageFileHandle,
__in ULONG64 BaseOffset, __in ULONG64 BaseOffset,
@@ -146,7 +146,7 @@ STDMETHODIMP MSVCDebugEventCallback::LoadModule(
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::UnloadModule( STDMETHODIMP CdbDebugEventCallback::UnloadModule(
THIS_ THIS_
__in_opt PCSTR ImageBaseName, __in_opt PCSTR ImageBaseName,
__in ULONG64 BaseOffset __in ULONG64 BaseOffset
@@ -155,7 +155,7 @@ STDMETHODIMP MSVCDebugEventCallback::UnloadModule(
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::SystemError( STDMETHODIMP CdbDebugEventCallback::SystemError(
THIS_ THIS_
__in ULONG Error, __in ULONG Error,
__in ULONG Level __in ULONG Level
@@ -164,7 +164,7 @@ STDMETHODIMP MSVCDebugEventCallback::SystemError(
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::SessionStatus( STDMETHODIMP CdbDebugEventCallback::SessionStatus(
THIS_ THIS_
__in ULONG Status __in ULONG Status
) )
@@ -172,7 +172,7 @@ STDMETHODIMP MSVCDebugEventCallback::SessionStatus(
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::ChangeDebuggeeState( STDMETHODIMP CdbDebugEventCallback::ChangeDebuggeeState(
THIS_ THIS_
__in ULONG Flags, __in ULONG Flags,
__in ULONG64 Argument __in ULONG64 Argument
@@ -181,7 +181,7 @@ STDMETHODIMP MSVCDebugEventCallback::ChangeDebuggeeState(
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::ChangeEngineState( STDMETHODIMP CdbDebugEventCallback::ChangeEngineState(
THIS_ THIS_
__in ULONG Flags, __in ULONG Flags,
__in ULONG64 Argument __in ULONG64 Argument
@@ -190,7 +190,7 @@ STDMETHODIMP MSVCDebugEventCallback::ChangeEngineState(
return S_OK; return S_OK;
} }
STDMETHODIMP MSVCDebugEventCallback::ChangeSymbolState( STDMETHODIMP CdbDebugEventCallback::ChangeSymbolState(
THIS_ THIS_
__in ULONG Flags, __in ULONG Flags,
__in ULONG64 Argument __in ULONG64 Argument

View File

@@ -2,7 +2,7 @@
#define DEBUGGER_CDBDEBUGEVENTCALLBACK_H #define DEBUGGER_CDBDEBUGEVENTCALLBACK_H
#include <windows.h> #include <windows.h>
#include <dbgeng.h> #include <inc/dbgeng.h>
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {

View File

@@ -1,5 +1,5 @@
#include <windows.h> #include <windows.h>
#include <dbgeng.h> #include <inc/dbgeng.h>
#include "cdbdebugoutput.h" #include "cdbdebugoutput.h"
#include "cdbdebugengine.h" #include "cdbdebugengine.h"
@@ -7,7 +7,7 @@
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
STDMETHODIMP MSVCDebugOutput::QueryInterface( STDMETHODIMP CdbDebugOutput::QueryInterface(
THIS_ THIS_
IN REFIID InterfaceId, IN REFIID InterfaceId,
OUT PVOID* Interface OUT PVOID* Interface
@@ -28,21 +28,21 @@ STDMETHODIMP MSVCDebugOutput::QueryInterface(
} }
} }
STDMETHODIMP_(ULONG) MSVCDebugOutput::AddRef(THIS) STDMETHODIMP_(ULONG) CdbDebugOutput::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) MSVCDebugOutput::Release(THIS) STDMETHODIMP_(ULONG) CdbDebugOutput::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 MSVCDebugOutput::Output( STDMETHODIMP CdbDebugOutput::Output(
THIS_ THIS_
IN ULONG mask, IN ULONG mask,
IN PCSTR text IN PCSTR text

View File

@@ -85,7 +85,20 @@ HEADERS += $$PWD/modeltest.h
DEFINES += USE_MODEL_TEST=1 DEFINES += USE_MODEL_TEST=1
} }
false { win32 {
# ---- Detect Debugging Tools For Windows
CDB_PATH="$$(ProgramFiles)/Debugging Tools For Windows/sdk"
exists ($$CDB_PATH) {
message("Experimental: Adding support for $$CDB_PATH")
DEFINES+=CDB_ENABLED
CDB_PLATFORM=i386
INCLUDEPATH+=$$CDB_PATH
CDB_LIBPATH=$$CDB_PATH/lib/$$CDB_PLATFORM
HEADERS += \ HEADERS += \
cdbdebugengine.h \ cdbdebugengine.h \
@@ -97,7 +110,7 @@ SOURCES += \
cdbdebugeventcallback.cpp \ cdbdebugeventcallback.cpp \
cdbdebugoutput.cpp cdbdebugoutput.cpp
LIBS += dbgeng.lib LIBS += -L$$CDB_LIBPATH Dbghelp.lib dbgeng.lib
} }
}

View File

@@ -132,7 +132,12 @@ static IDebuggerEngine *winEngine = 0;
static IDebuggerEngine *scriptEngine = 0; static IDebuggerEngine *scriptEngine = 0;
extern IDebuggerEngine *createGdbEngine(DebuggerManager *parent); extern IDebuggerEngine *createGdbEngine(DebuggerManager *parent);
extern IDebuggerEngine *createWinEngine(DebuggerManager *) { return 0; } extern IDebuggerEngine *createWinEngine(DebuggerManager *)
#ifdef CDB_ENABLED
;
#else
{ return 0; }
#endif
extern IDebuggerEngine *createScriptEngine(DebuggerManager *parent); extern IDebuggerEngine *createScriptEngine(DebuggerManager *parent);
DebuggerManager::DebuggerManager() DebuggerManager::DebuggerManager()

View File

@@ -110,7 +110,7 @@ enum DebuggerStatus
class IDebuggerEngine; class IDebuggerEngine;
class GdbEngine; class GdbEngine;
class ScriptEngine; class ScriptEngine;
class WinEngine; class CdbDebugEngine;
// The construct below is not nice but enforces a bit of order. The // The construct below is not nice but enforces a bit of order. The
// DebuggerManager interfaces a lots of thing: The DebuggerPlugin, // DebuggerManager interfaces a lots of thing: The DebuggerPlugin,
@@ -131,10 +131,11 @@ public:
private: private:
// This is the part of the interface that's exclusively seen by the // This is the part of the interface that's exclusively seen by the
// debugger engines. // debugger enginesfriend class GdbEngine;.
friend class GdbEngine; friend class GdbEngine;
friend class CdbDebugEngine;
friend class CdbDebugEventCallback;
friend class ScriptEngine; friend class ScriptEngine;
friend class WinEngine;
// called from the engines after successful startup // called from the engines after successful startup
virtual void notifyInferiorStopRequested() = 0; virtual void notifyInferiorStopRequested() = 0;