C# Class Mono.Debugger.Backend.SingleSteppingEngine

The single stepping engine is responsible for doing all the stepping operations. sse - short for single stepping engine. stepping operation - an operation which has been invoked by the user such as StepLine(), NextLine() etc. atomic operation - an operation which the sse invokes on the target such as stepping one machine instruction or resuming the target until a breakpoint is hit. step frame - an address range; the sse invokes atomic operations until the target hit a breakpoint, received a signal or stopped at an address outside this range. temporary breakpoint - a breakpoint which is automatically removed the next time the target stopped; it is used to step over method calls. source stepping op - stepping operation based on the program's source code, such as StepLine() or NextLine(). native stepping op - stepping operation based on the machine code such as StepInstruction() or NextInstruction(). The SingleSteppingEngine supports both synchronous and asynchronous operations; in synchronous mode, the engine waits until the child has stopped before returning. In either case, the step commands return true on success and false an error. Since the SingleSteppingEngine can be used from multiple threads at the same time, you can no longer safely use the `State' property to find out whether the target is stopped or not. It is safe to call all the step commands from multiple threads, but for obvious reasons only one command can run at a time. So if you attempt to issue a step command while the engine is still busy, the step command will return false to signal this error. The ThreadManager creates one SingleSteppingEngine instance for each thread in the target. The `SingleSteppingEngine' class is basically just responsible for whatever happens in the background thread: processing commands and events. Their methods are just meant to be called from the SingleSteppingEngine (since it's a protected nested class they can't actually be called from anywhere else). See the `Thread' class for the "user interface".
Inheritance: ThreadServant
ファイルを表示 Open project: baulig/debugger Class Usage Examples

Protected Properties

Property Type Description
current_backtrace Backtrace
current_frame System.Diagnostics.StackFrame
current_method Method
registers Registers

Private Properties

Property Type Description
AbortInvocation void
AbortRuntimeInvoke OperationRuntimeInvoke
AcquireThreadLock void
ActivatePendingBreakpoints bool
CreateStepFrame StepFrame
CreateStepFrame StepFrame
DetachThread void
DoTargetAccess object
GetCallbackFrame Inferior.CallbackFrame
GetRuntimeInvokedFunction Mono.Debugger.Languages.TargetFunctionType
InitializeBreakpoints bool
InsertBreakpoint void
Invoke object
Old_Step ThreadCommandResult
OnExecd CommandResult
OnManagedCallback bool
OnManagedThreadCreated void
OnManagedThreadExited void
OnModuleLoaded bool
OnThreadExited void
ProcessOperation CommandResult
ReleaseThreadLock void
ReleaseThreadLock void
RemoveBreakpoint void
ResumeUserThread void
SendCommand object
SetMainReturnAddress void
SetManagedThreadData void
SetTID void
StartOperation CommandResult
SuspendUserThread void
check_method_operation System.Operation
check_runtime_version bool
child_breakpoint bool
compute_frame System.Diagnostics.StackFrame
frame_changed System.Operation
handle_exception bool
is_in_step_frame bool
is_managed_frame bool
lookup_breakpoint Breakpoint
save_stack StackData
step_over_breakpoint bool
throw_exception ExceptionAction

Public Methods

Method Description
CallMethod ( TargetAddress method, TargetAddress method_arg, TargetObject object_arg ) : CommandResult
CallMethod ( TargetAddress method, long arg1, long arg2 ) : CommandResult
CallMethod ( TargetAddress method, long arg1, long arg2, long arg3, string string_argument ) : CommandResult
Detach ( ) : void
DisassembleInstruction ( Method method, TargetAddress address ) : AssemblerLine
DisassembleMethod ( Method method ) : AssemblerMethod
GetBacktrace ( Backtrace mode, int max_frames ) : Backtrace
GetInstructionSize ( TargetAddress address ) : int
GetMemoryMaps ( ) : TargetMemoryArea[]
GetRegisters ( ) : Registers
Kill ( ) : void
Lookup ( TargetAddress address ) : Method
ManagedCallback ( ManagedCallbackFunction func, CommandResult result ) : bool
PrintObject ( Style style, TargetObject obj, DisplayFormat format ) : string
PrintType ( Style style, TargetType type ) : string
ProcessEvent ( Inferior cevent ) : bool
ProcessEvent ( int status ) : void

