C# Class VSNDK.DebugEngine.EventDispatcher

Show file Open project: blackberry/VSPlugin Class Usage Examples

Public Properties

Property Type Description
countSIGINT int
inCriticalRegion bool
m_GDBRunMode bool
m_unknownCode bool

Public Methods

Method Description
EventDispatcher ( AD7Engine engine ) : System

Constructor. Starts the thread responsible for handling asynchronous GDB output.

breakpointHit ( uint ID, string threadID ) : void

Update VS when a breakpoint is hit in GDB.

continueExecution ( ) : void

Called after the debug engine has set the initial breakpoints, or to resume a process that was interrupted.

createVar ( string name, bool &hasVsNdK_ ) : string

Creates a variable object.

deleteBreakpoint ( uint GDB_ID ) : bool

Delete a breakpoint in GDB.

deleteVar ( string name, bool hasVsNdK_ ) : void

Deletes a previously created variable object and all of its children.

enableBreakpoint ( uint GDB_ID, bool fEnable ) : bool

Enable or disable a breakpoint.

endDebugSession ( uint exitCode ) : void

Ends the debug session by closing GDB, sending the appropriate events to the SDM, and breaking out of all buffer- and event-listening loops.

enterCriticalRegion ( ) : bool

Control access to a critical region, that manipulates some of the debug engine variables, like its state. This is done to avoid a race condition that can happen when user modifies a breakpoint condition at run time and the same breakpoint is hit. When that happens, only one event will be handled at a time.

getDocumentContext ( string filename, uint line ) : AD7DocumentContext

Returns the document context needed for showing the location of the current instruction pointer.

getStackDepth ( string threadID ) : int

Return the depth of the stack.

getStackFrames ( ) : string

List the frames currently on the stack.

getVariablesForFrame ( uint frameIndex, string threadID ) : string

List the names of local variables and function arguments for the selected frame.

ignoreHitCount ( uint GDB_ID, int ignore ) : bool

Ignore a given number of hit counts in GDB.

killProcess ( ) : void

Kill the child process in which your program is running under gdb.

leaveCriticalRegion ( ) : void

Leave the critical region, that manipulates some of the debug engine variables, like its state. This is done to avoid a race condition that can happen when user modifies a breakpoint condition at run time and the same breakpoint is hit. When that happens, only one event will be handled at a time.

listChildren ( string name ) : string

Return a list of the children of the specified variable object.

lockedBreakpoint ( AD7BoundBreakpoint bbp, bool hit, bool cond ) : bool

Lock a breakpoint before updating its hit counts and/or condition. This is done to avoid a race condition that can happen when user modifies a breakpoint condition at run time and the same breakpoint is hit. When that happens, only one event will be handled at a time.

prepareToModifyBreakpoint ( ) : void

Interrupt the debugged process if necessary before changing a breakpoint.

resetHitCount ( AD7BoundBreakpoint bbp, bool resetCondition ) : bool

Reset current hit count in GDB. There is no way to reset hit counts in GDB. To implement this functionality, the specified GDB breakpoint is deleted and a new one is created with the same conditions, substituting the GDB_ID of the VS breakpoint.

resumeFromInterrupt ( ) : void

If the process was running when the breakpoint was changed, resume the process.

selectThread ( string id ) : void

Make "id" the current thread.

setBreakpoint ( string func, uint &GDB_ID, uint &GDB_line, string &GDB_filename, string &GDB_address ) : bool

Set a breakpoint given a function name.

setBreakpoint ( string filename, uint line, uint &GDB_ID, uint &GDB_line, string &GDB_filename, string &GDB_address ) : bool

Set a breakpoint given a filename and line number.

setBreakpointCondition ( uint GDB_ID, string condition ) : bool

Set breakpoint condition in GDB.

unlockBreakpoint ( AD7BoundBreakpoint bbp, bool hit, bool cond ) : void

Unlock a breakpoint after updating its hit counts and/or condition. This is done to avoid a race condition that can happen when user modifies a breakpoint condition at run time and the same breakpoint is hit. When that happens, only one event will be handled at a time.

updateHitCount ( uint ID, uint hitCount ) : void

Update hit count.

Private Methods

