blob: 81346bcef6c455a4d22655ab8a8bc3e0308face7 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009 Nokia and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Nokia - Initial API and implementation
*******************************************************************************/
#pragma once
#include <string>
#include "stdafx.h"
#include "DebugMonitor.h"
#include "TCFChannel.h"
#include <queue>
extern "C" {
#include "channel.h"
#include "events.h"
}
class AgentAction;
class AgentActionParams;
class WinProcess;
/*
* Windows implementation of DebugMonitor.
*/
class WinDebugMonitor: public DebugMonitor {
public:
WinDebugMonitor(const LaunchProcessParams& params);
WinDebugMonitor(const AttachToProcessParams& params);
virtual ~WinDebugMonitor(void);
void StartProcessForDebug();
void EventLoop();
void StartMonitor();
void CaptureMonitorThread();
void Suspend();
void Resume();
void PostAction(AgentAction* action);
virtual void Attach(unsigned long pid, ContextAttachCallBack * done,
void * data, int selfattach);
void StartDebug();
/*
* Launch a process and monitor it.
*/
static void LaunchProcess(const LaunchProcessParams& params) throw (AgentException);
/*
* Attach to a process and monitor it.
* processID: the Windows process ID.
*/
static void AttachToProcess(const AttachToProcessParams& params) throw (AgentException);
static std::string GetDebugExceptionDescription(const EXCEPTION_DEBUG_INFO& exceptionInfo);
void HandleDebugEvent(DEBUG_EVENT& debugEvent);
void ProcessDied(DWORD process_id);
private:
void AttachToProcessForDebug();
void HandleNoDebugEvent();
void HandleExceptionEvent(DEBUG_EVENT& debugEvent);
void HandleProcessCreatedEvent(DEBUG_EVENT& debugEvent);
void HandleThreadCreatedEvent(DEBUG_EVENT& debugEvent);
void HandleProcessExitedEvent(DEBUG_EVENT& debugEvent);
void HandleThreadExitedEvent(DEBUG_EVENT& debugEvent);
void HandleDLLLoadedEvent(DEBUG_EVENT& debugEvent);
void HandleDLLUnloadedEvent(DEBUG_EVENT& debugEvent);
void HandleDebugStringEvent(DEBUG_EVENT& debugEvent);
void HandleSystemDebugErrorEvent(DEBUG_EVENT& debugEvent);
void HandleUnknwonDebugEvent(DEBUG_EVENT& debugEvent);
private:
DWORD wfdeWait;
bool waitForDebugEvents;
bool handledInitialDebugBreakpoint;
DWORD processID;
bool isAttach;
PROCESS_INFORMATION processInfo;
HANDLE monitorThread_;
std::queue<AgentAction*> actions_;
};