2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2009-02-20 17:07:00 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
2009-02-20 17:07:00 +01:00
|
|
|
**
|
|
|
|
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2009-02-20 17:07:00 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
2009-02-20 17:07:00 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2009-02-20 17:07:00 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
2009-02-20 17:07:00 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at qt-sales@nokia.com.
|
2009-02-20 17:07:00 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2009-02-20 17:07:00 +01:00
|
|
|
|
2009-02-09 13:07:38 +01:00
|
|
|
#include "cdbdebugeventcallback.h"
|
2009-02-20 14:56:36 +01:00
|
|
|
#include "cdbdebugengine.h"
|
2009-02-20 17:07:00 +01:00
|
|
|
#include "cdbdebugengine_p.h"
|
2009-02-09 11:35:43 +01:00
|
|
|
#include "debuggermanager.h"
|
|
|
|
|
|
2009-02-09 13:07:38 +01:00
|
|
|
#include <QtCore/QDebug>
|
2009-02-09 11:35:43 +01:00
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2009-02-23 14:46:46 +01:00
|
|
|
CdbDebugEventCallback::CdbDebugEventCallback(CdbDebugEngine* dbg) :
|
|
|
|
|
m_pEngine(dbg)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::QueryInterface(
|
2009-02-09 11:35:43 +01:00
|
|
|
THIS_
|
|
|
|
|
IN REFIID InterfaceId,
|
2009-02-09 13:07:38 +01:00
|
|
|
OUT PVOID* Interface)
|
2009-02-09 11:35:43 +01:00
|
|
|
{
|
|
|
|
|
*Interface = NULL;
|
|
|
|
|
|
|
|
|
|
if (IsEqualIID(InterfaceId, __uuidof(IUnknown)) ||
|
2009-02-23 14:46:46 +01:00
|
|
|
IsEqualIID(InterfaceId, __uuidof(IDebugOutputCallbacks))) {
|
2009-02-09 11:35:43 +01:00
|
|
|
*Interface = (IDebugOutputCallbacks *)this;
|
|
|
|
|
AddRef();
|
|
|
|
|
return S_OK;
|
2009-02-23 14:46:46 +01:00
|
|
|
} else {
|
2009-02-09 11:35:43 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP_(ULONG) CdbDebugEventCallback::AddRef(THIS)
|
2009-02-09 11:35:43 +01:00
|
|
|
{
|
|
|
|
|
// This class is designed to be static so
|
|
|
|
|
// there's no true refcount.
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP_(ULONG) CdbDebugEventCallback::Release(THIS)
|
2009-02-09 11:35:43 +01:00
|
|
|
{
|
|
|
|
|
// This class is designed to be static so
|
|
|
|
|
// there's no true refcount.
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::GetInterestMask(THIS_ __out PULONG mask)
|
2009-02-09 11:35:43 +01:00
|
|
|
{
|
|
|
|
|
*mask = DEBUG_EVENT_CREATE_PROCESS | DEBUG_EVENT_EXIT_PROCESS
|
|
|
|
|
//| DEBUG_EVENT_CREATE_THREAD | DEBUG_EVENT_EXIT_THREAD
|
|
|
|
|
| DEBUG_EVENT_BREAKPOINT
|
|
|
|
|
| DEBUG_EVENT_EXCEPTION
|
|
|
|
|
;
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::Breakpoint(THIS_ __in PDEBUG_BREAKPOINT Bp)
|
2009-02-09 11:35:43 +01:00
|
|
|
{
|
2009-02-23 14:46:46 +01:00
|
|
|
if (debugCDB)
|
|
|
|
|
qDebug() << Q_FUNC_INFO;
|
2009-02-20 17:07:00 +01:00
|
|
|
m_pEngine->m_d->handleBreakpointEvent(Bp);
|
2009-02-09 11:35:43 +01:00
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-05 17:30:29 +01:00
|
|
|
static inline QString msgException(const EXCEPTION_RECORD64 *Exception, ULONG FirstChance)
|
|
|
|
|
{
|
|
|
|
|
return QString::fromLatin1("An exception occurred: Code=0x%1 FirstChance=%2").
|
|
|
|
|
arg(QString::number(Exception->ExceptionCode, 16)).
|
|
|
|
|
arg(FirstChance);
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::Exception(
|
2009-02-09 11:35:43 +01:00
|
|
|
THIS_
|
|
|
|
|
__in PEXCEPTION_RECORD64 Exception,
|
|
|
|
|
__in ULONG FirstChance
|
|
|
|
|
)
|
|
|
|
|
{
|
2009-02-23 14:46:46 +01:00
|
|
|
Q_UNUSED(Exception)
|
|
|
|
|
if (debugCDB)
|
2009-03-05 17:30:29 +01:00
|
|
|
qDebug() << Q_FUNC_INFO << msgException(Exception, FirstChance);
|
|
|
|
|
|
|
|
|
|
// First chance are harmless
|
|
|
|
|
if (!FirstChance)
|
|
|
|
|
qWarning("%s", qPrintable(msgException(Exception, FirstChance)));
|
2009-02-09 11:35:43 +01:00
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::CreateThread(
|
2009-02-09 11:35:43 +01:00
|
|
|
THIS_
|
|
|
|
|
__in ULONG64 Handle,
|
|
|
|
|
__in ULONG64 DataOffset,
|
|
|
|
|
__in ULONG64 StartOffset
|
|
|
|
|
)
|
|
|
|
|
{
|
2009-02-23 14:46:46 +01:00
|
|
|
Q_UNUSED(Handle)
|
|
|
|
|
Q_UNUSED(DataOffset)
|
|
|
|
|
Q_UNUSED(StartOffset)
|
|
|
|
|
|
|
|
|
|
if (debugCDB)
|
|
|
|
|
qDebug() << Q_FUNC_INFO;
|
2009-02-09 11:35:43 +01:00
|
|
|
//Debugger::ThreadInfo ti;
|
|
|
|
|
//ti.handle = Handle;
|
|
|
|
|
//ti.dataOffset = DataOffset;
|
|
|
|
|
//ti.startOffset = StartOffset;
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::ExitThread(
|
2009-02-09 11:35:43 +01:00
|
|
|
THIS_
|
|
|
|
|
__in ULONG ExitCode
|
|
|
|
|
)
|
|
|
|
|
{
|
2009-02-23 14:46:46 +01:00
|
|
|
if (debugCDB)
|
|
|
|
|
qDebug() << Q_FUNC_INFO << ExitCode;
|
|
|
|
|
|
2009-02-09 11:35:43 +01:00
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::CreateProcess(
|
2009-02-09 11:35:43 +01:00
|
|
|
THIS_
|
|
|
|
|
__in ULONG64 ImageFileHandle,
|
|
|
|
|
__in ULONG64 Handle,
|
|
|
|
|
__in ULONG64 BaseOffset,
|
|
|
|
|
__in ULONG ModuleSize,
|
|
|
|
|
__in_opt PCSTR ModuleName,
|
|
|
|
|
__in_opt PCSTR ImageName,
|
|
|
|
|
__in ULONG CheckSum,
|
|
|
|
|
__in ULONG TimeDateStamp,
|
|
|
|
|
__in ULONG64 InitialThreadHandle,
|
|
|
|
|
__in ULONG64 ThreadDataOffset,
|
|
|
|
|
__in ULONG64 StartOffset
|
|
|
|
|
)
|
|
|
|
|
{
|
2009-02-23 14:46:46 +01:00
|
|
|
Q_UNUSED(ImageFileHandle)
|
|
|
|
|
Q_UNUSED(BaseOffset)
|
|
|
|
|
Q_UNUSED(ModuleSize)
|
|
|
|
|
Q_UNUSED(ModuleName)
|
|
|
|
|
Q_UNUSED(ImageName)
|
|
|
|
|
Q_UNUSED(CheckSum)
|
|
|
|
|
Q_UNUSED(TimeDateStamp)
|
|
|
|
|
Q_UNUSED(ThreadDataOffset)
|
|
|
|
|
Q_UNUSED(StartOffset)
|
|
|
|
|
if (debugCDB)
|
|
|
|
|
qDebug() << Q_FUNC_INFO << ModuleName;
|
|
|
|
|
|
2009-03-05 17:30:29 +01:00
|
|
|
m_pEngine->m_d->setDebuggeeHandles(reinterpret_cast<HANDLE>(Handle), reinterpret_cast<HANDLE>(InitialThreadHandle));
|
2009-02-23 14:46:46 +01:00
|
|
|
m_pEngine->m_d->m_debuggerManagerAccess->notifyInferiorRunning();
|
2009-02-09 11:35:43 +01:00
|
|
|
|
|
|
|
|
ULONG currentThreadId;
|
2009-02-20 17:07:00 +01:00
|
|
|
if (SUCCEEDED(m_pEngine->m_d->m_pDebugSystemObjects->GetThreadIdByHandle(InitialThreadHandle, ¤tThreadId)))
|
|
|
|
|
m_pEngine->m_d->m_currentThreadId = currentThreadId;
|
2009-02-09 11:35:43 +01:00
|
|
|
else
|
2009-02-20 17:07:00 +01:00
|
|
|
m_pEngine->m_d->m_currentThreadId = 0;
|
2009-02-09 11:35:43 +01:00
|
|
|
|
|
|
|
|
m_pEngine->attemptBreakpointSynchronization();
|
|
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::ExitProcess(
|
2009-02-09 11:35:43 +01:00
|
|
|
THIS_
|
|
|
|
|
__in ULONG ExitCode
|
|
|
|
|
)
|
|
|
|
|
{
|
2009-02-23 14:46:46 +01:00
|
|
|
if (debugCDB)
|
|
|
|
|
qDebug() << Q_FUNC_INFO << ExitCode;
|
|
|
|
|
|
2009-03-05 17:30:29 +01:00
|
|
|
m_pEngine->m_d->setDebuggeeHandles(0, 0);
|
2009-02-23 14:46:46 +01:00
|
|
|
m_pEngine->m_d->m_debuggerManagerAccess->notifyInferiorExited();
|
2009-02-09 11:35:43 +01:00
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::LoadModule(
|
2009-02-09 11:35:43 +01:00
|
|
|
THIS_
|
|
|
|
|
__in ULONG64 ImageFileHandle,
|
|
|
|
|
__in ULONG64 BaseOffset,
|
|
|
|
|
__in ULONG ModuleSize,
|
|
|
|
|
__in_opt PCSTR ModuleName,
|
|
|
|
|
__in_opt PCSTR ImageName,
|
|
|
|
|
__in ULONG CheckSum,
|
|
|
|
|
__in ULONG TimeDateStamp
|
|
|
|
|
)
|
|
|
|
|
{
|
2009-02-23 14:46:46 +01:00
|
|
|
Q_UNUSED(ImageFileHandle)
|
|
|
|
|
Q_UNUSED(BaseOffset)
|
|
|
|
|
Q_UNUSED(ModuleSize)
|
|
|
|
|
Q_UNUSED(ModuleName)
|
|
|
|
|
Q_UNUSED(ImageName)
|
|
|
|
|
Q_UNUSED(CheckSum)
|
|
|
|
|
Q_UNUSED(TimeDateStamp)
|
|
|
|
|
if (debugCDB)
|
|
|
|
|
qDebug() << Q_FUNC_INFO << ModuleName;
|
|
|
|
|
|
2009-02-09 11:35:43 +01:00
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::UnloadModule(
|
2009-02-09 11:35:43 +01:00
|
|
|
THIS_
|
|
|
|
|
__in_opt PCSTR ImageBaseName,
|
|
|
|
|
__in ULONG64 BaseOffset
|
|
|
|
|
)
|
|
|
|
|
{
|
2009-02-23 14:46:46 +01:00
|
|
|
Q_UNUSED(ImageBaseName)
|
|
|
|
|
Q_UNUSED(BaseOffset)
|
|
|
|
|
if (debugCDB)
|
|
|
|
|
qDebug() << Q_FUNC_INFO << ImageBaseName;
|
|
|
|
|
|
2009-02-09 11:35:43 +01:00
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::SystemError(
|
2009-02-09 11:35:43 +01:00
|
|
|
THIS_
|
|
|
|
|
__in ULONG Error,
|
|
|
|
|
__in ULONG Level
|
|
|
|
|
)
|
|
|
|
|
{
|
2009-02-23 14:46:46 +01:00
|
|
|
if (debugCDB)
|
|
|
|
|
qDebug() << Q_FUNC_INFO << Error << Level;
|
2009-02-09 11:35:43 +01:00
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::SessionStatus(
|
2009-02-09 11:35:43 +01:00
|
|
|
THIS_
|
|
|
|
|
__in ULONG Status
|
|
|
|
|
)
|
|
|
|
|
{
|
2009-02-23 14:46:46 +01:00
|
|
|
Q_UNUSED(Status)
|
2009-02-09 11:35:43 +01:00
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::ChangeDebuggeeState(
|
2009-02-09 11:35:43 +01:00
|
|
|
THIS_
|
|
|
|
|
__in ULONG Flags,
|
|
|
|
|
__in ULONG64 Argument
|
|
|
|
|
)
|
|
|
|
|
{
|
2009-02-23 14:46:46 +01:00
|
|
|
Q_UNUSED(Flags)
|
|
|
|
|
Q_UNUSED(Argument)
|
2009-02-09 11:35:43 +01:00
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::ChangeEngineState(
|
2009-02-09 11:35:43 +01:00
|
|
|
THIS_
|
|
|
|
|
__in ULONG Flags,
|
|
|
|
|
__in ULONG64 Argument
|
|
|
|
|
)
|
|
|
|
|
{
|
2009-02-23 14:46:46 +01:00
|
|
|
Q_UNUSED(Flags)
|
|
|
|
|
Q_UNUSED(Argument)
|
2009-02-09 11:35:43 +01:00
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-20 14:56:36 +01:00
|
|
|
STDMETHODIMP CdbDebugEventCallback::ChangeSymbolState(
|
2009-02-09 11:35:43 +01:00
|
|
|
THIS_
|
|
|
|
|
__in ULONG Flags,
|
|
|
|
|
__in ULONG64 Argument
|
|
|
|
|
)
|
|
|
|
|
{
|
2009-02-23 14:46:46 +01:00
|
|
|
Q_UNUSED(Flags)
|
|
|
|
|
Q_UNUSED(Argument)
|
2009-02-09 11:35:43 +01:00
|
|
|
return S_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|