Method Description
setBreakpointImpl ( string command, string command2, uint &GDB_ID, uint &GDB_line, string &GDB_filename, string &GDB_address ) : bool

Code to set the breakpoint in GDB and then confirm and set in Visual Studio

Method Details

EventDispatcher() public method

Constructor. Starts the thread responsible for handling asynchronous GDB output.
public EventDispatcher ( AD7Engine engine ) : System
engine AD7Engine The AD7Engine object that represents the DE.
return System

breakpointHit() public method

Update VS when a breakpoint is hit in GDB.
public breakpointHit ( uint ID, string threadID ) : void
ID uint Breakpoint ID from GDB.
threadID string Thread ID.
return void

continueExecution() public method

Called after the debug engine has set the initial breakpoints, or to resume a process that was interrupted.
public continueExecution ( ) : void
return void

createVar() public method

Creates a variable object.
public createVar ( string name, bool &hasVsNdK_ ) : string
name string Name of the variable.
hasVsNdK_ bool Boolean value that indicates if the variable name has the prefix VsNdK_.
return string

deleteBreakpoint() public method

Delete a breakpoint in GDB.
public deleteBreakpoint ( uint GDB_ID ) : bool
GDB_ID uint Breakpoint ID in GDB.
return bool

deleteVar() public method

Deletes a previously created variable object and all of its children.
public deleteVar ( string name, bool hasVsNdK_ ) : void
name string Name of the variable.
hasVsNdK_ bool Boolean value that indicates if the variable name has the prefix VsNdK_.
return void

enableBreakpoint() public method

Enable or disable a breakpoint.
public enableBreakpoint ( uint GDB_ID, bool fEnable ) : bool
GDB_ID uint Breakpoint ID in GDB.
fEnable bool If true, enable the breakpoint. If false, disable it.
return bool

endDebugSession() public method

Ends the debug session by closing GDB, sending the appropriate events to the SDM, and breaking out of all buffer- and event-listening loops.
public endDebugSession ( uint exitCode ) : void
exitCode uint The exit code.
return void

enterCriticalRegion() public method

Control access to a critical region, that manipulates some of the debug engine variables, like its state. This is done to avoid a race condition that can happen when user modifies a breakpoint condition at run time and the same breakpoint is hit. When that happens, only one event will be handled at a time.
public enterCriticalRegion ( ) : bool
return bool

getDocumentContext() public method

Returns the document context needed for showing the location of the current instruction pointer.
public getDocumentContext ( string filename, uint line ) : AD7DocumentContext
filename string File name.
line uint Line number.
return AD7DocumentContext

getStackDepth() public method

Return the depth of the stack.
public getStackDepth ( string threadID ) : int
threadID string Thread ID.
return int

getStackFrames() public method

List the frames currently on the stack.
public getStackFrames ( ) : string
return string

getVariablesForFrame() public method

List the names of local variables and function arguments for the selected frame.
public getVariablesForFrame ( uint frameIndex, string threadID ) : string
frameIndex uint Frame number.
threadID string Thread ID.
return string

ignoreHitCount() public method

Ignore a given number of hit counts in GDB.
public ignoreHitCount ( uint GDB_ID, int ignore ) : bool
GDB_ID uint Breakpoint ID in GDB.
ignore int Number of hit counts to ignore.
return bool

killProcess() public method

Kill the child process in which your program is running under gdb.
public killProcess ( ) : void
return void

leaveCriticalRegion() public method

Leave the critical region, that manipulates some of the debug engine variables, like its state. This is done to avoid a race condition that can happen when user modifies a breakpoint condition at run time and the same breakpoint is hit. When that happens, only one event will be handled at a time.
public leaveCriticalRegion ( ) : void
return void

listChildren() public method

Return a list of the children of the specified variable object.
public listChildren ( string name ) : string
name string Variable name.
return string

lockedBreakpoint() public method

Lock a breakpoint before updating its hit counts and/or condition. This is done to avoid a race condition that can happen when user modifies a breakpoint condition at run time and the same breakpoint is hit. When that happens, only one event will be handled at a time.
public lockedBreakpoint ( AD7BoundBreakpoint bbp, bool hit, bool cond ) : bool
bbp AD7BoundBreakpoint Breakpoint to be locked.
hit bool True if user is adding/modifying count and conditions upon which a breakpoint is fired. It is also true /// when event dispatcher is handling a breakpoint hit.
cond bool True if user is adding/modifying conditions under which a conditional breakpoint fires. It is also true /// when event dispatcher is handling a breakpoint hit.
return bool