This is called from the SingleSteppingEngine's main event loop to give us the next event - `status' has no meaning to us, it's just meant to be passed to inferior.ProcessEvent() to get the actual event.

Actually, `status' is the waitpid() status code. In Linux 2.6.x, you can call waitpid() from any thread in the debugger, but we need to get the target's registers to find out whether it's a breakpoint etc. That's done in inferior.ProcessEvent() - which must always be called from the engine's thread.

ReadAddress ( TargetAddress address ) : TargetAddress
ReadBuffer ( TargetAddress address, int size ) : byte[]
ReadByte ( TargetAddress address ) : byte
ReadInteger ( TargetAddress address ) : int
ReadLongInteger ( TargetAddress address ) : long
ReadMemory ( TargetAddress address, int size ) : TargetBlob
ReadString ( TargetAddress address ) : string
Return ( ReturnMode mode ) : CommandResult
RuntimeInvoke ( TargetFunctionType function, TargetStructObject object_argument, TargetObject param_objects, RuntimeInvokeFlags flags, RuntimeInvokeResult result ) : void
SetKilledFlag ( ) : void
SetRegisters ( Registers registers ) : void
SimpleLookup ( TargetAddress address, bool exact_match ) : Symbol
SingleSteppingEngine ( ThreadManager manager, Process process, Inferior inferior, int pid ) : System
SingleSteppingEngine ( ThreadManager manager, Process process, ProcessStart start ) : System
StartApplication ( CommandResult result ) : CommandResult
StartExecedChild ( CommandResult result ) : CommandResult
StartForkedChild ( CommandResult result ) : CommandResult
StartSuspended ( ) : void
StartThread ( CommandResult result ) : CommandResult
Step ( ThreadingModel model, StepMode mode, StepFrame frame ) : CommandResult
Stop ( ) : void
ToString ( ) : string
WriteAddress ( TargetAddress address, TargetAddress value ) : void
WriteBuffer ( TargetAddress address, byte buffer ) : void
WriteByte ( TargetAddress address, byte value ) : void
WriteInteger ( TargetAddress address, int value ) : void
WriteLongInteger ( TargetAddress address, long value ) : void

Protected Methods

Method Description
CheckTrampoline ( Instruction instruction, TrampolineHandler handler ) : bool
DoAbortInvocation ( long rti_id ) : void
DoDetach ( ) : void
DoDispose ( ) : void
DoProcessEvent ( Inferior cevent ) : void
ExecuteOperation ( System.Operation operation ) : void
MethodHasSource ( Method method ) : bool
OperationCompleted ( TargetEventArgs args ) : void
OperationCompleted ( TargetEventArgs args, bool suspended ) : void
OperationInterrupted ( ) : void
ProcessOperationEvent ( Inferior cevent ) : void
PushOperation ( System.Operation operation ) : void
PushOperationNoExec ( System.Operation operation ) : void
SingleSteppingEngine ( ThreadManager manager, Process process ) : System
StartOperation ( ) : void

Start a new stepping operation. All stepping operations are done asynchronously. The inferior basically just knows two kinds of stepping operations: there is do_continue() to continue execution (until a breakpoint is hit or the target receives a signal or exits) and there is do_step_native() to single-step one machine instruction. There's also a version of do_continue() which takes an address - it inserts a temporary breakpoint on that address and calls do_continue(). Let's call these "atomic operations" while a "stepping operation" is something like stepping until the next source line. We normally need to do several atomic operations for each stepping operation. We start a new stepping operation here, but what we actually do is starting an atomic operation on the target. Note that we just start it, but don't wait until is completed. Once the target is running, we go back to the main event loop and wait for it (or another thread) to stop (or to get another command from the user).

check_inferior ( ) : void
disable_extended_notification ( NotificationType type ) : void
do_continue ( ) : void

Resume the target.

do_continue ( TargetAddress until ) : void
do_next ( ) : void

Step over the next machine instruction.

do_step ( ) : void
do_step_native ( ) : void
enable_extended_notification ( NotificationType type ) : void
enforce_managed_context ( ) : void
frames_invalid ( ) : void
insert_lmf_breakpoint ( TargetAddress lmf_address ) : void
insert_temporary_breakpoint ( TargetAddress address ) : void
remove_lmf_breakpoint ( ) : void
remove_temporary_breakpoint ( ) : void
request_managed_callback ( ManagedCallbackData data ) : void
restore_stack ( StackData stack ) : void
set_registers ( Registers registers ) : void
update_current_frame ( StackFrame new_frame ) : void

Private Methods

Method Description
AbortInvocation ( long rti_id ) : void
AbortRuntimeInvoke ( long rti_id ) : OperationRuntimeInvoke
AcquireThreadLock ( ) : void

Interrupt any currently running stepping operation, but don't send any notifications to the caller. The currently running operation is automatically resumed when ReleaseThreadLock() is called.

ActivatePendingBreakpoints ( Module module ) : bool
CreateStepFrame ( ) : StepFrame

Create a step frame to step until the next source line.

CreateStepFrame ( StepMode mode ) : StepFrame

Create a step frame for a native stepping operation.

DetachThread ( ) : void
DoTargetAccess ( TargetAccessHandler func ) : object
GetCallbackFrame ( TargetAddress stack_pointer, bool exact_match ) : Inferior.CallbackFrame
GetRuntimeInvokedFunction ( long ID ) : TargetFunctionType
InitializeBreakpoints ( ) : bool
InsertBreakpoint ( BreakpointHandle handle, TargetAddress address, int domain ) : void
Invoke ( TargetAccessDelegate func, object data ) : object
Old_Step ( StepMode mode, StepFrame frame ) : ThreadCommandResult
OnExecd ( SingleSteppingEngine new_engine ) : CommandResult
OnManagedCallback ( Queue callbacks ) : bool
OnManagedThreadCreated ( TargetAddress end_stack_address ) : void
OnManagedThreadExited ( ) : void
OnModuleLoaded ( Module module ) : bool
OnThreadExited ( Inferior cevent ) : void
ProcessOperation ( System.Operation operation ) : CommandResult
ReleaseThreadLock ( ) : void
ReleaseThreadLock ( Inferior cevent ) : void
RemoveBreakpoint ( BreakpointHandle handle ) : void
ResumeUserThread ( CommandResult result ) : void
SendCommand ( TargetAccessDelegate target ) : object
SetMainReturnAddress ( TargetAddress main_ret ) : void
SetManagedThreadData ( TargetAddress lmf_address, TargetAddress extended_notifications_addr ) : void
SetTID ( long tid ) : void
StartOperation ( System.Operation operation ) : CommandResult
SuspendUserThread ( ) : void
check_method_operation ( TargetAddress address, Method method, SourceAddress source, System.Operation operation ) : System.Operation

Checks whether to do a "method operation". This is only used while doing a source stepping operation and ensures that we don't stop somewhere inside a method's prologue code or between two source lines.

check_runtime_version ( int major, int minor ) : bool
child_breakpoint ( Inferior cevent, int index, Breakpoint &bpt ) : bool

A breakpoint has been hit; now the sse needs to find out what do do: either ignore the breakpoint and continue or keep the target stopped and send out the notification. If @index is zero, we hit an "unknown" breakpoint - ie. a breakpoint which we did not create. Normally, this means that there is a breakpoint instruction (such as G_BREAKPOINT ()) in the code. Such unknown breakpoints are handled by the Debugger; one of the language backends may recognize the breakpoint's address, for instance if this is the JIT's breakpoint trampoline. Returns true if the target should remain stopped and false to continue stepping. If we can't find a handler for the breakpoint, the default is to stop the target and let the user decide what to do.

compute_frame ( TargetAddress address ) : StackFrame
frame_changed ( TargetAddress address, System.Operation operation ) : System.Operation

This is called when a stepping operation is completed or something unexpected happened (received signal etc.). Normally, we just compute the new StackFrame here, but we may also discover that we need to do one more stepping operation, see check_method_operation().

handle_exception ( TargetAddress stack, TargetAddress exc, TargetAddress ip ) : bool
is_in_step_frame ( StepFrame frame, TargetAddress address ) : bool

Check whether @address is inside @frame.

is_managed_frame ( ) : bool
lookup_breakpoint ( int index ) : Breakpoint
save_stack ( long id ) : StackData
step_over_breakpoint ( bool singlestep, TargetAddress until ) : bool
throw_exception ( TargetAddress stack, TargetAddress exc, TargetAddress ip ) : ExceptionAction

Method Details

CallMethod() public method

public CallMethod ( TargetAddress method, TargetAddress method_arg, TargetObject object_arg ) : CommandResult
method TargetAddress
method_arg TargetAddress
object_arg Mono.Debugger.Languages.TargetObject
return CommandResult

CallMethod() public method

public CallMethod ( TargetAddress method, long arg1, long arg2 ) : CommandResult
method TargetAddress
arg1 long
arg2 long
return CommandResult

CallMethod() public method

public CallMethod ( TargetAddress method, long arg1, long arg2, long arg3, string string_argument ) : CommandResult
method TargetAddress
arg1 long
arg2 long
arg3 long
string_argument string
return CommandResult

CheckTrampoline() protected method

protected CheckTrampoline ( Instruction instruction, TrampolineHandler handler ) : bool
instruction Mono.Debugger.Architectures.Instruction
handler TrampolineHandler
return bool

Detach() public method

public Detach ( ) : void
return void

DisassembleInstruction() public method

public DisassembleInstruction ( Method method, TargetAddress address ) : AssemblerLine
method Method
address TargetAddress
return AssemblerLine

DisassembleMethod() public method

public DisassembleMethod ( Method method ) : AssemblerMethod
method Method
return AssemblerMethod

DoAbortInvocation() protected method

protected DoAbortInvocation ( long rti_id ) : void
rti_id long
return void

DoDetach() protected method

protected DoDetach ( ) : void
return void

DoDispose() protected method

protected DoDispose ( ) : void
return void

DoProcessEvent() protected method

protected DoProcessEvent ( Inferior cevent ) : void
cevent Inferior
return void

ExecuteOperation() protected method

protected ExecuteOperation ( System.Operation operation ) : void
operation System.Operation
return void

GetBacktrace() public method

public GetBacktrace ( Backtrace mode, int max_frames ) : Backtrace
mode Backtrace
max_frames int
return Backtrace

GetInstructionSize() public method

public GetInstructionSize ( TargetAddress address ) : int
address TargetAddress
return int

GetMemoryMaps() public method

public GetMemoryMaps ( ) : TargetMemoryArea[]
return TargetMemoryArea[]

GetRegisters() public method

public GetRegisters ( ) : Registers
return Registers

Kill() public method

public Kill ( ) : void
return void

Lookup() public method

public Lookup ( TargetAddress address ) : Method
address TargetAddress
return Method

ManagedCallback() public method

public ManagedCallback ( ManagedCallbackFunction func, CommandResult result ) : bool
func ManagedCallbackFunction
result CommandResult
return bool

MethodHasSource() protected method

protected MethodHasSource ( Method method ) : bool
method Method
return bool

OperationCompleted() protected method

protected OperationCompleted ( TargetEventArgs args ) : void
args TargetEventArgs
return void

OperationCompleted() protected method

protected OperationCompleted ( TargetEventArgs args, bool suspended ) : void
args TargetEventArgs
suspended bool
return void

OperationInterrupted() protected method

protected OperationInterrupted ( ) : void
return void

PrintObject() public method

public PrintObject ( Style style, TargetObject obj, DisplayFormat format ) : string
style Style
obj Mono.Debugger.Languages.TargetObject
format DisplayFormat
return string

PrintType() public method

public PrintType ( Style style, TargetType type ) : string
style Style
type Mono.Debugger.Languages.TargetType
return string

ProcessEvent() public method

public ProcessEvent ( Inferior cevent ) : bool
cevent Inferior
return bool

ProcessEvent() public method

This is called from the SingleSteppingEngine's main event loop to give us the next event - `status' has no meaning to us, it's just meant to be passed to inferior.ProcessEvent() to get the actual event.
Actually, `status' is the waitpid() status code. In Linux 2.6.x, you can call waitpid() from any thread in the debugger, but we need to get the target's registers to find out whether it's a breakpoint etc. That's done in inferior.ProcessEvent() - which must always be called from the engine's thread.
public ProcessEvent ( int status ) : void
status int
return void

ProcessOperationEvent() protected method

protected ProcessOperationEvent ( Inferior cevent ) : void
cevent Inferior
return void

PushOperation() protected method

protected PushOperation ( System.Operation operation ) : void
operation System.Operation
return void

PushOperationNoExec() protected method

protected PushOperationNoExec ( System.Operation operation ) : void
operation System.Operation
return void

ReadAddress() public method

public ReadAddress ( TargetAddress address ) : TargetAddress
address TargetAddress
return TargetAddress

ReadBuffer() public method

public ReadBuffer ( TargetAddress address, int size ) : byte[]
address TargetAddress
size int
return byte[]

ReadByte() public method

public ReadByte ( TargetAddress address ) : byte
address TargetAddress
return byte

ReadInteger() public method

public ReadInteger ( TargetAddress address ) : int
address TargetAddress
return int

ReadLongInteger() public method

public ReadLongInteger ( TargetAddress address ) : long
address TargetAddress
return long

ReadMemory() public method

public ReadMemory ( TargetAddress address, int size ) : TargetBlob
address TargetAddress
size int
return TargetBlob

ReadString() public method

public ReadString ( TargetAddress address ) : string
address TargetAddress
return string

Return() public method

public Return ( ReturnMode mode ) : CommandResult
mode ReturnMode
return CommandResult

RuntimeInvoke() public method

public RuntimeInvoke ( TargetFunctionType function, TargetStructObject object_argument, TargetObject param_objects, RuntimeInvokeFlags flags, RuntimeInvokeResult result ) : void
function Mono.Debugger.Languages.TargetFunctionType
object_argument Mono.Debugger.Languages.TargetStructObject
param_objects Mono.Debugger.Languages.TargetObject
flags RuntimeInvokeFlags
result RuntimeInvokeResult
return void

SetKilledFlag() public method

public SetKilledFlag ( ) : void
return void

SetRegisters() public method

public SetRegisters ( Registers registers ) : void
registers Registers
return void

SimpleLookup() public method

public SimpleLookup ( TargetAddress address, bool exact_match ) : Symbol
address TargetAddress
exact_match bool
return Symbol

SingleSteppingEngine() protected method

protected SingleSteppingEngine ( ThreadManager manager, Process process ) : System
manager ThreadManager
process System.Diagnostics.Process
return System

SingleSteppingEngine() public method

public SingleSteppingEngine ( ThreadManager manager, Process process, Inferior inferior, int pid ) : System
manager ThreadManager
process System.Diagnostics.Process
inferior Inferior
pid int
return System

SingleSteppingEngine() public method

public SingleSteppingEngine ( ThreadManager manager, Process process, ProcessStart start ) : System
manager ThreadManager
process System.Diagnostics.Process
start ProcessStart
return System

StartApplication() public method

public StartApplication ( CommandResult result ) : CommandResult
result CommandResult
return CommandResult

StartExecedChild() public method

public StartExecedChild ( CommandResult result ) : CommandResult
result CommandResult
return CommandResult

StartForkedChild() public method

public StartForkedChild ( CommandResult result ) : CommandResult
result CommandResult
return CommandResult

StartOperation() protected method

Start a new stepping operation. All stepping operations are done asynchronously. The inferior basically just knows two kinds of stepping operations: there is do_continue() to continue execution (until a breakpoint is hit or the target receives a signal or exits) and there is do_step_native() to single-step one machine instruction. There's also a version of do_continue() which takes an address - it inserts a temporary breakpoint on that address and calls do_continue(). Let's call these "atomic operations" while a "stepping operation" is something like stepping until the next source line. We normally need to do several atomic operations for each stepping operation. We start a new stepping operation here, but what we actually do is starting an atomic operation on the target. Note that we just start it, but don't wait until is completed. Once the target is running, we go back to the main event loop and wait for it (or another thread) to stop (or to get another command from the user).
protected StartOperation ( ) : void
return void

StartSuspended() public method

public StartSuspended ( ) : void
return void

StartThread() public method

public StartThread ( CommandResult result ) : CommandResult
result CommandResult
return CommandResult

Step() public method

public Step ( ThreadingModel model, StepMode mode, StepFrame frame ) : CommandResult
model ThreadingModel
mode StepMode
frame StepFrame
return CommandResult

Stop() public method

public Stop ( ) : void
return void

ToString() public method

public ToString ( ) : string
return string

WriteAddress() public method

public WriteAddress ( TargetAddress address, TargetAddress value ) : void
address TargetAddress
value TargetAddress
return void

WriteBuffer() public method

public WriteBuffer ( TargetAddress address, byte buffer ) : void
address TargetAddress
buffer byte
return void

WriteByte() public method

public WriteByte ( TargetAddress address, byte value ) : void
address TargetAddress
value byte
return void

WriteInteger() public method

public WriteInteger ( TargetAddress address, int value ) : void
address TargetAddress
value int
return void

WriteLongInteger() public method

public WriteLongInteger ( TargetAddress address, long value ) : void
address TargetAddress
value long
return void

check_inferior() protected method

protected check_inferior ( ) : void
return void

disable_extended_notification() protected method

protected disable_extended_notification ( NotificationType type ) : void
type NotificationType
return void

do_continue() protected method

Resume the target.
protected do_continue ( ) : void
return void

do_continue() protected method

protected do_continue ( TargetAddress until ) : void
until TargetAddress
return void

do_next() protected method

Step over the next machine instruction.
protected do_next ( ) : void
return void

do_step() protected method

protected do_step ( ) : void
return void

do_step_native() protected method

protected do_step_native ( ) : void
return void

enable_extended_notification() protected method

protected enable_extended_notification ( NotificationType type ) : void
type NotificationType
return void

enforce_managed_context() protected method

protected enforce_managed_context ( ) : void
return void

frames_invalid() protected method

protected frames_invalid ( ) : void
return void

insert_lmf_breakpoint() protected method

protected insert_lmf_breakpoint ( TargetAddress lmf_address ) : void
lmf_address TargetAddress
return void

insert_temporary_breakpoint() protected method

protected insert_temporary_breakpoint ( TargetAddress address ) : void
address TargetAddress
return void

remove_lmf_breakpoint() protected method

protected remove_lmf_breakpoint ( ) : void
return void

remove_temporary_breakpoint() protected method

protected remove_temporary_breakpoint ( ) : void
return void

request_managed_callback() protected method

protected request_managed_callback ( ManagedCallbackData data ) : void
data ManagedCallbackData
return void

restore_stack() protected method

protected restore_stack ( StackData stack ) : void
stack StackData
return void

set_registers() protected method

protected set_registers ( Registers registers ) : void
registers Registers
return void

update_current_frame() protected method

protected update_current_frame ( StackFrame new_frame ) : void
new_frame System.Diagnostics.StackFrame
return void

Property Details

current_backtrace protected_oe property

protected Backtrace current_backtrace
return Backtrace

current_frame protected_oe property

protected StackFrame,System.Diagnostics current_frame
return System.Diagnostics.StackFrame

current_method protected_oe property

protected Method current_method
return Method

registers protected_oe property

protected Registers registers
return Registers