/******************************************************************************* | |
* Copyright (c) 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 | |
* http://www.eclipse.org/legal/epl-v10.html | |
* | |
* Contributors: | |
* Nokia - Initial API and implementation | |
*******************************************************************************/ | |
#ifndef BREAKPOINTSERVICE_H_ | |
#define BREAKPOINTSERVICE_H_ | |
#include <map> | |
#include <string> | |
#include <vector> | |
#include "TCFService.h" | |
#include "TCFContext.h" | |
class WinProcess; | |
struct Channel; | |
struct Protocol; | |
enum TCFBreakpointType { | |
type_Auto, | |
type_Software, | |
type_Hardware | |
}; | |
enum TCFAccessMode { | |
ACCESSMODE_READ = 0x01, | |
ACCESSMODE_WRITE = 0x02, | |
ACCESSMODE_EXECUTE = 0x04, | |
ACCESSMODE_CHANGE = 0x08, | |
}; | |
typedef unsigned char HWBreakID; | |
#define HWBREAK_NOT_SET 0 | |
// | |
// To store the breakpoint info | |
// | |
struct TBreakpoint { | |
std::vector<std::string> iContextIds; | |
WinProcess* process; // pointer to the process hosint the bkpt | |
std::string hostBreakPointId; // breakpoint ID from host debugger. | |
ContextAddress address; | |
bool enabled; | |
unsigned char originalByte; // original byte where we set the bp. | |
unsigned char size; // for windows-x86, max is well below 255 | |
TCFBreakpointType bpType; // ignored; always software for bkpt | |
// and always hardware for watchpoint | |
TCFAccessMode accessMode; // _EXECUTE means bkpt; o/w -> watchpoint | |
HWBreakID hwBreakID; | |
TBreakpoint() | |
: process(NULL), address(0), enabled(true), originalByte(0), | |
size(0), bpType(type_Auto), accessMode(ACCESSMODE_READ), | |
hwBreakID(HWBREAK_NOT_SET) | |
{} | |
}; | |
typedef std::map<std::string, TBreakpoint*> TID2BreakpointMap; | |
/* | |
* A list of breakpoints in all processes in the debug session. | |
*/ | |
static TID2BreakpointMap sBreakPointMap; | |
// | |
// Breakpoint service implementation | |
// | |
class BreakpointsService: public TCFService { | |
public: | |
BreakpointsService(Protocol * proto); | |
const char* GetName(); | |
static void CommandAddBreakpoint(const char* token, Channel*); | |
static void CommandRemoveBreakpoint(const char* token, Channel*); | |
static int InsertBreak(const TBreakpoint*); | |
static int ClearBreak(const TBreakpoint*); | |
static int InsertWatch(TBreakpoint*); | |
static int ClearWatch(TBreakpoint*); | |
static TBreakpoint* FindBreakpointByAddress(const HANDLE& processHandle, | |
const ContextAddress); | |
static TBreakpoint* FindWatchpointByAddress(const HANDLE& processHandle, | |
const ContextAddress); | |
static void RemoveBreakpointsFromMemoryRead(const HANDLE& processHandle, | |
const ContextAddress, char* memBuffer, const unsigned long size); | |
static void ReInsertBreakpointsAfterMemoryWrite( | |
const HANDLE& processHandle, const ContextAddress, char* memBuffer, | |
const unsigned long size); | |
static bool ServiceInstalled(); | |
private: | |
static bool sServiceInstalled; | |
}; | |
#endif /* BREAKPOINTSERVICE_H_ */ |