prepareToModifyBreakpoint() public method

Interrupt the debugged process if necessary before changing a breakpoint.
public prepareToModifyBreakpoint ( ) : void
return void

resetHitCount() public method

Reset current hit count in GDB. There is no way to reset hit counts in GDB. To implement this functionality, the specified GDB breakpoint is deleted and a new one is created with the same conditions, substituting the GDB_ID of the VS breakpoint.
public resetHitCount ( AD7BoundBreakpoint bbp, bool resetCondition ) : bool
bbp AD7BoundBreakpoint The VS breakpoint.
resetCondition bool Is false when this method is called by SetCondition, true if not. Used to avoid setting /// breakpoint conditions again in case it is called by SetCondition method.
return bool

resumeFromInterrupt() public method

If the process was running when the breakpoint was changed, resume the process.
public resumeFromInterrupt ( ) : void
return void

selectThread() public method

Make "id" the current thread.
public selectThread ( string id ) : void
id string Thread ID.
return void

setBreakpoint() public method

Set a breakpoint given a function name.
public setBreakpoint ( string func, uint &GDB_ID, uint &GDB_line, string &GDB_filename, string &GDB_address ) : bool
func string Function name.
GDB_ID uint Returns the breakpoint ID in GDB.
GDB_line uint Returns the breakpoint Line Number.
GDB_filename string Returns the breakpoint File Name.
GDB_address string Returns the Breakpoint Address.
return bool

setBreakpoint() public method

Set a breakpoint given a filename and line number.
public setBreakpoint ( string filename, uint line, uint &GDB_ID, uint &GDB_line, string &GDB_filename, string &GDB_address ) : bool
filename string Full path and filename for the code source.
line uint The line number for the breakpoint.
GDB_ID uint Returns the breakpoint ID in GDB.
GDB_line uint Returns the breakpoint Line Number.
GDB_filename string Returns the breakpoint File Name.
GDB_address string Returns the Breakpoint Address.
return bool

setBreakpointCondition() public method

Set breakpoint condition in GDB.
public setBreakpointCondition ( uint GDB_ID, string condition ) : bool
GDB_ID uint Breakpoint ID in GDB.
condition string Condition to be set. When empty (""), means to remove any previous condition.
return bool

unlockBreakpoint() public method

Unlock a breakpoint after updating its hit counts and/or condition. This is done to avoid a race condition that can happen when user modifies a breakpoint condition at run time and the same breakpoint is hit. When that happens, only one event will be handled at a time.
public unlockBreakpoint ( AD7BoundBreakpoint bbp, bool hit, bool cond ) : void
bbp AD7BoundBreakpoint Breakpoint to be locked.
hit bool True if user is adding/modifying count and conditions upon which a breakpoint is fired. It is also true /// when event dispatcher is handling a breakpoint hit.
cond bool True if user is adding/modifying conditions under which a conditional breakpoint fires. It is also true /// when event dispatcher is handling a breakpoint hit.
return void

updateHitCount() public method

Update hit count.
public updateHitCount ( uint ID, uint hitCount ) : void
ID uint Breakpoint ID in GDB.
hitCount uint Hit count.
return void

Property Details

countSIGINT public property

There is a GDB bug that causes a message "Quit (expect signal SIGINT when the program is resumed)". If this message occurs 5 times, VSNDK will end the debug session. That's why this variable is needed, to count the amount of this kind of message that is received in a sequence.
public int countSIGINT
return int

inCriticalRegion public property

Variable that is manipulated only in methods enterCriticalRegion and leaveCriticalRegion
public bool inCriticalRegion
return bool

m_GDBRunMode public static property

Boolean variable that indicates the GDB state: TRUE -> run mode; FALSE -> break mode.
public static bool m_GDBRunMode
return bool

m_unknownCode public static property

Boolean variable that indicates if the current code is known or unknown, i.e., if there is a source code file associated.
public static bool m_unknownCode
return bool