| 1 |
/* |
/** |
| 2 |
* procframe.h: Method interpreter debugger stack frame information. |
* procframe.h: Method interpreter debugger stack frame information. |
| 3 |
* by Benjamin Allan |
* by Benjamin Allan |
| 4 |
* March 17, 1998 |
* March 17, 1998 |
| 31 |
|
|
| 32 |
#ifndef __PROCFRAME_H_SEEN__ |
#ifndef __PROCFRAME_H_SEEN__ |
| 33 |
#define __PROCFRAME_H_SEEN__ |
#define __PROCFRAME_H_SEEN__ |
| 34 |
/* Method interpreter debugger stack frame information. |
/** Method interpreter debugger stack frame information. |
| 35 |
* The data structures in this header should not be passed |
* The data structures in this header should not be passed |
| 36 |
* through headers except inside gl_lists. This header |
* through headers except inside gl_lists. This header |
| 37 |
* should not be accessed except by the interpreter and |
* should not be accessed except by the interpreter and |
| 40 |
*/ |
*/ |
| 41 |
|
|
| 42 |
enum FrameMode { |
enum FrameMode { |
| 43 |
FrameInherit, /* inherit previous mode when used in Add */ |
FrameInherit, /** inherit previous mode when used in Add */ |
| 44 |
FrameNormal, /* normal operations. inheritable. */ |
FrameNormal, /** normal operations. inheritable. */ |
| 45 |
FrameDebug, /* trace operations. inheritable. */ |
FrameDebug, /** trace operations. inheritable. */ |
| 46 |
FrameStart, /* not yet supported. initiate something. */ |
FrameStart, /** not yet supported. initiate something. */ |
| 47 |
FrameStep, /* not yet supported. do next statement any scope */ |
FrameStep, /** not yet supported. do next statement any scope */ |
| 48 |
FrameNext, /* not yet supported. do next instruction this scope */ |
FrameNext, /** not yet supported. do next instruction this scope */ |
| 49 |
FrameDestroyed /* severe error if seen */ |
FrameDestroyed /** severe error if seen */ |
| 50 |
}; |
}; |
| 51 |
|
|
| 52 |
/* Because error handling is user defined according to watchpt.h |
/** Because error handling is user defined according to watchpt.h |
| 53 |
* the following enum is used internally. |
* the following enum is used internally. |
| 54 |
* External package functions |
* External package functions |
| 55 |
* should return Proc_CallOK, Proc_CallError, |
* should return Proc_CallOK, Proc_CallError, |
| 57 |
* Error message output is affected by FrameControl. |
* Error message output is affected by FrameControl. |
| 58 |
*/ |
*/ |
| 59 |
enum FrameControl { |
enum FrameControl { |
| 60 |
FrameOK = 0, /* normal return and entry state. */ |
FrameOK = 0, /** normal return and entry state. */ |
| 61 |
FrameError, /* error return. only the erroneous frame uses this. */ |
FrameError, /** error return. only the erroneous frame uses this. */ |
| 62 |
FrameBreak, /* break from an enclosing loop. If no enclosing loop |
FrameBreak, /** break from an enclosing loop. If no enclosing loop |
| 63 |
* exists, will be passed up to calling frame. */ |
* exists, will be passed up to calling frame. */ |
| 64 |
FrameContinue,/* skip to next iteration in an enclosing loop. If no |
FrameContinue,/** skip to next iteration in an enclosing loop. If no |
| 65 |
* enclosing loop exists, will be passed up to calling frame.*/ |
* enclosing loop exists, will be passed up to calling frame.*/ |
| 66 |
FrameFallthru,/* suppress break inside switch processing of cases */ |
FrameFallthru,/** suppress break inside switch processing of cases */ |
| 67 |
FrameReturn, /* frames above a FrameError or FrameReturn stop & return */ |
FrameReturn, /** frames above a FrameError or FrameReturn stop & return */ |
| 68 |
/* Initialize morphs this back to a FrameError for client. */ |
/** Initialize morphs this back to a FrameError for client. */ |
| 69 |
FrameLoop /* in the scope of a loop. valid entry state. */ |
FrameLoop /** in the scope of a loop. valid entry state. */ |
| 70 |
}; |
}; |
| 71 |
/* keep the above in sync with the internals of FrameControlToString below */ |
/** keep the above in sync with the internals of FrameControlToString below */ |
| 72 |
|
|
| 73 |
|
|
| 74 |
/* |
/** |
| 75 |
* some watch point structures for internal use only. |
* some watch point structures for internal use only. |
| 76 |
* see watchpt.h for UI watchpoint input structures. |
* see watchpt.h for UI watchpoint input structures. |
| 77 |
*/ |
*/ |
| 78 |
struct anywatch { |
struct anywatch { |
| 79 |
void *key; /* all watches hash on some sort of unique ptr key */ |
void *key; /** all watches hash on some sort of unique ptr key */ |
| 80 |
void *next; /* all watches are in hash tables. */ |
void *next; /** all watches are in hash tables. */ |
| 81 |
void *data; /* everyone wants to know something. */ |
void *data; /** everyone wants to know something. */ |
| 82 |
unsigned long flags; /* control bits */ |
unsigned long flags; /** control bits */ |
| 83 |
}; |
}; |
| 84 |
|
|
| 85 |
struct namewatch { |
struct namewatch { |
| 86 |
symchar *leafname; |
symchar *leafname; |
| 87 |
struct namewatch *next; |
struct namewatch *next; |
| 88 |
struct gl_list_t *where; |
struct gl_list_t *where; |
| 89 |
unsigned long flags; /* control bits */ |
unsigned long flags; /** control bits */ |
| 90 |
}; |
}; |
| 91 |
|
|
| 92 |
struct procwatch { |
struct procwatch { |
| 93 |
symchar *leafname; |
symchar *leafname; |
| 94 |
struct procwatch *next; |
struct procwatch *next; |
| 95 |
struct gl_list_t *where; |
struct gl_list_t *where; |
| 96 |
unsigned long flags; /* control bits */ |
unsigned long flags; /** control bits */ |
| 97 |
}; |
}; |
| 98 |
|
|
| 99 |
struct statwatch { |
struct statwatch { |
| 100 |
struct Statement *stat; |
struct Statement *stat; |
| 101 |
struct statwatch *next; |
struct statwatch *next; |
| 102 |
struct gl_list_t *where; |
struct gl_list_t *where; |
| 103 |
unsigned long flags; /* control bits */ |
unsigned long flags; /** control bits */ |
| 104 |
}; |
}; |
| 105 |
|
|
| 106 |
struct varswatch { |
struct varswatch { |
| 107 |
struct Instance *var; /* watched var */ |
struct Instance *var; /** watched var */ |
| 108 |
struct varswatch *next; |
struct varswatch *next; |
| 109 |
struct gl_list_t *where; /* list of statement/context pairs */ |
struct gl_list_t *where; /** list of statement/context pairs */ |
| 110 |
unsigned long flags; /* control bits */ |
unsigned long flags; /** control bits */ |
| 111 |
}; |
}; |
| 112 |
|
|
| 113 |
struct typewatch { |
struct typewatch { |
| 114 |
struct TypeDescription *desc; /* watched var type */ |
struct TypeDescription *desc; /** watched var type */ |
| 115 |
struct typewatch *next; |
struct typewatch *next; |
| 116 |
struct TypeDescription *ancestor; /* watched ancestor causing this */ |
struct TypeDescription *ancestor; /** watched ancestor causing this */ |
| 117 |
unsigned long flags; /* control bits */ |
unsigned long flags; /** control bits */ |
| 118 |
}; |
}; |
| 119 |
|
|
| 120 |
/* Masks are always = 2^N -1 for some N. Such a mask |
/** Masks are always = 2^N -1 for some N. Such a mask |
| 121 |
* can be used in hashing a pointer into an array of size 2^N. |
* can be used in hashing a pointer into an array of size 2^N. |
| 122 |
* N should be even. |
* N should be even. |
| 123 |
* Until we run tests, hard to say what the masks should be. |
* Until we run tests, hard to say what the masks should be. |
| 138 |
#define SWTSHIFT 22 |
#define SWTSHIFT 22 |
| 139 |
#define TWTSHIFT 22 |
#define TWTSHIFT 22 |
| 140 |
#define VWTSHIFT 22 |
#define VWTSHIFT 22 |
| 141 |
/* The idea here is that pointers (to persistent instances, names, types |
/** The idea here is that pointers (to persistent instances, names, types |
| 142 |
* and methods, but not stack instances) are unique keys during method |
* and methods, but not stack instances) are unique keys during method |
| 143 |
* execution, so these can be hashed for more or less linear cost trace |
* execution, so these can be hashed for more or less linear cost trace |
| 144 |
* operations. We're hashing things because it's really gross to use |
* operations. We're hashing things because it's really gross to use |
| 153 |
|
|
| 154 |
struct procDebug { |
struct procDebug { |
| 155 |
wpflags what; |
wpflags what; |
| 156 |
/* what tells what tables are active. check it, not the table ptrs */ |
/** what tells what tables are active. check it, not the table ptrs */ |
| 157 |
FILE *log; /* where debugger output should go. probably same as err */ |
FILE *log; /** where debugger output should go. probably same as err */ |
| 158 |
int errcnt; /* total error messages issued while processing this stack */ |
int errcnt; /** total error messages issued while processing this stack */ |
| 159 |
struct namewatch **ntab; /* hash table of leaf names being watched */ |
struct namewatch **ntab; /** hash table of leaf names being watched */ |
| 160 |
struct procwatch **ptab; /* hash table of proc names being watched */ |
struct procwatch **ptab; /** hash table of proc names being watched */ |
| 161 |
struct statwatch **stab; /* hash table of statements being watched */ |
struct statwatch **stab; /** hash table of statements being watched */ |
| 162 |
struct typewatch **ttab; /* hash table of var types being watched */ |
struct typewatch **ttab; /** hash table of var types being watched */ |
| 163 |
struct varswatch **vtab; /* hash table of variables being watched */ |
struct varswatch **vtab; /** hash table of variables being watched */ |
| 164 |
/* above watch tables point at below data spaces unless no break points |
/** above watch tables point at below data spaces unless no break points |
| 165 |
* of the classes involved are set. If a table is not used, its tab |
* of the classes involved are set. If a table is not used, its tab |
| 166 |
* pointer is left NULL instead of being assigned to its head. |
* pointer is left NULL instead of being assigned to its head. |
| 167 |
*/ |
*/ |
| 172 |
struct varswatch *varshead[VWTMASK+1]; |
struct varswatch *varshead[VWTMASK+1]; |
| 173 |
}; |
}; |
| 174 |
|
|
| 175 |
/* |
/** |
| 176 |
* a procFrame defines the stack information we may carry about while |
* a procFrame defines the stack information we may carry about while |
| 177 |
* executing a method call from the interface. It is for the |
* executing a method call from the interface. It is for the |
| 178 |
* internal use of initialize.c only. |
* internal use of initialize.c only. |
| 179 |
*/ |
*/ |
| 180 |
struct procFrame { |
struct procFrame { |
| 181 |
enum FrameMode m; /* 0 -> no -> rest of frame data empty */ |
enum FrameMode m; /** 0 -> no -> rest of frame data empty */ |
| 182 |
enum FrameControl flow; /* flow of control info */ |
enum FrameControl flow; /** flow of control info */ |
| 183 |
enum Proc_enum ErrNo; /* last status computed */ |
enum Proc_enum ErrNo; /** last status computed */ |
| 184 |
int depth; /* where on the stack. redundant. */ |
int depth; /** where on the stack. redundant. */ |
| 185 |
FILE *err; /* where interactive messages should be sent */ |
FILE *err; /** where interactive messages should be sent */ |
| 186 |
struct Instance *i; /* scope proc is being executed in. */ |
struct Instance *i; /** scope proc is being executed in. */ |
| 187 |
char *cname; /* name of scope by which we got here. */ |
char *cname; /** name of scope by which we got here. */ |
| 188 |
struct InitProcedure *proc; /* proc being evaluated. */ |
struct InitProcedure *proc; /** proc being evaluated. */ |
| 189 |
struct Statement *stat; /* statement being evaluated. */ |
struct Statement *stat; /** statement being evaluated. */ |
| 190 |
struct procFrame *caller; /* scope that lead here in execution. |
struct procFrame *caller; /** scope that lead here in execution. |
| 191 |
* NULL if caller was a user interface. |
* NULL if caller was a user interface. |
| 192 |
*/ |
*/ |
| 193 |
wpflags gen; /* some general debug options valid |
wpflags gen; /** some general debug options valid |
| 194 |
* whether or not dbi == NULL. |
* whether or not dbi == NULL. |
| 195 |
*/ |
*/ |
| 196 |
struct procDebug *dbi; /* points to debugging information which |
struct procDebug *dbi; /** points to debugging information which |
| 197 |
* is shared by all frames in a stack since |
* is shared by all frames in a stack since |
| 198 |
* debugging is a global activity. |
* debugging is a global activity. |
| 199 |
* The root frame should create this data. |
* The root frame should create this data. |
| 200 |
* If NULL, no messaging at all. |
* If NULL, no messaging at all. |
| 201 |
*/ |
*/ |
| 202 |
/* not yet supported: */ |
/** not yet supported: */ |
| 203 |
struct gl_list_t *locals; /* local vars simulation list. */ |
struct gl_list_t *locals; /** local vars simulation list. */ |
| 204 |
}; |
}; |
| 205 |
|
|
| 206 |
/* setting this to 1 causes a STOP at the next sensible moment */ |
/** setting this to 1 causes a STOP at the next sensible moment */ |
| 207 |
/* UIs access this variable through watchpt.h only. */ |
/** UIs access this variable through watchpt.h only. */ |
| 208 |
extern int g_procframe_stop; |
extern int g_procframe_stop; |
| 209 |
|
|
| 210 |
/* return a string (not caller's to free) form of the enum given */ |
/** return a string (not caller's to free) form of the enum given */ |
| 211 |
extern char *FrameControlToString(enum FrameControl); |
extern char *FrameControlToString(enum FrameControl); |
| 212 |
/* |
/** |
| 213 |
* Doing anything more than output during execution probably calls for |
* Doing anything more than output during execution probably calls for |
| 214 |
* a real debugging thread or a most careful inside-out method |
* a real debugging thread or a most careful inside-out method |
| 215 |
* execution protocol. |
* execution protocol. |
| 216 |
*/ |
*/ |
| 217 |
|
|
| 218 |
/* init a top procFrame for normal execution with no debugging. */ |
/** init a top procFrame for normal execution with no debugging. */ |
| 219 |
extern void InitNormalTopProcFrame(struct procFrame *, struct Instance *, |
extern void InitNormalTopProcFrame(struct procFrame *, struct Instance *, |
| 220 |
char *, FILE *,int); |
char *, FILE *,int); |
| 221 |
|
|
| 222 |
/* init a top procFrame for debugging execution. */ |
/** init a top procFrame for debugging execution. */ |
| 223 |
extern void InitDebugTopProcFrame(struct procFrame *, struct Instance *, |
extern void InitDebugTopProcFrame(struct procFrame *, struct Instance *, |
| 224 |
char *, FILE *, int, |
char *, FILE *, int, |
| 225 |
struct procDebug *, struct gl_list_t *, |
struct procDebug *, struct gl_list_t *, |
| 226 |
FILE *); |
FILE *); |
| 227 |
|
|
| 228 |
/* add a frame */ |
/** add a frame */ |
| 229 |
/* |
/** |
| 230 |
* Create a frame for a stack. parent should be the |
* Create a frame for a stack. parent should be the |
| 231 |
* containing frame unless this is the first frame in a |
* containing frame unless this is the first frame in a |
| 232 |
* stack. Context is the instance statements are supposed |
* stack. Context is the instance statements are supposed |
| 241 |
char *, struct InitProcedure *, |
char *, struct InitProcedure *, |
| 242 |
enum FrameMode); |
enum FrameMode); |
| 243 |
|
|
| 244 |
/* update context info in a frame */ |
/** update context info in a frame */ |
| 245 |
/* set the statement for the given frame. statement had best be somewhere |
/** set the statement for the given frame. statement had best be somewhere |
| 246 |
* in the proc list of the frame. i had better be the context the |
* in the proc list of the frame. i had better be the context the |
| 247 |
* statement is to be evaluated in if it is evaluated. |
* statement is to be evaluated in if it is evaluated. |
| 248 |
*/ |
*/ |
| 250 |
struct Statement *, |
struct Statement *, |
| 251 |
struct Instance *); |
struct Instance *); |
| 252 |
|
|
| 253 |
/* iffy */ |
/** iffy */ |
| 254 |
extern void DestroyProcFrame(struct procFrame *); |
extern void DestroyProcFrame(struct procFrame *); |
| 255 |
|
|
| 256 |
|
|
| 257 |
#endif /* __PROCFRAME_H_SEEN__ */ |
#endif /** __PROCFRAME_H_SEEN__ */ |