ROSE  0.9.10.89
Public Types | Public Member Functions | List of all members
Rose::BinaryAnalysis::BinaryDebugger Class Reference

Description

Simple debugger.

This class implements a very simple debugger.

Definition at line 13 of file BinaryDebugger.h.

#include <BinaryDebugger.h>

Inheritance diagram for Rose::BinaryAnalysis::BinaryDebugger:
Inheritance graph
[legend]
Collaboration diagram for Rose::BinaryAnalysis::BinaryDebugger:
Collaboration graph
[legend]

Public Types

enum  DetachMode {
  KILL,
  DETACH,
  CONTINUE,
  NOTHING
}
 
enum  Flag {
  ATTACH = 0x00000001,
  REDIRECT_INPUT = 0x00000002,
  REDIRECT_OUTPUT = 0x00000004,
  REDIRECT_ERROR = 0x00000008,
  CLOSE_FILES = 0x00000010,
  DEFAULT_FLAGS = 0x00000013
}
 Flags controlling operation. More...
 

Public Member Functions

 BinaryDebugger (int pid, unsigned flags=DEFAULT_FLAGS)
 
 BinaryDebugger (const std::string &exeName, unsigned flags=DEFAULT_FLAGS)
 
 BinaryDebugger (const std::vector< std::string > &exeNameAndArgs, unsigned flags=DEFAULT_FLAGS)
 
void attach (int pid, unsigned flags=DEFAULT_FLAGS)
 Attach to an existing process. More...
 
int isAttached ()
 Returns true if attached to a subordinate. More...
 
void detach ()
 Detach from the subordinate. More...
 
void terminate ()
 Terminate the subordinate. More...
 
void executionAddress (rose_addr_t va)
 Set execution address. More...
 
rose_addr_t executionAddress ()
 Get execution address. More...
 
void setBreakpoint (const AddressInterval &)
 Set breakpoints. More...
 
void clearBreakpoint (const AddressInterval &)
 Remove breakpoints. More...
 
void clearBreakpoints ()
 Remove all breakpoints. More...
 
void singleStep ()
 Execute one instruction. More...
 
void runToBreakpoint ()
 Run until the next breakpoint is reached. More...
 
void runToSyscall ()
 Run until the next system call. More...
 
size_t kernelWordSize ()
 Obtain and cache kernel's word size in bits. More...
 
Sawyer::Container::BitVector readRegister (RegisterDescriptor)
 Read subordinate register. More...
 
size_t readMemory (rose_addr_t va, size_t nBytes, uint8_t *buffer)
 Read subordinate memory. More...
 
bool isTerminated ()
 Returns true if the subordinate terminated. More...
 
std::string howTerminated ()
 String describing how the subordinate process terminated. More...
 
void attach (const std::string &fileName, unsigned flags=DEFAULT_FLAGS)
 Program to debug. More...
 
void attach (const std::vector< std::string > &fileNameAndArgs, unsigned flags=DEFAULT_FLAGS)
 Program to debug. More...
 

Member Enumeration Documentation

Flags controlling operation.

Enumerator
ATTACH 

Attach to existing process.

REDIRECT_INPUT 

Redirect input from /dev/null.

REDIRECT_OUTPUT 

Redirect output to /dev/null.

REDIRECT_ERROR 

Redirect standard error to /dev/null.

CLOSE_FILES 

Close all file descriptors > 2.

DEFAULT_FLAGS 

Default flags.

Definition at line 18 of file BinaryDebugger.h.

Member Function Documentation

void Rose::BinaryAnalysis::BinaryDebugger::attach ( int  pid,
unsigned  flags = DEFAULT_FLAGS 
)

Attach to an existing process.

Arranges for an existing process to be debugged. If the ATTACH flag is set (the default) then the debugger attempts to attach to that process and gain control, otherwise it assumes that the calling process has already done that.

void Rose::BinaryAnalysis::BinaryDebugger::attach ( const std::string &  fileName,
unsigned  flags = DEFAULT_FLAGS 
)

Program to debug.

The program can be specified as a single name or as a name and arguments.

void Rose::BinaryAnalysis::BinaryDebugger::attach ( const std::vector< std::string > &  fileNameAndArgs,
unsigned  flags = DEFAULT_FLAGS 
)

Program to debug.

The program can be specified as a single name or as a name and arguments.

int Rose::BinaryAnalysis::BinaryDebugger::isAttached ( )
inline

Returns true if attached to a subordinate.

Return value is the subordinate process ID.

Definition at line 93 of file BinaryDebugger.h.

void Rose::BinaryAnalysis::BinaryDebugger::detach ( )

Detach from the subordinate.

void Rose::BinaryAnalysis::BinaryDebugger::terminate ( )

Terminate the subordinate.

void Rose::BinaryAnalysis::BinaryDebugger::executionAddress ( rose_addr_t  va)

Set execution address.

rose_addr_t Rose::BinaryAnalysis::BinaryDebugger::executionAddress ( )

Get execution address.

void Rose::BinaryAnalysis::BinaryDebugger::setBreakpoint ( const AddressInterval )

Set breakpoints.

void Rose::BinaryAnalysis::BinaryDebugger::clearBreakpoint ( const AddressInterval )

Remove breakpoints.

void Rose::BinaryAnalysis::BinaryDebugger::clearBreakpoints ( )
inline

Remove all breakpoints.

Definition at line 114 of file BinaryDebugger.h.

References Sawyer::Container::IntervalSet< I >::clear().

void Rose::BinaryAnalysis::BinaryDebugger::singleStep ( )

Execute one instruction.

void Rose::BinaryAnalysis::BinaryDebugger::runToBreakpoint ( )

Run until the next breakpoint is reached.

void Rose::BinaryAnalysis::BinaryDebugger::runToSyscall ( )

Run until the next system call.

The subordinate is run until it is about to make a system call or has just returned from a system call, or it has encountered a signal or terminated. Execution does not stop at break points.

size_t Rose::BinaryAnalysis::BinaryDebugger::kernelWordSize ( )

Obtain and cache kernel's word size in bits.

The wordsize of the kernel is not necessarily the same as the word size of the compiled version of this header.

Sawyer::Container::BitVector Rose::BinaryAnalysis::BinaryDebugger::readRegister ( RegisterDescriptor  )

Read subordinate register.

Some registers are wider than what can be easily represented on this architecture (e.g., x86 XMM registers are 128 bits), therefore return the result as a bit vector. If you want just the low-order 64 bits, invoke it like this:

uint64_t value = debugger.readRegister(RIP).toInteger();
size_t Rose::BinaryAnalysis::BinaryDebugger::readMemory ( rose_addr_t  va,
size_t  nBytes,
uint8_t *  buffer 
)

Read subordinate memory.

Returns the number of bytes read. The implementation accesses the subordinate memory via proc filesystem rather than sending PTRACE_PEEKDATA commands. This allows large areas of memory to be read efficiently.

bool Rose::BinaryAnalysis::BinaryDebugger::isTerminated ( )

Returns true if the subordinate terminated.

std::string Rose::BinaryAnalysis::BinaryDebugger::howTerminated ( )

String describing how the subordinate process terminated.


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