GDBServerFoundation::IStoppedGDBTarget Class Referenceabstract

Defines methods called when the target is stopped. More...

#include <IGDBTarget.h>

Inheritance diagram for GDBServerFoundation::IStoppedGDBTarget:
GDBServerFoundation::ISyncGDBTarget GDBServerFoundation::MinimalTargetBase

Public Member Functions

virtual const
PlatformRegisterList
GetRegisterList ()=0
 Returns a pointer to a persistent list of the registers supported by the target.
 
virtual GDBStatus ReadFrameRelatedRegisters (int threadID, RegisterSetContainer &registers)=0
 Reads program counter, stack pointer and stack base pointer registers.
 
virtual GDBStatus ReadTargetRegisters (int threadID, RegisterSetContainer &registers)=0
 Reads the values of all registers from the target.
 
virtual GDBStatus WriteTargetRegisters (int threadID, const RegisterSetContainer &registers)=0
 Writes one or more target registers.
 
virtual GDBStatus ReadTargetMemory (ULONGLONG Address, void *pBuffer, size_t *pSizeInBytes)=0
 Reads the memory of the underlying target.
 
virtual GDBStatus WriteTargetMemory (ULONGLONG Address, const void *pBuffer, size_t sizeInBytes)=0
 Writes the memory of the underlying target.
 
virtual GDBStatus GetDynamicLibraryList (std::vector< DynamicLibraryRecord > &libraries)=0
 Fills the list of the dynamic libraries currently loaded in the target.
 
virtual GDBStatus GetThreadList (std::vector< ThreadRecord > &threads)=0
 Fills the list of the threads currently present in the target.
 
virtual GDBStatus SetThreadModeForNextCont (int threadID, DebugThreadMode mode, OUT bool *pNeedRestoreCall, IN OUT INT_PTR *pRestoreCookie)=0
 Sets the mode in which an individual thread will continue before the next debug event.
 
virtual GDBStatus Terminate ()=0
 Terminates the target.
 
virtual GDBStatus CreateBreakpoint (BreakpointType type, ULONGLONG Address, unsigned kind, OUT INT_PTR *pCookie)=0
 Sets a breakpoint at a given address.
 
virtual GDBStatus RemoveBreakpoint (BreakpointType type, ULONGLONG Address, INT_PTR Cookie)=0
 Removes a previously set breakpoint.
 
virtual GDBStatus ExecuteRemoteCommand (const std::string &command, std::string &output)=0
 This handler is invoked when user sends an arbitrary command to the GDB stub ("mon <command>" in GDB).
 
virtual IFLASHProgrammerGetFLASHProgrammer ()=0
 Returns a pointer to an IFLASHProgrammer instance, or NULL if not supported. The returned instance should be persistent (e.g. the same object that implements IStoppedGDBTarget).
 
virtual ~IStoppedGDBTarget ()
 

Detailed Description

Defines methods called when the target is stopped.

This interface defines the methods of the GDB target that are called when the target is stopped. Actual targets should implement the ISyncGDBTarget interface instead.

Constructor & Destructor Documentation

virtual GDBServerFoundation::IStoppedGDBTarget::~IStoppedGDBTarget ( )
inlinevirtual

Member Function Documentation

virtual GDBStatus GDBServerFoundation::IStoppedGDBTarget::CreateBreakpoint ( BreakpointType  type,
ULONGLONG  Address,
unsigned  kind,
OUT INT_PTR *  pCookie 
)
pure virtual

Sets a breakpoint at a given address.

Parameters
typeSpecifies the type of the supported breakpoint.
AddressSpecifies the address where the breakpoint should be set.
kindSpecifies the additional information provided by GDB. For data breakpoints this is the length of the watched region.
pCookiereceives an arbitrary INT_PTR value that will be passed to RemoveBreakpoint() once this breakpoint is removed.
Remarks
It is not necessary to implement this method for software breakpoints. If GDB encounters a "not supported" reply, it will set the breakpoint using the WriteTargetMemory() call. It is only recommended to implement this method for the software breakpoints if it can set them better than GDB itself.

Implemented in GDBServerFoundation::MinimalTargetBase.

virtual GDBStatus GDBServerFoundation::IStoppedGDBTarget::ExecuteRemoteCommand ( const std::string &  command,
std::string &  output 
)
pure virtual

This handler is invoked when user sends an arbitrary command to the GDB stub ("mon <command>" in GDB).

Implemented in GDBServerFoundation::MinimalTargetBase.

virtual GDBStatus GDBServerFoundation::IStoppedGDBTarget::GetDynamicLibraryList ( std::vector< DynamicLibraryRecord > &  libraries)
pure virtual

Fills the list of the dynamic libraries currently loaded in the target.

If the target supports dynamic libraries (a.k.a DLLs, a.k.a. shared libraries, a.k.a. shared objects), this method should provide the information about them by filling the libraries vector.

Parameters
librariesContains an empty vector that should be filled with instances of DynamicLibraryRecord
Returns
If the target does not support dynamic libraries, the method should return kGDBNotSupported. Refer to GDBStatus documentation for more information.

Implemented in GDBServerFoundation::MinimalTargetBase.

virtual IFLASHProgrammer* GDBServerFoundation::IStoppedGDBTarget::GetFLASHProgrammer ( )
pure virtual

Returns a pointer to an IFLASHProgrammer instance, or NULL if not supported. The returned instance should be persistent (e.g. the same object that implements IStoppedGDBTarget).

Implemented in GDBServerFoundation::MinimalTargetBase.

virtual const PlatformRegisterList* GDBServerFoundation::IStoppedGDBTarget::GetRegisterList ( )
pure virtual

Returns a pointer to a persistent list of the registers supported by the target.

This method should return a list to a constant global PlatformRegisterList instance containing the descriptions of all the registers present in the target.

