MSP430Proxy::SoftwareBreakpointManager Class Reference

Allows setting and removing software breakpoints in FLASH. More...

#include <SoftwareBreakpointManager.h>

Public Types

enum  BreakpointState { NoBreakpoint = 0, BreakpointPending, BreakpointInactive, BreakpointActive }
 

Public Member Functions

bool SetBreakpoint (unsigned addr)
 Queues a breakpoint set request until the next call to CommitBreakpoints()
 
bool RemoveBreakpoint (unsigned addr)
 Queues a breakpoint removal request until the next call to RemoveBreakpoints()
 
bool CommitBreakpoints ()
 Modifies the FLASH memory to reflect the changed breakpoints.
 
BreakpointState GetBreakpointState (unsigned addr)
 Returns the state of a breakpoint at a given address.
 
bool GetOriginalInstruction (unsigned addr, unsigned short *pInsn)
 Returns the original instruction that was present at a given address before the breakpoint was set.
 
void HideOrRestoreBreakpointsInMemorySnapshot (unsigned addr, void *pBlock, size_t length, bool hideBreakpoints)
 Modifies the given memory snapshot to hide or show the software breakpoints.
 
 SoftwareBreakpointManager (unsigned flashStart, unsigned flashEnd, unsigned short breakInstruction, bool instantCleanup)
 Creates an instance of the SoftwareBreakpointManager class.
 

Detailed Description

Allows setting and removing software breakpoints in FLASH.

This class sets and removes software breakpoints in the FLASH memory of an MSP430 device. It minimizes the amount of write/erase cycles by queuing the breakpoint requests and only modifying the FLASH when CommitBreakpoints() method is called.

Software breakpoint mechanism

The MSP430 devices implement software breakpoints by programming one of the hardware breakpoints to be triggered when a certain instruction is executed. Typically, the "MOV.B r3,r3" instruction with code 0x4343 is used for software breakpoints. The instruction itself does nothing, and should not normally appear in the normal MSP430 code. When the hardware breakpoint is programmed accordingly, replacing any actual instruction with the breakpoint instruction will cause the breakpoint to trigger at that address without consuming any additional hardware breakpoint resources. Note that setting and removing the breakpoints in FLASH requires erasing and writing the FLASH and thus consumes the write cycles.

Definition at line 17 of file SoftwareBreakpointManager.h.

Member Enumeration Documentation

Enumerator:
NoBreakpoint 

Breakpoint is not set at this address.

BreakpointPending 

Breakpoint will be created in the next call to CommitBreakpoints()

BreakpointInactive 

Breakpoint is present in memory, but should be ignored and removed next time the segment is overwritten.

BreakpointActive 

Breakpoint is present in memory and should be handled.

Definition at line 20 of file SoftwareBreakpointManager.h.

Constructor & Destructor Documentation

MSP430Proxy::SoftwareBreakpointManager::SoftwareBreakpointManager ( unsigned  flashStart,
unsigned  flashEnd,
unsigned short  breakInstruction,
bool  instantCleanup 
)

Creates an instance of the SoftwareBreakpointManager class.

Parameters
flashStartSpecifies the address where the FLASH memory starts
flashEndSpecifies the address of the last byte of the FLASH memory
breakInstructionSpecifies the instruction that is used as a software breakpoint. One of the hardware breakpoints should be programmed to trigger when this instruction gets executed.
instantCleanupIf this argument is set to false, removing a breakpoint won't cause a FLASH rewrite cycle. Instead, the breakpoint will be marked as inactive (when it hits, the software should ignore it and resume execution). In this mode the inactive breakpoints will be physically removed only when the same FLASH block is erased and rewritten to set another breakpoint.
Remarks
The size of the FLASH erase block is assumed to be a constant of 512 bytes.

Definition at line 8 of file SoftwareBreakpointManager.cpp.

Member Function Documentation

bool MSP430Proxy::SoftwareBreakpointManager::CommitBreakpoints ( )

Modifies the FLASH memory to reflect the changed breakpoints.

Definition at line 99 of file SoftwareBreakpointManager.cpp.

MSP430Proxy::SoftwareBreakpointManager::BreakpointState MSP430Proxy::SoftwareBreakpointManager::GetBreakpointState ( unsigned  addr)

Returns the state of a breakpoint at a given address.

Definition at line 171 of file SoftwareBreakpointManager.cpp.

bool MSP430Proxy::SoftwareBreakpointManager::GetOriginalInstruction ( unsigned  addr,
unsigned short *  pInsn 
)

Returns the original instruction that was present at a given address before the breakpoint was set.

Definition at line 180 of file SoftwareBreakpointManager.cpp.

void MSP430Proxy::SoftwareBreakpointManager::HideOrRestoreBreakpointsInMemorySnapshot ( unsigned  addr,
void *  pBlock,
size_t  length,
bool  hideBreakpoints 
)

Modifies the given memory snapshot to hide or show the software breakpoints.

This method is used to hide the software breakpoints from the memory dumps sent to gdb so that the gdb disassembler still shows the original code.

Definition at line 197 of file SoftwareBreakpointManager.cpp.

bool MSP430Proxy::SoftwareBreakpointManager::RemoveBreakpoint ( unsigned  addr)

Queues a breakpoint removal request until the next call to RemoveBreakpoints()

Definition at line 50 of file SoftwareBreakpointManager.cpp.

bool MSP430Proxy::SoftwareBreakpointManager::SetBreakpoint ( unsigned  addr)

Queues a breakpoint set request until the next call to CommitBreakpoints()

Definition at line 20 of file SoftwareBreakpointManager.cpp.


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