ROSE  0.9.12.19
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Rose::BinaryAnalysis::Debugger Class Reference

Description

Simple debugger.

This class implements a very simple debugger.

Definition at line 19 of file BinaryDebugger.h.

#include <BinaryDebugger.h>

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

Classes

class  Specimen
 Describes the specimen to be debugged. More...
 

Public Types

enum  DetachMode {
  KILL,
  DETACH,
  CONTINUE,
  NOTHING
}
 How to detach from a process when this object is destroyed. More...
 
enum  Flag {
  ATTACH = 0x00000001,
  REDIRECT_INPUT = 0x00000002,
  REDIRECT_OUTPUT = 0x00000004,
  REDIRECT_ERROR = 0x00000008,
  CLOSE_FILES = 0x00000010,
  DEFAULT_FLAGS = 0x00000013
}
 Flags controlling operation. More...
 
typedef Sawyer::SharedPointer< DebuggerPtr
 Shared-ownership pointer to Debugger. More...
 

Public Member Functions

void attach (const Specimen &)
 Attach to a specimen. 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...
 
Sawyer::Container::BitVector readMemory (rose_addr_t va, size_t nBytes, ByteOrder::Endianness order)
 Read subordinate memory as a bit vector. 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...
 
const RegisterDictionaryregisterDictionary () const
 Available registers. More...
 
Disassemblerdisassembler () const
 Disassembler. More...
 
int waitpidStatus () const
 Returns the last status from a call to waitpid. More...
 
- Public Member Functions inherited from Sawyer::SharedObject
 SharedObject ()
 Default constructor. More...
 
 SharedObject (const SharedObject &)
 Copy constructor. More...
 
virtual ~SharedObject ()
 Virtual destructor. More...
 
SharedObjectoperator= (const SharedObject &)
 Assignment. More...
 

Static Public Member Functions

static Ptr instance ()
 Create a debugger object that isn't attached to any subordinate process. More...
 
static Ptr instance (const Specimen &specimen)
 Create a debugger and start debugging a specimen. More...
 

Protected Member Functions

 Debugger (const Specimen &specimen)
 Construct a debugger attached to a specimen. More...
 

Member Typedef Documentation

Shared-ownership pointer to Debugger.

See Shared ownership.

Definition at line 22 of file BinaryDebugger.h.

Member Enumeration Documentation

How to detach from a process when this object is destroyed.

Enumerator
KILL 

Kill the process.

DETACH 

Simply detach leaving process in current state.

CONTINUE 

Detach from process and cause it to continue running.

NOTHING 

Do nothing.

Definition at line 25 of file BinaryDebugger.h.

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 33 of file BinaryDebugger.h.

Constructor & Destructor Documentation

Rose::BinaryAnalysis::Debugger::Debugger ( const Specimen specimen)
inlineexplicitprotected

Construct a debugger attached to a specimen.

Definition at line 184 of file BinaryDebugger.h.

References attach().

Member Function Documentation

static Ptr Rose::BinaryAnalysis::Debugger::instance ( )
inlinestatic

Create a debugger object that isn't attached to any subordinate process.

Definition at line 201 of file BinaryDebugger.h.

Referenced by Rose::BinaryAnalysis::InstructionSemantics2::NativeSemantics::Dispatcher::instance().

static Ptr Rose::BinaryAnalysis::Debugger::instance ( const Specimen specimen)
inlinestatic

Create a debugger and start debugging a specimen.

Definition at line 206 of file BinaryDebugger.h.

void Rose::BinaryAnalysis::Debugger::attach ( const Specimen )

Attach to a specimen.

Referenced by Debugger().

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

Returns true if attached to a subordinate.

Return value is the subordinate process ID.

Definition at line 218 of file BinaryDebugger.h.

void Rose::BinaryAnalysis::Debugger::detach ( )

Detach from the subordinate.

void Rose::BinaryAnalysis::Debugger::terminate ( )

Terminate the subordinate.

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

Set execution address.

rose_addr_t Rose::BinaryAnalysis::Debugger::executionAddress ( )

Get execution address.

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

Set breakpoints.

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

Remove breakpoints.

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

Remove all breakpoints.

Definition at line 243 of file BinaryDebugger.h.

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

void Rose::BinaryAnalysis::Debugger::singleStep ( )

Execute one instruction.

void Rose::BinaryAnalysis::Debugger::runToBreakpoint ( )

Run until the next breakpoint is reached.

void Rose::BinaryAnalysis::Debugger::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::Debugger::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::Debugger::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();
Sawyer::Container::BitVector Rose::BinaryAnalysis::Debugger::readMemory ( rose_addr_t  va,
size_t  nBytes,
ByteOrder::Endianness  order 
)

Read subordinate memory as a bit vector.

uint64_t value = debugger->readMemory(0x12345678, 4, ByteOrder::ORDER_LSB).toInteger();
size_t Rose::BinaryAnalysis::Debugger::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::Debugger::isTerminated ( )

Returns true if the subordinate terminated.

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

String describing how the subordinate process terminated.

const RegisterDictionary* Rose::BinaryAnalysis::Debugger::registerDictionary ( ) const

Available registers.

Disassembler* Rose::BinaryAnalysis::Debugger::disassembler ( ) const
inline

Disassembler.

Definition at line 294 of file BinaryDebugger.h.

int Rose::BinaryAnalysis::Debugger::waitpidStatus ( ) const
inline

Returns the last status from a call to waitpid.

Definition at line 299 of file BinaryDebugger.h.


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