Qore Programming Language Reference Manual 1.14.0
Loading...
Searching...
No Matches
Qore::DebugProgram Class Referenceabstract

DebugProgram class supports Qore Program debugging via ProgramControl. More...

#include <QC_DebugProgram.dox.h>

Public Member Methods

nothing addProgram (ProgramControl pgm)
 Add program to debugging.
 
int breakProgram (ProgramControl pgm)
 Break program, i.e. all threads.
 
int breakProgramThread (ProgramControl pgm, int tid)
 Break particular program thread.
 
 constructor ()
 Creates the debug program object with notification functions without any functionality.
 
 copy ()
 Throws an exception to prevent objects of this class from being copied. More...
 
 destructor ()
 Waits for all threads to finish executing, then deletes all global variables, dereferences the internal Program object and deletes the Qore object.
 
list getAllPrograms ()
 Get all programs being debugged.
 
int getInterruptedCount ()
 Get number of interrupted threads.
 
abstract onAttach (ProgramControl pgm, reference rs, reference rtsid)
 Executed when new thread is attached to program being debugged.
 
abstract onDetach (ProgramControl pgm, reference rs, reference rtsid)
 Executed when thread is datached from program being debugged.
 
abstract onException (ProgramControl pgm, int statement, hash ex, reference dismiss, reference rs, reference rtsid)
 Executed when an exception is raised. More...
 
abstract onExit (ProgramControl pgm, int statement, reference returnValue, reference rs, reference rtsid)
 Executed when a program/thread is exited. More...
 
abstract onFunctionEnter (ProgramControl pgm, int statement, reference rs, reference rtsid)
 Executed when a function is entered. More...
 
abstract onFunctionExit (ProgramControl pgm, int statement, reference returnValue, reference rs, reference rtsid)
 Executed when a function is exited. More...
 
abstract onStep (ProgramControl pgm, int blockStatement, *int statement, *int breakpointId, reference flow, reference rs, reference rtsid)
 Executed when step is performed.
 
nothing removeProgram (ProgramControl pgm)
 Remove program from debugging.
 
nothing waitForTerminationAndClear ()
 Clear all programs and wait for all threads to finish executing callbacks.
 

Detailed Description

DebugProgram class supports Qore Program debugging via ProgramControl.

One instance may be assigned to one or more ProgramControl instances which may run in one or more threads. ProgramControl is added to the debugging list, next the program being debugged notifies the debugger when the next execution event occurs. Calling of notification method is always performed in the program thread. When the program flow is to be interrupted then it happens in the notification method of this class. Then debugger decides to continue and then returns from the notification function and passes Debug Run State Constants value "step option" code back.

The debugger should probably handle control in separate thread.

The DebugProgram class defines the interface and the real functionality should be implemented in a child class.

Restrictions:
MUST HAVE: Qore::PO_ALLOW_DEBUGGER
Example:
const code = "for (int i=0; i<10; i++) {}";
class MyDebugProgram dbg() inherits DebugProgram {
private:
onAttach(ProgramControl pgm, reference rs) {
rs = DebugStep;
}
}
ProgramControl p = ProgramControl::getProgram();
dbg.addProgram(p);
pgm.parse(code);
pgm.saveProgram();
pgm.run();
Since
Qore 0.8.13

Member Function Documentation

◆ copy()

Qore::DebugProgram::copy ( )

Throws an exception to prevent objects of this class from being copied.

Exceptions
DEBUGPROGRAM-COPY-ERRORcopying DebugProgram objects is unsupported

◆ onException()

abstract Qore::DebugProgram::onException ( ProgramControl  pgm,
int  statement,
hash  ex,
reference  dismiss,
reference  rs,
reference  rtsid 
)
pure virtual

Executed when an exception is raised.

See also
ProgramControl::getStatementIdInfo

◆ onExit()

abstract Qore::DebugProgram::onExit ( ProgramControl  pgm,
int  statement,
reference  returnValue,
reference  rs,
reference  rtsid 
)
pure virtual

Executed when a program/thread is exited.

See also
ProgramControl::getStatementIdInfo

◆ onFunctionEnter()

abstract Qore::DebugProgram::onFunctionEnter ( ProgramControl  pgm,
int  statement,
reference  rs,
reference  rtsid 
)
pure virtual

Executed when a function is entered.

See also
ProgramControl::getStatementIdInfo

◆ onFunctionExit()

abstract Qore::DebugProgram::onFunctionExit ( ProgramControl  pgm,
int  statement,
reference  returnValue,
reference  rs,
reference  rtsid 
)
pure virtual

Executed when a function is exited.

See also
ProgramControl::getStatementIdInfo