blob: a525c2ae76820d778ec5641d651e503147234a72 [file] [log] [blame]
* Copyright (c) 2009, 2011 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
* Contributors:
* Nokia - Initial API and implementation
#pragma once
#include "stdafx.h"
#include "ThreadContext.h"
#include "WinHWBkptMgr.h" // for DRMask, DRFlags on SetDebugRegister/ClearDebugRegister
#define DR0 0x01
#define DR1 0x02
#define DR2 0x04
#define DR3 0x08
class WinProcess;
class WinThread : public ThreadContext {
WinThread(WinProcess& process, DEBUG_EVENT& debugEvent);
virtual ~WinThread(void);
int GetThreadID();
static WinThread* GetThreadByID(int processID, int threadID);
virtual std::vector<std::string> GetRegisterValues(
const std::vector<std::string>& registerIDs);
virtual void SetRegisterValues(const std::vector<std::string>& registerIDs,
const std::vector<std::string>& registerValues);
char* GetRegisterValue(const std::string& regName, int regSize);
bool SetRegisterValue(const std::string& regName, int regSize, char* val);
// overrides of RunControlContext
virtual int ReadMemory(const ReadWriteMemoryParams&) throw (AgentException);
virtual int WriteMemory(const ReadWriteMemoryParams&) throw (AgentException);
virtual void Resume(const AgentActionParams&) throw (AgentException);
virtual void Suspend(const AgentActionParams&) throw (AgentException);
virtual void Terminate(const AgentActionParams&) throw (AgentException);
virtual void SingleStep(const AgentActionParams&) throw (AgentException);
// end overrides
void PrepareForTermination(const AgentActionParams&) throw (AgentException);
void HandleException(DEBUG_EVENT& debugEvent);
void HandleExecutableEvent(bool isLoaded, const std::string& exePath,
unsigned long baseAddress, unsigned long codeSize);
/* Address where suspend is reported */
ContextAddress GetPCAddress() const;
void EnableSingleStep();
DWORD GetContinueStatus() const;
void SetDebugRegister(WinHWBkptMgr::DRMask, ContextAddress, WinHWBkptMgr::DRFlags);
void ClearDebugRegister(WinHWBkptMgr::DRMask);
void Resume();
DWORD Suspend();
void Initialize();
void EnsureValidContextInfo();
void SetContextInfo();
bool IsSuspended() const;
void MarkSuspended();
void AdjustPC();
/** REASON_xx code for suspend */
const char* GetSuspendReason() const;
/** Description for suspend */
std::string GetExceptionMessage() const;
void* GetRegisterValueBuffer(const std::string& regName) const;
void HandleHardwareBreak();
std::pair<int, int> threadLookupPair_;
bool threadContextValid_;
bool isSuspended_;
bool isTerminating_;
bool isUserSuspended_;
CONTEXT threadContextInfo_;
std::map<std::string, std::string> registerValueCache_;
WinProcess& parentProcess_;
unsigned long startAddress_;
HANDLE handle_;
void* localBase_;
static std::map<std::pair<int, int>, WinThread*> threadIDMap_;