123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- //===========================================================================//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- //***************************************************************************
- //
- // ABLDBUG.H
- //
- //***************************************************************************
-
- #ifndef ABLDBUG_H
- #define ABLDBUG_H
- #ifndef DABLDBUG_H
- #include "dabldbug.h"
- #endif
- #ifndef ABLENV_H
- #include "ablenv.h"
- #endif
- //***************************************************************************
- typedef enum {
- DEBUG_COMMAND_SET_MODULE,
- DEBUG_COMMAND_TRACE,
- DEBUG_COMMAND_STEP,
- DEBUG_COMMAND_BREAKPOINT_SET,
- DEBUG_COMMAND_BREAKPOINT_REMOVE,
- DEBUG_COMMAND_WATCH_SET,
- DEBUG_COMMAND_WATCH_REMOVE_ALL,
- DEBUG_COMMAND_PRINT,
- DEBUG_COMMAND_CONTINUE,
- DEBUG_COMMAND_HELP,
- DEBUG_COMMAND_INFO,
- NUM_DEBUG_COMMANDS
- } DebugCommandCode;
- //***************************************************************************
- typedef struct _Watch {
- SymTableNodePtr idPtr;
- bool store;
- bool breakOnStore;
- bool fetch;
- bool breakOnFetch;
- } Watch;
- typedef Watch* WatchPtr;
- class WatchManager {
- protected:
- long maxWatches;
- long numWatches;
- WatchPtr watches;
- public:
- void* operator new (size_t mySize);
- void operator delete (void* us);
- void init (void) {
- maxWatches = 0;
- maxWatches = 0;
- watches = NULL;
- }
- long init (long max);
- void destroy (void);
- WatchManager (void) {
- init();
- }
- ~WatchManager (void) {
- destroy();
- }
- WatchPtr add (SymTableNodePtr idPtr);
- long remove (SymTableNodePtr idPtr);
- long removeAll (void);
-
- long setStore (SymTableNodePtr idPtr, bool state, bool breakToDebug = false);
-
- long setFetch (SymTableNodePtr idPtr, bool state, bool breakToDebug = false);
- bool getStore (SymTableNodePtr idPtr);
- bool getFetch (SymTableNodePtr idPtr);
- void print (void);
- };
- //---------------------------------------------------------------------------
- class BreakPointManager {
- protected:
- long maxBreakPoints;
- long numBreakPoints;
- long* breakPoints;
- public:
- void* operator new (size_t mySize);
- void operator delete (void* us);
- void init (void) {
- maxBreakPoints = 0;
- numBreakPoints = 0;
- breakPoints = NULL;
- }
- long init (long max);
- void destroy (void);
- BreakPointManager (void) {
- init();
- }
- ~BreakPointManager (void) {
- destroy();
- }
- long add (long lineNumber);
- long remove (long lineNumber);
- long removeAll (void);
- bool isBreakPoint (long lineNumber);
- void print (void);
- };
- //---------------------------------------------------------------------------
- #define WATCH_STORE_OFF 1
- #define WATCH_STORE_ON 2
- #define WATCH_FETCH_OFF 4
- #define WATCH_FETCH_ON 8
- #define WATCH_BREAK 16
- class Debugger {
- protected:
- ABLModulePtr module; // Current executing module
- WatchManagerPtr watchManager; // Current executing watch manager
- BreakPointManagerPtr breakPointManager; // Current executing breakpt manager
- ABLModulePtr debugModule; // Current module being debugged
- bool enabled;
- bool debugCommand;
- bool halt;
- bool trace;
- bool step;
- bool traceEntry;
- bool traceExit;
- static char message[512];
- void (*printCallback)(char* s);
- public:
- void* operator new (size_t mySize);
- void operator delete (void* us);
- void init (void) {
- module = NULL;
- watchManager = NULL;
- breakPointManager = NULL;
- debugModule = module;
- enabled = false;
- debugCommand = false;
- halt = false;
- trace = false;
- step = false;
- traceEntry = false;
- traceExit = false;
- printCallback = NULL;
- }
- long init (void (*callback)(char* s), ABLModulePtr _module);
- void destroy (void);
- Debugger (void) {
- init();
- }
- ~Debugger (void) {
- destroy();
- }
- void enable (void) {
- enabled = true;
- }
- void disable (void) {
- enabled = false;
- }
- bool isEnabled (void) {
- return(enabled);
- }
- long print (char* s);
- void setModule (ABLModulePtr _module);
- long setWatch (long states);
- long addBreakPoint (void);
- long removeBreakPoint (void);
- void sprintStatement (char* dest);
- void sprintLineNumber (char* dest);
- void sprintDataValue (char* dest, StackItemPtr data, TypePtr dataType);
- long sprintSimpleValue (char* dest, SymTableNodePtr symbol);
- long sprintArrayValue (char* dest, SymTableNodePtr symbol, char* subscriptString);
- long sprintValue (char* dest, char* exprString);
- long traceStatementExecution (void);
- long traceRoutineEntry (SymTableNodePtr idPtr);
- long traceRoutineExit (SymTableNodePtr idPtr);
- long traceDataStore (SymTableNodePtr id, TypePtr idType, StackItemPtr target, TypePtr targetType);
- long traceDataFetch (SymTableNodePtr id, TypePtr idType, StackItemPtr data);
- void showValue (void);
- void assignVariable (void);
- void displayModuleInstanceRegistry (void);
- void processCommand (long commandId, char* strParam1, long numParam1, ABLModulePtr moduleParam1);
- void debugMode (void);
- ABLModulePtr getDebugModule (void) {
- return(debugModule);
- }
- };
- //***************************************************************************
- #endif
|