The method is called during initialization and the table returned by it should be present during the entire target lifetime.

virtual GDBStatus GDBServerFoundation::IStoppedGDBTarget::GetThreadList ( std::vector< ThreadRecord > &  threads)
pure virtual

Fills the list of the threads currently present in the target.

If the target supports multiple threads, this method should provide the information about them by filling the threads vector.

Parameters
threadsContains an empty vector that should be filled with instances of ThreadRecord
Returns
If the target does not support multiple threads, the method should return kGDBNotSupported. Refer to GDBStatus documentation for more information.

Implemented in GDBServerFoundation::MinimalTargetBase.

virtual GDBStatus GDBServerFoundation::IStoppedGDBTarget::ReadFrameRelatedRegisters ( int  threadID,
RegisterSetContainer registers 
)
pure virtual

Reads program counter, stack pointer and stack base pointer registers.

Returns
See the GDBStatus description for a list of valid return codes.
Parameters
threadIDSpecifies the ID of the thread to query
registersContains the storage for the register values. The storage is initialized with RegisterValue instances flagged as invalid and sizes set based on the GetRegisterList() call.
Remarks
If this method returns an error, GDB will read all registers using the ReadTargetRegisters() method. Thus it only makes sense to implement this method if reading frame-related registers instead of all registers saves time.

Here's an example implementation of this method:

virtual GDBStatus ReadFrameRelatedRegisters(int threadID, RegisterSetContainer &registers)
{
// (Fill the context structure here)
registers[i386::rgEIP] = RegisterValue(context.Eip, 4);
registers[i386::rgESP] = RegisterValue(context.Esp, 4);
registers[i386::rgEBP] = RegisterValue(context.Ebp, 4);
return kGDBSuccess;
}

Implemented in GDBServerFoundation::MinimalTargetBase.

virtual GDBStatus GDBServerFoundation::IStoppedGDBTarget::ReadTargetMemory ( ULONGLONG  Address,
void *  pBuffer,
size_t *  pSizeInBytes 
)
pure virtual

Reads the memory of the underlying target.

virtual GDBStatus GDBServerFoundation::IStoppedGDBTarget::ReadTargetRegisters ( int  threadID,
RegisterSetContainer registers 
)
pure virtual

Reads the values of all registers from the target.

This method should read all registers from the target (or a single target thread). See the ReadFrameRelatedRegisters() method description for implementation examples.

virtual GDBStatus GDBServerFoundation::IStoppedGDBTarget::RemoveBreakpoint ( BreakpointType  type,
ULONGLONG  Address,
INT_PTR  Cookie 
)
pure virtual

Removes a previously set breakpoint.

This method should remove a breakpoint previously set with CreateBreakpoint().

Parameters
typeEqual to the type argument of the corresponding CreateBreakpoint() call.
AddressEqual to the Address argument of the corresponding CreateBreakpoint() call.
Cookiecontains the arbitrary INT_PTR value provided by the CreateBreakpoint() method.

Implemented in GDBServerFoundation::MinimalTargetBase.

virtual GDBStatus GDBServerFoundation::IStoppedGDBTarget::SetThreadModeForNextCont ( int  threadID,
DebugThreadMode  mode,
OUT bool *  pNeedRestoreCall,
IN OUT INT_PTR *  pRestoreCookie 
)
pure virtual

Sets the mode in which an individual thread will continue before the next debug event.

This method allows setting different continuation modes (e.g. single-step, free run or halt) for different threads of a multi-threaded program. If the target does not support it, the method should return kGDBNotSupported.

Parameters
threadIDSpecifies the ID of the thread that is being controlled
modeSpecifies the mode in which the thread should be put until the next debug event
pNeedRestoreCallSet the value pointed by this argument to TRUE if this method needs to be called again with mode == dtmRestore once the next debug event completes.
pRestoreCookieIf mode is not dtmRestore, you set pNeedRestoreCall to TRUE, this argument can receive an arbitrary INT_PTR value that will be passed to the method later during the dtmRestore call. If mode is dtmRestore, this argument points to the previously saved value.
Remarks
Before the method is actually used, it is called with mode == dtmProbe and an invalid threadID to determine whether the target supports it. Thus, if mode is dtmProbe, the threadID argument should be ignored and the method should immediately return either kGDBNotSupported or kGDBSuccess.

Implemented in GDBServerFoundation::MinimalTargetBase.

virtual GDBStatus GDBServerFoundation::IStoppedGDBTarget::Terminate ( )
pure virtual

Terminates the target.

Implemented in GDBServerFoundation::MinimalTargetBase.

virtual GDBStatus GDBServerFoundation::IStoppedGDBTarget::WriteTargetMemory ( ULONGLONG  Address,
const void *  pBuffer,
size_t  sizeInBytes 
)
pure virtual

Writes the memory of the underlying target.

virtual GDBStatus GDBServerFoundation::IStoppedGDBTarget::WriteTargetRegisters ( int  threadID,
const RegisterSetContainer registers 
)
pure virtual

Writes one or more target registers.

This method should write the target registers that have valid values provided.

Parameters
threadIDSpecifies the ID of the thread to query
registersProvides the values for the registers to write. The size of the registers collection can be determined by calling the RegisterSetContainer::RegisterCount() method. If an i-th register needs to be modified, the registers[i].Valid field is set.
Remarks
Here's an example implementation:
virtual GDBStatus WriteTargetRegisters(int threadID, const RegisterSetContainer &registers)
{
for (size_t i = 0; i < registers.RegisterCount(); i++)
{
if (!registers[i].Valid)
continue;
m_pTargetImpl->WriteRegister(i, registers[i].ToUInt32());
}
return kGDBSuccess;
}

The documentation for this class was generated from the following file: