many changes, delinted
This commit is contained in:
parent
57b1d9824a
commit
b089e0d7f8
18 changed files with 426 additions and 210 deletions
|
@ -56,7 +56,6 @@ CSRC = {
|
||||||
run.c,
|
run.c,
|
||||||
symbol.c,
|
symbol.c,
|
||||||
print.c,
|
print.c,
|
||||||
value.c,
|
|
||||||
type.c,
|
type.c,
|
||||||
rd.c,
|
rd.c,
|
||||||
do_comm.c,
|
do_comm.c,
|
||||||
|
@ -133,7 +132,7 @@ LINTFLAGS = {
|
||||||
|
|
||||||
%cluster {
|
%cluster {
|
||||||
%targets lint.out[type = lint-output];
|
%targets lint.out[type = lint-output];
|
||||||
%sources $CMD_LLSRC + $CSRC + $DBS_LLTARGETS + $HHSRC + char.ct + operators.ot ;
|
%sources $CSRC + $CMD_LLSRC + $DBS_LLTARGETS + $HHSRC + char.ct + operators.ot ;
|
||||||
%use lint(realdest => lint.out) ;
|
%use lint(realdest => lint.out) ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ add_to_avl_tree(tree, n)
|
||||||
struct avl_tree *tree; /* tree to be added to */
|
struct avl_tree *tree; /* tree to be added to */
|
||||||
char *n; /* information */
|
char *n; /* information */
|
||||||
{
|
{
|
||||||
balance_add(&(tree->root), n, tree->cmp);
|
(void) balance_add(&(tree->root), n, tree->cmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* extern char *find_ngt(struct avl_tree *tree, char *n);
|
/* extern char *find_ngt(struct avl_tree *tree, char *n);
|
||||||
|
|
|
@ -27,7 +27,7 @@ static int
|
||||||
print_string(),
|
print_string(),
|
||||||
print_char(),
|
print_char(),
|
||||||
get_number(),
|
get_number(),
|
||||||
get_string(),
|
getstring(),
|
||||||
get_token(),
|
get_token(),
|
||||||
print_op(),
|
print_op(),
|
||||||
unop_prio(),
|
unop_prio(),
|
||||||
|
@ -37,7 +37,7 @@ static int
|
||||||
static long
|
static long
|
||||||
array_elsize();
|
array_elsize();
|
||||||
|
|
||||||
static struct langdep c = {
|
static struct langdep c_lang = {
|
||||||
0,
|
0,
|
||||||
|
|
||||||
"%ld",
|
"%ld",
|
||||||
|
@ -59,7 +59,7 @@ static struct langdep c = {
|
||||||
array_elsize,
|
array_elsize,
|
||||||
binop_prio,
|
binop_prio,
|
||||||
unop_prio,
|
unop_prio,
|
||||||
get_string,
|
getstring,
|
||||||
get_name,
|
get_name,
|
||||||
get_number,
|
get_number,
|
||||||
get_token,
|
get_token,
|
||||||
|
@ -67,9 +67,9 @@ static struct langdep c = {
|
||||||
fix_bin_to_pref
|
fix_bin_to_pref
|
||||||
};
|
};
|
||||||
|
|
||||||
struct langdep *c_dep = &c;
|
struct langdep *c_dep = &c_lang;
|
||||||
|
|
||||||
static int
|
static void
|
||||||
printchar(f, c, esc)
|
printchar(f, c, esc)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int c;
|
int c;
|
||||||
|
@ -104,7 +104,7 @@ printchar(f, c, esc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static
|
||||||
print_char(c)
|
print_char(c)
|
||||||
int c;
|
int c;
|
||||||
{
|
{
|
||||||
|
@ -113,7 +113,7 @@ print_char(c)
|
||||||
putc('\'', db_out);
|
putc('\'', db_out);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static
|
||||||
print_string(f, s, len)
|
print_string(f, s, len)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char *s;
|
char *s;
|
||||||
|
@ -431,7 +431,7 @@ quoted(ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_string(c)
|
getstring(c)
|
||||||
int c;
|
int c;
|
||||||
{
|
{
|
||||||
register int ch;
|
register int ch;
|
||||||
|
@ -464,7 +464,7 @@ get_string(c)
|
||||||
return STRING;
|
return STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static
|
||||||
print_op(f, p)
|
print_op(f, p)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
p_tree p;
|
p_tree p;
|
||||||
|
@ -588,7 +588,7 @@ print_op(f, p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static
|
||||||
fix_bin_to_pref(p)
|
fix_bin_to_pref(p)
|
||||||
p_tree p;
|
p_tree p;
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,19 +20,22 @@
|
||||||
extern char *Salloc();
|
extern char *Salloc();
|
||||||
extern char *strindex();
|
extern char *strindex();
|
||||||
extern char *strcpy();
|
extern char *strcpy();
|
||||||
|
extern void signal_child();
|
||||||
extern FILE *db_in;
|
extern FILE *db_in;
|
||||||
extern int disable_intr;
|
extern int disable_intr;
|
||||||
extern p_tree run_command, print_command;
|
extern p_tree run_command, print_command;
|
||||||
|
|
||||||
|
struct token tok, aside;
|
||||||
int errorgiven = 0;
|
int errorgiven = 0;
|
||||||
int child_interrupted = 0;
|
int child_interrupted = 0;
|
||||||
int interrupted = 0;
|
int interrupted = 0;
|
||||||
int eof_seen = 0;
|
int eof_seen = 0;
|
||||||
|
|
||||||
|
static int shellescape();
|
||||||
|
|
||||||
static int extended_charset = 0;
|
static int extended_charset = 0;
|
||||||
static int in_expression = 0;
|
static int in_expression = 0;
|
||||||
|
|
||||||
struct token tok, aside;
|
|
||||||
|
|
||||||
#define binprio(op) ((*(currlang->binop_prio))(op))
|
#define binprio(op) ((*(currlang->binop_prio))(op))
|
||||||
#define unprio(op) ((*(currlang->unop_prio))(op))
|
#define unprio(op) ((*(currlang->unop_prio))(op))
|
||||||
}
|
}
|
||||||
|
@ -60,7 +63,7 @@ commands
|
||||||
com = 0;
|
com = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log(com);
|
enterlog(com);
|
||||||
eval(com);
|
eval(com);
|
||||||
if (repeatable(com)) {
|
if (repeatable(com)) {
|
||||||
lastcom = com;
|
lastcom = com;
|
||||||
|
@ -73,7 +76,7 @@ commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (lastcom && ! errorgiven) {
|
} else if (lastcom && ! errorgiven) {
|
||||||
log(lastcom);
|
enterlog(lastcom);
|
||||||
eval(lastcom);
|
eval(lastcom);
|
||||||
}
|
}
|
||||||
if (give_prompt) {
|
if (give_prompt) {
|
||||||
|
@ -101,7 +104,7 @@ command_line(p_tree *p;)
|
||||||
| where_command(p)
|
| where_command(p)
|
||||||
| STATUS { *p = mknode(OP_STATUS); }
|
| STATUS { *p = mknode(OP_STATUS); }
|
||||||
| DUMP { *p = mknode(OP_DUMP); }
|
| DUMP { *p = mknode(OP_DUMP); }
|
||||||
| RESTORE count(p)? { *p = mknode(OP_RESTORE, *p); }
|
| RESTORE opt_num(p) { *p = mknode(OP_RESTORE, *p); }
|
||||||
| delete_command(p)
|
| delete_command(p)
|
||||||
| print_command(p)
|
| print_command(p)
|
||||||
| display_command(p)
|
| display_command(p)
|
||||||
|
@ -111,7 +114,7 @@ command_line(p_tree *p;)
|
||||||
| FIND qualified_name(p){ *p = mknode(OP_FIND, *p); }
|
| FIND qualified_name(p){ *p = mknode(OP_FIND, *p); }
|
||||||
| WHICH qualified_name(p){ *p = mknode(OP_WHICH, *p); }
|
| WHICH qualified_name(p){ *p = mknode(OP_WHICH, *p); }
|
||||||
| able_command(p)
|
| able_command(p)
|
||||||
| '!' { shellescape();
|
| '!' { (void) shellescape();
|
||||||
*p = mknode(OP_SHELL);
|
*p = mknode(OP_SHELL);
|
||||||
}
|
}
|
||||||
| source_command(p)
|
| source_command(p)
|
||||||
|
@ -227,7 +230,7 @@ trace_command(p_tree *p;)
|
||||||
{ p_tree whr = 0, cond = 0, exp = 0; }
|
{ p_tree whr = 0, cond = 0, exp = 0; }
|
||||||
:
|
:
|
||||||
TRACE
|
TRACE
|
||||||
[ ON expression(&exp, 0) ]?
|
[ ON format_expression(&exp) ]?
|
||||||
where(&whr)?
|
where(&whr)?
|
||||||
condition(&cond)? { *p = mknode(OP_TRACE, whr, cond, exp); }
|
condition(&cond)? { *p = mknode(OP_TRACE, whr, cond, exp); }
|
||||||
;
|
;
|
||||||
|
@ -290,7 +293,7 @@ regs_command(p_tree *p;)
|
||||||
|
|
||||||
delete_command(p_tree *p;)
|
delete_command(p_tree *p;)
|
||||||
:
|
:
|
||||||
DELETE count_list(p)? { *p = mknode(OP_DELETE, *p); }
|
DELETE num_list(p)? { *p = mknode(OP_DELETE, *p); }
|
||||||
;
|
;
|
||||||
|
|
||||||
print_command(p_tree *p;)
|
print_command(p_tree *p;)
|
||||||
|
@ -351,14 +354,14 @@ able_command(p_tree *p;)
|
||||||
[ ENABLE { *p = mknode(OP_ENABLE, (p_tree) 0); }
|
[ ENABLE { *p = mknode(OP_ENABLE, (p_tree) 0); }
|
||||||
| DISABLE { *p = mknode(OP_DISABLE, (p_tree) 0); }
|
| DISABLE { *p = mknode(OP_DISABLE, (p_tree) 0); }
|
||||||
]
|
]
|
||||||
count_list(&(*p)->t_args[0])?
|
num_list(&(*p)->t_args[0])?
|
||||||
;
|
;
|
||||||
|
|
||||||
count_list(p_tree *p;)
|
num_list(p_tree *p;)
|
||||||
:
|
:
|
||||||
count(p)
|
num(p)
|
||||||
[ ',' { *p = mknode(OP_LINK, *p, (p_tree) 0); }
|
[ ',' { *p = mknode(OP_LINK, *p, (p_tree) 0); }
|
||||||
count(&(*p)->t_args[1])
|
num(&(*p)->t_args[1])
|
||||||
]*
|
]*
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -481,12 +484,17 @@ count(p_tree *p;)
|
||||||
;
|
;
|
||||||
|
|
||||||
opt_num(p_tree *p;)
|
opt_num(p_tree *p;)
|
||||||
|
:
|
||||||
|
num(p)
|
||||||
|
|
|
||||||
|
{ *p = 0; }
|
||||||
|
;
|
||||||
|
|
||||||
|
num(p_tree *p;)
|
||||||
:
|
:
|
||||||
count(p)
|
count(p)
|
||||||
|
|
|
|
||||||
'-' count(p) { (*p)->t_ival = - (*p)->t_ival; }
|
'-' count(p) { (*p)->t_ival = - (*p)->t_ival; }
|
||||||
|
|
|
||||||
{ *p = 0; }
|
|
||||||
;
|
;
|
||||||
|
|
||||||
qualified_name(p_tree *p;)
|
qualified_name(p_tree *p;)
|
||||||
|
@ -609,7 +617,7 @@ get_name(c)
|
||||||
return id->id_reserved ? id->id_reserved : NAME;
|
return id->id_reserved ? id->id_reserved : NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char * symbol2str();
|
extern char *symbol2str();
|
||||||
|
|
||||||
LLmessage(t)
|
LLmessage(t)
|
||||||
{
|
{
|
||||||
|
@ -630,7 +638,7 @@ LLmessage(t)
|
||||||
errorgiven = 1;
|
errorgiven = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
catch_del()
|
catch_del()
|
||||||
{
|
{
|
||||||
signal(SIGINT, catch_del);
|
signal(SIGINT, catch_del);
|
||||||
|
@ -641,13 +649,13 @@ catch_del()
|
||||||
interrupted = 1;
|
interrupted = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
init_del()
|
init_del()
|
||||||
{
|
{
|
||||||
signal(SIGINT, catch_del);
|
signal(SIGINT, catch_del);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
ctch()
|
ctch()
|
||||||
{
|
{
|
||||||
/* Only for shell escapes ... */
|
/* Only for shell escapes ... */
|
||||||
|
@ -656,7 +664,7 @@ ctch()
|
||||||
|
|
||||||
#define SHBUFSIZ 512
|
#define SHBUFSIZ 512
|
||||||
|
|
||||||
int
|
static int
|
||||||
shellescape()
|
shellescape()
|
||||||
{
|
{
|
||||||
register char *p; /* walks through command */
|
register char *p; /* walks through command */
|
||||||
|
|
|
@ -21,9 +21,7 @@ extern char *strindex();
|
||||||
extern long str2long();
|
extern long str2long();
|
||||||
extern double atof();
|
extern double atof();
|
||||||
|
|
||||||
extern long pointer_size;
|
static char *DbPtr; /* current pointer in db string */
|
||||||
|
|
||||||
static char *DbPtr; /* current pointer in DBX string */
|
|
||||||
static int AllowName; /* set if NAME legal at this point */
|
static int AllowName; /* set if NAME legal at this point */
|
||||||
static long ival;
|
static long ival;
|
||||||
static double fval;
|
static double fval;
|
||||||
|
@ -718,7 +716,7 @@ static unsigned int NAckNames; /* Number of ACK symbol table entries */
|
||||||
static struct outname *EndAckNames; /* &AckNames[NAckNames] */
|
static struct outname *EndAckNames; /* &AckNames[NAckNames] */
|
||||||
|
|
||||||
/* Read the symbol table from file 'f', which is supposed to be an
|
/* Read the symbol table from file 'f', which is supposed to be an
|
||||||
ACK a.out format file. Offer DBX strings to the DBX string parser.
|
ACK a.out format file. Offer db strings to the db string parser.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
DbRead(f)
|
DbRead(f)
|
||||||
|
@ -760,7 +758,7 @@ DbRead(f)
|
||||||
else n->on_mptr = 0;
|
else n->on_mptr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Offer strings to the DBX string parser if they contain a ':'.
|
/* Offer strings to the db string parser if they contain a ':'.
|
||||||
Also offer filename-line number information to add_position_addr().
|
Also offer filename-line number information to add_position_addr().
|
||||||
Here, the order may be important.
|
Here, the order may be important.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,15 +16,16 @@
|
||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "message.h"
|
|
||||||
|
|
||||||
extern FILE *db_out;
|
extern FILE *db_out;
|
||||||
extern t_lineno listline, currline;
|
extern t_lineno listline, currline;
|
||||||
extern int stop_reason;
|
|
||||||
extern int interrupted;
|
extern int interrupted;
|
||||||
|
extern int stack_offset;
|
||||||
|
|
||||||
p_tree print_command;
|
p_tree print_command;
|
||||||
|
|
||||||
|
extern void set_bytes();
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
do_noop(p)
|
do_noop(p)
|
||||||
p_tree p;
|
p_tree p;
|
||||||
|
@ -230,7 +231,6 @@ extern t_addr get_dump();
|
||||||
|
|
||||||
struct dump {
|
struct dump {
|
||||||
char *globals, *stack;
|
char *globals, *stack;
|
||||||
struct message_hdr mglobal, mstack;
|
|
||||||
struct dump *next;
|
struct dump *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ do_dump(p)
|
||||||
error("could not allocate enough memory");
|
error("could not allocate enough memory");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p->t_address = get_dump(&d->mglobal, &d->globals, &d->mstack, &d->stack);
|
p->t_address = get_dump(&d->globals, &d->stack);
|
||||||
if (! p->t_address) {
|
if (! p->t_address) {
|
||||||
free((char *) d);
|
free((char *) d);
|
||||||
return;
|
return;
|
||||||
|
@ -276,7 +276,8 @@ do_restore(p)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! put_dump(&d->mglobal, d->globals, &d->mstack, d->stack)) {
|
if (! put_dump(d->globals, d->stack)) {
|
||||||
|
error("restoring failed");
|
||||||
}
|
}
|
||||||
perform_items();
|
perform_items();
|
||||||
}
|
}
|
||||||
|
@ -468,7 +469,7 @@ setstop(p, kind)
|
||||||
do_stop(p)
|
do_stop(p)
|
||||||
p_tree p;
|
p_tree p;
|
||||||
{
|
{
|
||||||
if (! setstop(p, M_SETBP)) {
|
if (! setstop(p, 1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
add_to_item_list(p);
|
add_to_item_list(p);
|
||||||
|
@ -504,7 +505,7 @@ do_trace(p)
|
||||||
p_tree p;
|
p_tree p;
|
||||||
{
|
{
|
||||||
p->t_address = NO_ADDR;
|
p->t_address = NO_ADDR;
|
||||||
if (! settrace(p, M_SETTRACE)) {
|
if (! settrace(p, 1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
add_to_item_list(p);
|
add_to_item_list(p);
|
||||||
|
@ -520,12 +521,7 @@ able(p, kind)
|
||||||
int kind;
|
int kind;
|
||||||
{
|
{
|
||||||
if (!p) {
|
if (!p) {
|
||||||
if (stop_reason) {
|
able_item(0, kind);
|
||||||
able_item(stop_reason, kind);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
error("no current stopping point");
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch(p->t_oper) {
|
switch(p->t_oper) {
|
||||||
|
@ -585,7 +581,7 @@ do_continue(p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
fprintf(db_out, "Only %d breakpoints skipped\n",
|
fprintf(db_out, "Only %ld breakpoints skipped\n",
|
||||||
p->t_args[0]->t_ival - count);
|
p->t_args[0]->t_ival - count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -598,7 +594,7 @@ do_step(p)
|
||||||
p_tree p;
|
p_tree p;
|
||||||
{
|
{
|
||||||
p = p->t_args[0];
|
p = p->t_args[0];
|
||||||
if (! singlestep(M_SETSS, p ? p->t_ival : 1L)) {
|
if (! singlestep(0, p ? p->t_ival : 1L)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,7 +606,7 @@ do_next(p)
|
||||||
p_tree p;
|
p_tree p;
|
||||||
{
|
{
|
||||||
p = p->t_args[0];
|
p = p->t_args[0];
|
||||||
if (! singlestep(M_SETSSF, p? p->t_ival : 1L)) {
|
if (! singlestep(1, p? p->t_ival : 1L)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,7 +659,7 @@ where_entry(num)
|
||||||
fprintf(db_out, "%s(", sc->sc_definedby->sy_idf->id_text);
|
fprintf(db_out, "%s(", sc->sc_definedby->sy_idf->id_text);
|
||||||
print_params(sc->sc_definedby->sy_type, AB, has_static_link(sc));
|
print_params(sc->sc_definedby->sy_type, AB, has_static_link(sc));
|
||||||
fputs(") ", db_out);
|
fputs(") ", db_out);
|
||||||
print_position(where_PC, 0);
|
(void) print_position(where_PC, 0);
|
||||||
fputs("\n", db_out);
|
fputs("\n", db_out);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -705,21 +701,13 @@ do_where(p)
|
||||||
|
|
||||||
/* implementation of the delete command */
|
/* implementation of the delete command */
|
||||||
|
|
||||||
extern p_tree remove_from_item_list();
|
|
||||||
|
|
||||||
do_delete(p)
|
do_delete(p)
|
||||||
p_tree p;
|
p_tree p;
|
||||||
{
|
{
|
||||||
switch(p->t_oper) {
|
switch(p->t_oper) {
|
||||||
case OP_DELETE:
|
case OP_DELETE:
|
||||||
if (! p->t_args[0]) {
|
if (! p->t_args[0]) {
|
||||||
if (stop_reason) {
|
remove_from_item_list(0);
|
||||||
remove_from_item_list(stop_reason);
|
|
||||||
stop_reason = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
error("no current stopping point");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else do_delete(p->t_args[0]);
|
else do_delete(p->t_args[0]);
|
||||||
break;
|
break;
|
||||||
|
@ -728,20 +716,7 @@ do_delete(p)
|
||||||
do_delete(p->t_args[1]);
|
do_delete(p->t_args[1]);
|
||||||
break;
|
break;
|
||||||
case OP_INTEGER:
|
case OP_INTEGER:
|
||||||
p = remove_from_item_list((int) p->t_ival);
|
remove_from_item_list((int) p->t_ival);
|
||||||
|
|
||||||
if (p) switch(p->t_oper) {
|
|
||||||
case OP_WHEN:
|
|
||||||
case OP_STOP:
|
|
||||||
setstop(p, M_CLRBP);
|
|
||||||
break;
|
|
||||||
case OP_TRACE:
|
|
||||||
settrace(p, M_CLRTRACE);
|
|
||||||
break;
|
|
||||||
case OP_DUMP:
|
|
||||||
free_dump(p);
|
|
||||||
}
|
|
||||||
freenode(p);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
|
@ -939,7 +914,7 @@ do_log(p)
|
||||||
extern int item_count;
|
extern int item_count;
|
||||||
extern int in_wheninvoked;
|
extern int in_wheninvoked;
|
||||||
|
|
||||||
log(p)
|
enterlog(p)
|
||||||
p_tree p;
|
p_tree p;
|
||||||
{
|
{
|
||||||
register p_tree p1;
|
register p_tree p1;
|
||||||
|
@ -952,19 +927,20 @@ log(p)
|
||||||
case OP_DELETE:
|
case OP_DELETE:
|
||||||
case OP_ENABLE:
|
case OP_ENABLE:
|
||||||
case OP_DISABLE:
|
case OP_DISABLE:
|
||||||
|
case OP_RESTORE:
|
||||||
/* Change absolute item numbers into relative ones
|
/* Change absolute item numbers into relative ones
|
||||||
for safer replay
|
for safer replay
|
||||||
*/
|
*/
|
||||||
p1 = p->t_args[0];
|
p1 = p->t_args[0];
|
||||||
while (p1 && p1->t_oper == OP_LINK) {
|
while (p1 && p1->t_oper == OP_LINK) {
|
||||||
register p_tree p2 = p1->t_args[0];
|
register p_tree p2 = p1->t_args[0];
|
||||||
if (p2->t_ival > 0) {
|
if (p2->t_ival > 0 && p2->t_ival <= item_count) {
|
||||||
p2->t_ival = item_count - p2->t_ival;
|
p2->t_ival = p2->t_ival - item_count - 1;
|
||||||
}
|
}
|
||||||
p1 = p1->t_args[1];
|
p1 = p1->t_args[1];
|
||||||
}
|
}
|
||||||
if (p1 && p1->t_ival > 0) {
|
if (p1 && p1->t_ival > 0 && p1->t_ival <= item_count) {
|
||||||
p1->t_ival = item_count - p1->t_ival;
|
p1->t_ival = p1->t_ival - item_count - 1;
|
||||||
}
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
and returns 1 if it evaluates to TRUE, or 0 if it could not be
|
and returns 1 if it evaluates to TRUE, or 0 if it could not be
|
||||||
evaluated for some reason or if it evalutes to FALSE.
|
evaluated for some reason or if it evalutes to FALSE.
|
||||||
If the expression cannot be evaluated, an error message is given.
|
If the expression cannot be evaluated, an error message is given.
|
||||||
- int eval_desig(p_tree p, t_addr *pbuf, long **psize, p_type *ptp)
|
- int eval_desig(p_tree p, t_addr *paddr, long **psize, p_type *ptp)
|
||||||
This routine evaluates the expression indicated by p, which should
|
This routine evaluates the expression indicated by p, which should
|
||||||
result in a designator. The result of the expression is an address
|
result in a designator. The result of the expression is an address
|
||||||
which is to be found in *pbuf. *psize will contain the size of the
|
which is to be found in *paddr. *psize will contain the size of the
|
||||||
designated object, and *ptp its type.
|
designated object, and *ptp its type.
|
||||||
If the expression cannot be evaluated or does not result in a
|
If the expression cannot be evaluated or does not result in a
|
||||||
designator, 0 is returned and an error message is given.
|
designator, 0 is returned and an error message is given.
|
||||||
|
@ -50,15 +50,185 @@
|
||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
#include "langdep.h"
|
#include "langdep.h"
|
||||||
|
#include "scope.h"
|
||||||
|
#include "idf.h"
|
||||||
|
|
||||||
extern FILE *db_out;
|
extern FILE *db_out;
|
||||||
|
extern int stack_offset;
|
||||||
extern char *strcpy();
|
extern char *strcpy();
|
||||||
|
extern t_addr *get_EM_regs();
|
||||||
|
extern char *memcpy();
|
||||||
|
|
||||||
#define malloc_succeeded(p) if (! (p)) {\
|
#define malloc_succeeded(p) if (! (p)) {\
|
||||||
error("could not allocate enough memory");\
|
error("could not allocate enough memory");\
|
||||||
return 0;\
|
return 0;\
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static t_addr get_addr(p_symbol sym; long *psize);
|
||||||
|
Get the address of the object indicated by sym. Returns 0 on failure,
|
||||||
|
address on success. *psize will contain size of object.
|
||||||
|
For local variables or parameters, the 'stack_offset' variable is
|
||||||
|
used to determine from which stack frame the search must start.
|
||||||
|
*/
|
||||||
|
static t_addr
|
||||||
|
get_addr(sym, psize)
|
||||||
|
register p_symbol sym;
|
||||||
|
long *psize;
|
||||||
|
{
|
||||||
|
p_type tp = sym->sy_type;
|
||||||
|
long size = tp->ty_size;
|
||||||
|
t_addr *EM_regs;
|
||||||
|
int i;
|
||||||
|
p_scope sc, symsc;
|
||||||
|
|
||||||
|
*psize = size;
|
||||||
|
switch(sym->sy_class) {
|
||||||
|
case VAR:
|
||||||
|
/* exists if child exists; nm_value contains addres */
|
||||||
|
return (t_addr) sym->sy_name.nm_value;
|
||||||
|
case VARPAR:
|
||||||
|
case LOCVAR:
|
||||||
|
/* first find the stack frame in which it resides */
|
||||||
|
symsc = base_scope(sym->sy_scope);
|
||||||
|
|
||||||
|
/* now symsc contains the scope where the storage for sym is
|
||||||
|
allocated. Now find it on the stack of child.
|
||||||
|
*/
|
||||||
|
i = stack_offset;
|
||||||
|
for (;;) {
|
||||||
|
sc = 0;
|
||||||
|
if (! (EM_regs = get_EM_regs(i++))) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (! EM_regs[1]) {
|
||||||
|
error("%s not available", sym->sy_idf->id_text);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
sc = base_scope(get_scope_from_addr(EM_regs[2]));
|
||||||
|
if (! sc || sc->sc_start > EM_regs[2]) {
|
||||||
|
error("%s not available", sym->sy_idf->id_text);
|
||||||
|
sc = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (sc == symsc) break; /* found it */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sym->sy_class == LOCVAR) {
|
||||||
|
/* Either local variable or value parameter */
|
||||||
|
return EM_regs[sym->sy_name.nm_value < 0 ? 0 : 1] +
|
||||||
|
(t_addr) sym->sy_name.nm_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we get here, we have a var parameter. Get the parameters
|
||||||
|
of the current procedure invocation.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
p_type proctype = sc->sc_definedby->sy_type;
|
||||||
|
t_addr a;
|
||||||
|
char *AB;
|
||||||
|
|
||||||
|
size = proctype->ty_nbparams;
|
||||||
|
if (has_static_link(sc)) size += pointer_size;
|
||||||
|
AB = malloc((unsigned) size);
|
||||||
|
if (! AB) {
|
||||||
|
error("could not allocate enough memory");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (! get_bytes(size, EM_regs[1], AB)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((size = tp->ty_size) == 0) {
|
||||||
|
size = compute_size(tp, AB);
|
||||||
|
*psize = size;
|
||||||
|
}
|
||||||
|
a = (t_addr) get_int(AB+sym->sy_name.nm_value, pointer_size, T_UNSIGNED);
|
||||||
|
free(AB);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
error("%s is not a variable", sym->sy_idf->id_text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static int get_value(p_symbol sym; char **pbuf; long *psize);
|
||||||
|
Get the value of the symbol indicated by sym. Return 0 on failure,
|
||||||
|
1 on success. On success, 'pbuf' contains the value, and 'psize' contains
|
||||||
|
the size. For 'pbuf', storage is allocated by malloc; this storage must
|
||||||
|
be freed by caller (I don't like this any more than you do, but caller
|
||||||
|
does not know sizes).
|
||||||
|
For local variables or parameters, the 'stack_offset' variable is
|
||||||
|
used to determine from which stack frame the search must start.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
get_value(sym, pbuf, psize)
|
||||||
|
register p_symbol sym;
|
||||||
|
char **pbuf;
|
||||||
|
long *psize;
|
||||||
|
{
|
||||||
|
p_type tp = sym->sy_type;
|
||||||
|
int retval = 0;
|
||||||
|
t_addr a;
|
||||||
|
long size = tp->ty_size;
|
||||||
|
|
||||||
|
*pbuf = 0;
|
||||||
|
switch(sym->sy_class) {
|
||||||
|
case CONST:
|
||||||
|
*pbuf = malloc((unsigned) size);
|
||||||
|
if (! *pbuf) {
|
||||||
|
error("could not allocate enough memory");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch(tp->ty_class) {
|
||||||
|
case T_REAL:
|
||||||
|
put_real(*pbuf, size, sym->sy_const.co_rval);
|
||||||
|
break;
|
||||||
|
case T_INTEGER:
|
||||||
|
case T_SUBRANGE:
|
||||||
|
case T_UNSIGNED:
|
||||||
|
case T_ENUM:
|
||||||
|
put_int(*pbuf, size, sym->sy_const.co_ival);
|
||||||
|
break;
|
||||||
|
case T_SET:
|
||||||
|
memcpy(*pbuf, sym->sy_const.co_setval, (int) size);
|
||||||
|
break;
|
||||||
|
case T_STRING:
|
||||||
|
memcpy(*pbuf, sym->sy_const.co_sval, (int) size);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fatal("strange constant");
|
||||||
|
}
|
||||||
|
retval = 1;
|
||||||
|
break;
|
||||||
|
case VAR:
|
||||||
|
case VARPAR:
|
||||||
|
case LOCVAR:
|
||||||
|
a = get_addr(sym, psize);
|
||||||
|
if (a) {
|
||||||
|
size = *psize;
|
||||||
|
*pbuf = malloc((unsigned) size);
|
||||||
|
if (! *pbuf) {
|
||||||
|
error("could not allocate enough memory");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (get_bytes(size, a, *pbuf)) {
|
||||||
|
retval = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (retval == 0) {
|
||||||
|
if (*pbuf) free(*pbuf);
|
||||||
|
*pbuf = 0;
|
||||||
|
*psize = 0;
|
||||||
|
}
|
||||||
|
else *psize = size;
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
/* buffer to integer and vice versa routines */
|
/* buffer to integer and vice versa routines */
|
||||||
|
|
||||||
long
|
long
|
||||||
|
@ -808,6 +978,10 @@ cmp_op(p, pbuf, psize, ptp)
|
||||||
else l1 = (unsigned long) l1 >
|
else l1 = (unsigned long) l1 >
|
||||||
(unsigned long) l2;
|
(unsigned long) l2;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
l1 = 0;
|
||||||
|
assert(0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case T_REAL:
|
case T_REAL:
|
||||||
|
@ -834,6 +1008,10 @@ cmp_op(p, pbuf, psize, ptp)
|
||||||
case E_GT:
|
case E_GT:
|
||||||
l1 = d1 > d2;
|
l1 = d1 > d2;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
l1 = 0;
|
||||||
|
assert(0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1163,8 +1341,6 @@ eval_expr(p, pbuf, psize, ptp)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern t_addr get_addr();
|
|
||||||
|
|
||||||
int
|
int
|
||||||
eval_desig(p, paddr, psize, ptp)
|
eval_desig(p, paddr, psize, ptp)
|
||||||
p_tree p;
|
p_tree p;
|
||||||
|
|
|
@ -57,6 +57,21 @@ values of type INTEGER with values of type REAL in an expression without
|
||||||
using conversion routines. In
|
using conversion routines. In
|
||||||
.BR grind ,
|
.BR grind ,
|
||||||
the conversions needed are performed automatically.
|
the conversions needed are performed automatically.
|
||||||
|
.LP
|
||||||
|
Expressions whose value is to be printed can be given a "format" by appending
|
||||||
|
a `\e', followed by a format. A format consists of a string of letters.
|
||||||
|
The following letters are available:
|
||||||
|
.LP
|
||||||
|
.nf
|
||||||
|
c print all integer values as a char
|
||||||
|
d print all integer values in signed decimal format
|
||||||
|
o print all integer values in octal format
|
||||||
|
x print all integer values in hexadecimal format
|
||||||
|
h print all integer values in hexadecimal format
|
||||||
|
u print all integer values in unsigned decimal format
|
||||||
|
s for "pointer to char" types, make an attempt to print
|
||||||
|
the indicated string
|
||||||
|
.fi
|
||||||
.SS Operators
|
.SS Operators
|
||||||
.LP
|
.LP
|
||||||
.B Grind
|
.B Grind
|
||||||
|
@ -64,7 +79,7 @@ supports operators for addition, subtraction, multiplication, division,
|
||||||
remainder, bitwise or, bitwise xor, bitwise and, boolean or,
|
remainder, bitwise or, bitwise xor, bitwise and, boolean or,
|
||||||
boolean and, left-shift, right-shift, address-of, dereference, less than,
|
boolean and, left-shift, right-shift, address-of, dereference, less than,
|
||||||
less than or equal, equal, not equal, greater than, greater than or equal,
|
less than or equal, equal, not equal, greater than, greater than or equal,
|
||||||
selection.
|
selection, array subscripting.
|
||||||
.LP
|
.LP
|
||||||
The syntax and priority of these operators depends on the source language.
|
The syntax and priority of these operators depends on the source language.
|
||||||
Parentheses can be used for grouping.
|
Parentheses can be used for grouping.
|
||||||
|
@ -97,10 +112,20 @@ This indicates the first statement within the named function (except for
|
||||||
the trace command discussed later).
|
the trace command discussed later).
|
||||||
The following way is also accepted:
|
The following way is also accepted:
|
||||||
.RS
|
.RS
|
||||||
\fBat\fP [ "\fIfilename\fP": ] \fIlinenumber\fP \fBin \fIfunction\fP
|
\fBin\fP \fIfunction\fP \fBat\fP [ "\fIfilename\fP": ] \fIlinenumber\fP
|
||||||
.RE
|
.RE
|
||||||
In this case, consistency of the information given is checked. This last
|
In this case, consistency of the information given is checked. This last
|
||||||
form is useful for "stuffing" output from the status command described later.
|
form is useful for "stuffing" output from the status command described later.
|
||||||
|
.SS "Command numbers"
|
||||||
|
.LP
|
||||||
|
Some command numbers have a command number associated with them. Other commands
|
||||||
|
refer to these command numbers. These command numbers can either be given as
|
||||||
|
an absolute number, or as a negative number. In the last case, the number
|
||||||
|
is interpreted relative to the last number assigned. This feature is normally
|
||||||
|
only used for commands that are put in a log file, so that "sourceing" these
|
||||||
|
log files is safer (see also the description of the \fBsource\fP and \fBlog\fP
|
||||||
|
commands).
|
||||||
|
|
||||||
.SS "Commands"
|
.SS "Commands"
|
||||||
.TP
|
.TP
|
||||||
.B ^C
|
.B ^C
|
||||||
|
@ -130,7 +155,7 @@ command.
|
||||||
.br
|
.br
|
||||||
Continue execution from where it stopped, or, if \fIsourceline\fP is
|
Continue execution from where it stopped, or, if \fIsourceline\fP is
|
||||||
given, at that source line. If \fIcount\fP is given, pass \fIcount\fP-1
|
given, at that source line. If \fIcount\fP is given, pass \fIcount\fP-1
|
||||||
breakpoints.
|
breakpoints. \fIsourceline\fP must be in the same function.
|
||||||
.TP
|
.TP
|
||||||
\fBtrace\fP [ \fBon\fP \fIexpression\fP ] [ \fIposition\fP ] [ \fBif\fP \fIcondition\fP ]
|
\fBtrace\fP [ \fBon\fP \fIexpression\fP ] [ \fIposition\fP ] [ \fBif\fP \fIcondition\fP ]
|
||||||
.ti -0.5i
|
.ti -0.5i
|
||||||
|
@ -169,7 +194,7 @@ If no condition is given, stop when
|
||||||
is reached.
|
is reached.
|
||||||
Either a position or a condition (or both) must be given.
|
Either a position or a condition (or both) must be given.
|
||||||
.TP
|
.TP
|
||||||
\fBwhen\fP [ \fIposition\fP ] [ \fBif\fP \fIcondition\fP ] { \fIcommand\fP [ ; \fIcommand ] ... }
|
\fBwhen\fP [ \fIposition\fP ] [ \fBif\fP \fIcondition\fP ] { \fIcommand\fP [ ; \fIcommand\fP ] ... }
|
||||||
Execute the
|
Execute the
|
||||||
.B grind
|
.B grind
|
||||||
.IR command (s)
|
.IR command (s)
|
||||||
|
@ -340,6 +365,7 @@ executing \fBgrind\fP log files created with the \fBlog\fP command.
|
||||||
.br
|
.br
|
||||||
Start logging the \fBgrind\fP commands given on file \fIfilename\fP, or
|
Start logging the \fBgrind\fP commands given on file \fIfilename\fP, or
|
||||||
stop logging. If no argument is given, the current log file is printed.
|
stop logging. If no argument is given, the current log file is printed.
|
||||||
|
In logged commands, an absolute command number is replaced by a relative one.
|
||||||
.TP
|
.TP
|
||||||
\fBdisable\fP [ \fIcommandnumber\fP [ , \fIcommandnumber\fP ... ] ]
|
\fBdisable\fP [ \fIcommandnumber\fP [ , \fIcommandnumber\fP ... ] ]
|
||||||
.br
|
.br
|
||||||
|
@ -364,7 +390,7 @@ breakpoint.
|
||||||
Invoke the shell with \fIshellcommand\fP. \fIshellcommand\fP extends to the
|
Invoke the shell with \fIshellcommand\fP. \fIshellcommand\fP extends to the
|
||||||
end of the line. In the command, the characters `%' and `!' are replaced
|
end of the line. In the command, the characters `%' and `!' are replaced
|
||||||
with the current file name and the previous shell command respectively.
|
with the current file name and the previous shell command respectively.
|
||||||
The sequences `\%' and `\!' are replaced by `%' and `!' respectively.
|
The sequences `\e%' and `\e!' are replaced by `%' and `!' respectively.
|
||||||
.TP
|
.TP
|
||||||
\fBframe\fP [ \fIcount\fP | + \fIcount\fP | - \fIcount\fP ]
|
\fBframe\fP [ \fIcount\fP | + \fIcount\fP | - \fIcount\fP ]
|
||||||
.br
|
.br
|
||||||
|
|
|
@ -7,11 +7,9 @@
|
||||||
#include "position.h"
|
#include "position.h"
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
#include "operator.h"
|
#include "operator.h"
|
||||||
#include "message.h"
|
|
||||||
|
|
||||||
extern FILE *db_out;
|
extern FILE *db_out;
|
||||||
extern int db_ss;
|
extern int db_ss;
|
||||||
int stop_reason;
|
|
||||||
|
|
||||||
typedef struct item {
|
typedef struct item {
|
||||||
struct item *i_next;
|
struct item *i_next;
|
||||||
|
@ -27,6 +25,7 @@ struct itemlist {
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct itemlist item_list;
|
static struct itemlist item_list;
|
||||||
|
static int stop_reason;
|
||||||
int item_count;
|
int item_count;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -57,11 +56,10 @@ item_addr_actions(a, mess_type, may_stop)
|
||||||
int mess_type;
|
int mess_type;
|
||||||
int may_stop;
|
int may_stop;
|
||||||
{
|
{
|
||||||
/* Perform actions associated with position 'a', and return 1 if we must stop
|
/* Perform actions associated with position 'a', and return stop_reason
|
||||||
there, and 0 if not.
|
if we must stop there, and 0 if not.
|
||||||
*/
|
*/
|
||||||
register p_item i = item_list.il_first;
|
register p_item i = item_list.il_first;
|
||||||
int stopping = 0;
|
|
||||||
|
|
||||||
stop_reason = 0;
|
stop_reason = 0;
|
||||||
for (i = item_list.il_first; i != 0; i = i->i_next) {
|
for (i = item_list.il_first; i != 0; i = i->i_next) {
|
||||||
|
@ -71,10 +69,9 @@ item_addr_actions(a, mess_type, may_stop)
|
||||||
&& (p->t_address == a || p->t_address == NO_ADDR)) {
|
&& (p->t_address == a || p->t_address == NO_ADDR)) {
|
||||||
switch(p->t_oper) {
|
switch(p->t_oper) {
|
||||||
case OP_STOP:
|
case OP_STOP:
|
||||||
if (mess_type != M_DB_SS && mess_type != M_OK) break;
|
if (mess_type != 1) break;
|
||||||
if (! p->t_args[1] || eval_cond(p->t_args[1])) {
|
if (! p->t_args[1] || eval_cond(p->t_args[1])) {
|
||||||
if (! stop_reason) stop_reason = i->i_itemno;
|
if (! stop_reason) stop_reason = i->i_itemno;
|
||||||
stopping = 1;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OP_TRACE:
|
case OP_TRACE:
|
||||||
|
@ -94,7 +91,7 @@ item_addr_actions(a, mess_type, may_stop)
|
||||||
&& (p->t_address == a || p->t_address == NO_ADDR)) {
|
&& (p->t_address == a || p->t_address == NO_ADDR)) {
|
||||||
switch(p->t_oper) {
|
switch(p->t_oper) {
|
||||||
case OP_TRACE:
|
case OP_TRACE:
|
||||||
if ((! stopping && mess_type != M_END_SS)
|
if ((! stop_reason && mess_type != 0)
|
||||||
|| p->t_args[2] || ! may_stop) {
|
|| p->t_args[2] || ! may_stop) {
|
||||||
perform(p, a);
|
perform(p, a);
|
||||||
}
|
}
|
||||||
|
@ -111,7 +108,7 @@ item_addr_actions(a, mess_type, may_stop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return stopping;
|
return stop_reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_displays()
|
handle_displays()
|
||||||
|
@ -131,7 +128,7 @@ add_to_item_list(p)
|
||||||
{
|
{
|
||||||
p_item i;
|
p_item i;
|
||||||
|
|
||||||
if (in_item_list(p)) return 1;
|
if (in_item_list(p)) return;
|
||||||
|
|
||||||
i = new_item();
|
i = new_item();
|
||||||
i->i_node = p;
|
i->i_node = p;
|
||||||
|
@ -146,17 +143,23 @@ add_to_item_list(p)
|
||||||
i->i_itemno = ++item_count;
|
i->i_itemno = ++item_count;
|
||||||
item_list.il_last = i;
|
item_list.il_last = i;
|
||||||
pr_item(i);
|
pr_item(i);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p_tree
|
|
||||||
remove_from_item_list(n)
|
remove_from_item_list(n)
|
||||||
int n;
|
int n;
|
||||||
{
|
{
|
||||||
register p_item i = item_list.il_first, prev = 0;
|
register p_item i = item_list.il_first, prev = 0;
|
||||||
p_tree p;
|
p_tree p;
|
||||||
|
|
||||||
if (n <= 0) n = item_count - n;
|
if (n == 0) {
|
||||||
|
n = stop_reason;
|
||||||
|
if (n == 0) {
|
||||||
|
error("no current stopping point");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
stop_reason = 0;
|
||||||
|
}
|
||||||
|
if (n < 0) n = item_count + n + 1;
|
||||||
while (i) {
|
while (i) {
|
||||||
if (i->i_itemno == n) break;
|
if (i->i_itemno == n) break;
|
||||||
prev = i;
|
prev = i;
|
||||||
|
@ -164,7 +167,7 @@ remove_from_item_list(n)
|
||||||
}
|
}
|
||||||
if (! i) {
|
if (! i) {
|
||||||
error("no item %d in current status", n);
|
error("no item %d in current status", n);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
if (i->i_itemno == stop_reason) stop_reason = 0;
|
if (i->i_itemno == stop_reason) stop_reason = 0;
|
||||||
if (prev) {
|
if (prev) {
|
||||||
|
@ -176,7 +179,19 @@ remove_from_item_list(n)
|
||||||
if (p->t_address == NO_ADDR
|
if (p->t_address == NO_ADDR
|
||||||
&& (p->t_oper != OP_TRACE || ! p->t_args[0])) db_ss--;
|
&& (p->t_oper != OP_TRACE || ! p->t_args[0])) db_ss--;
|
||||||
free_item(i);
|
free_item(i);
|
||||||
return p;
|
switch(p->t_oper) {
|
||||||
|
case OP_STOP:
|
||||||
|
case OP_WHEN:
|
||||||
|
(void) setstop(p, 0);
|
||||||
|
break;
|
||||||
|
case OP_TRACE:
|
||||||
|
(void) settrace(p, 0);
|
||||||
|
break;
|
||||||
|
case OP_DUMP:
|
||||||
|
free_dump(p);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
freenode(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
p_tree
|
p_tree
|
||||||
|
@ -185,7 +200,11 @@ get_from_item_list(n)
|
||||||
{
|
{
|
||||||
register p_item i = item_list.il_first;
|
register p_item i = item_list.il_first;
|
||||||
|
|
||||||
if (n <= 0) n = item_count - n;
|
if (n == 0) {
|
||||||
|
n = stop_reason;
|
||||||
|
if (n == 0) return 0;
|
||||||
|
}
|
||||||
|
if (n < 0) n = item_count + n + 1;
|
||||||
while (i) {
|
while (i) {
|
||||||
if (i->i_itemno == n) return i->i_node;
|
if (i->i_itemno == n) return i->i_node;
|
||||||
i = i->i_next;
|
i = i->i_next;
|
||||||
|
@ -199,7 +218,14 @@ able_item(n, kind)
|
||||||
register p_item i = item_list.il_first;
|
register p_item i = item_list.il_first;
|
||||||
register p_tree p;
|
register p_tree p;
|
||||||
|
|
||||||
if (n <= 0) n = item_count - n;
|
if (n == 0) {
|
||||||
|
n = stop_reason;
|
||||||
|
if (n == 0) {
|
||||||
|
error("no current stopping point");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (n < 0) n = item_count + n + 1;
|
||||||
while (i) {
|
while (i) {
|
||||||
if (i->i_itemno == n) break;
|
if (i->i_itemno == n) break;
|
||||||
i = i->i_next;
|
i = i->i_next;
|
||||||
|
@ -221,10 +247,10 @@ able_item(n, kind)
|
||||||
switch(p->t_oper) {
|
switch(p->t_oper) {
|
||||||
case OP_STOP:
|
case OP_STOP:
|
||||||
case OP_WHEN:
|
case OP_WHEN:
|
||||||
setstop(p, kind ? M_CLRBP : M_SETBP);
|
(void) setstop(p, ! kind);
|
||||||
break;
|
break;
|
||||||
case OP_TRACE:
|
case OP_TRACE:
|
||||||
settrace(p, kind ? M_CLRTRACE : M_SETTRACE);
|
(void) settrace(p, ! kind);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ static struct langlist *list;
|
||||||
|
|
||||||
struct langdep *currlang;
|
struct langdep *currlang;
|
||||||
|
|
||||||
static int
|
static void
|
||||||
add_language(suff, lang)
|
add_language(suff, lang)
|
||||||
char *suff;
|
char *suff;
|
||||||
struct langdep *lang;
|
struct langdep *lang;
|
||||||
|
@ -27,14 +27,12 @@ add_language(suff, lang)
|
||||||
list = p;
|
list = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
init_languages()
|
init_languages()
|
||||||
{
|
{
|
||||||
add_language(".mod", m2_dep);
|
add_language(".mod", m2_dep);
|
||||||
add_language(".c", c_dep);
|
add_language(".c", c_dep);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
find_language(suff)
|
find_language(suff)
|
||||||
char *suff;
|
char *suff;
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,7 @@ extern FILE *db_out;
|
||||||
extern t_lineno currline;
|
extern t_lineno currline;
|
||||||
extern int interrupted;
|
extern int interrupted;
|
||||||
|
|
||||||
static int
|
static void
|
||||||
mk_filnm(dir, file, newname)
|
mk_filnm(dir, file, newname)
|
||||||
char *dir;
|
char *dir;
|
||||||
char *file;
|
char *file;
|
||||||
|
|
|
@ -21,6 +21,9 @@ FILE *db_in;
|
||||||
int debug;
|
int debug;
|
||||||
extern struct tokenname tkidf[];
|
extern struct tokenname tkidf[];
|
||||||
extern char *strindex();
|
extern char *strindex();
|
||||||
|
extern void signal_child();
|
||||||
|
extern void init_del();
|
||||||
|
extern void init_run();
|
||||||
extern int eof_seen;
|
extern int eof_seen;
|
||||||
extern int interrupted;
|
extern int interrupted;
|
||||||
|
|
||||||
|
@ -73,9 +76,7 @@ main(argc, argv)
|
||||||
else if (AObj == 0) AObj = "a.out";
|
else if (AObj == 0) AObj = "a.out";
|
||||||
reserve(tkidf);
|
reserve(tkidf);
|
||||||
reserve(shorts);
|
reserve(shorts);
|
||||||
if (! init_run()) {
|
init_run();
|
||||||
fatal("something wrong with file descriptors");
|
|
||||||
}
|
|
||||||
prompt();
|
prompt();
|
||||||
Commands();
|
Commands();
|
||||||
signal_child(SIGKILL);
|
signal_child(SIGKILL);
|
||||||
|
|
|
@ -25,9 +25,9 @@ static int
|
||||||
print_string(),
|
print_string(),
|
||||||
print_char(),
|
print_char(),
|
||||||
get_number(),
|
get_number(),
|
||||||
get_name(),
|
getname(),
|
||||||
get_token(),
|
get_token(),
|
||||||
get_string(),
|
getstring(),
|
||||||
print_op(),
|
print_op(),
|
||||||
binop_prio(),
|
binop_prio(),
|
||||||
unop_prio(),
|
unop_prio(),
|
||||||
|
@ -58,8 +58,8 @@ static struct langdep m2 = {
|
||||||
array_elsize,
|
array_elsize,
|
||||||
binop_prio,
|
binop_prio,
|
||||||
unop_prio,
|
unop_prio,
|
||||||
get_string,
|
getstring,
|
||||||
get_name,
|
getname,
|
||||||
get_number,
|
get_number,
|
||||||
get_token,
|
get_token,
|
||||||
print_op,
|
print_op,
|
||||||
|
@ -68,7 +68,7 @@ static struct langdep m2 = {
|
||||||
|
|
||||||
struct langdep *m2_dep = &m2;
|
struct langdep *m2_dep = &m2;
|
||||||
|
|
||||||
static int
|
static
|
||||||
print_char(c)
|
print_char(c)
|
||||||
int c;
|
int c;
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ print_char(c)
|
||||||
fprintf(db_out, (c >= 040 && c < 0177) ? "'%c'" : "%oC", c);
|
fprintf(db_out, (c >= 040 && c < 0177) ? "'%c'" : "%oC", c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static
|
||||||
print_string(f, s, len)
|
print_string(f, s, len)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char *s;
|
char *s;
|
||||||
|
@ -298,7 +298,7 @@ get_number(ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_name(c)
|
getname(c)
|
||||||
register int c;
|
register int c;
|
||||||
{
|
{
|
||||||
char buf[512+1];
|
char buf[512+1];
|
||||||
|
@ -437,7 +437,7 @@ get_token(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_string(c)
|
getstring(c)
|
||||||
int c;
|
int c;
|
||||||
{
|
{
|
||||||
register int ch;
|
register int ch;
|
||||||
|
@ -457,7 +457,7 @@ get_string(c)
|
||||||
return STRING;
|
return STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static
|
||||||
print_op(f, p)
|
print_op(f, p)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
p_tree p;
|
p_tree p;
|
||||||
|
@ -549,7 +549,7 @@ print_op(f, p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static
|
||||||
fix_bin_to_pref()
|
fix_bin_to_pref()
|
||||||
{
|
{
|
||||||
/* No problems of this kind in Modula-2 */
|
/* No problems of this kind in Modula-2 */
|
||||||
|
|
|
@ -143,11 +143,11 @@ print_position(a, print_function)
|
||||||
t_addr a;
|
t_addr a;
|
||||||
int print_function;
|
int print_function;
|
||||||
{
|
{
|
||||||
register p_scope sc = base_scope(get_scope_from_addr(a));
|
|
||||||
register p_position pos = get_position_from_addr(a);
|
register p_position pos = get_position_from_addr(a);
|
||||||
|
|
||||||
if (sc && print_function) {
|
if (print_function) {
|
||||||
fprintf(db_out, "in %s ", sc->sc_definedby->sy_idf->id_text);
|
register p_scope sc = base_scope(get_scope_from_addr(a));
|
||||||
|
if (sc) fprintf(db_out, "in %s ", sc->sc_definedby->sy_idf->id_text);
|
||||||
}
|
}
|
||||||
if (pos) fprintf(db_out, "at \"%s\":%u", pos->filename, pos->lineno);
|
if (pos) fprintf(db_out, "at \"%s\":%u", pos->filename, pos->lineno);
|
||||||
return pos;
|
return pos;
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
#include "message.h"
|
|
||||||
#include "langdep.h"
|
#include "langdep.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
|
@ -28,6 +27,9 @@ print_unsigned(tp, v, format)
|
||||||
format++;
|
format++;
|
||||||
}
|
}
|
||||||
switch(format == 0 ? 0 : *format) {
|
switch(format == 0 ? 0 : *format) {
|
||||||
|
case 'u':
|
||||||
|
fprintf(db_out, currlang->uns_fmt, v);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (tp != uchar_type) {
|
if (tp != uchar_type) {
|
||||||
fprintf(db_out, currlang->uns_fmt, v);
|
fprintf(db_out, currlang->uns_fmt, v);
|
||||||
|
@ -107,6 +109,9 @@ print_integer(tp, v, format)
|
||||||
case 'h':
|
case 'h':
|
||||||
fprintf(db_out, currlang->hexint_fmt, v);
|
fprintf(db_out, currlang->hexint_fmt, v);
|
||||||
break;
|
break;
|
||||||
|
case 'u':
|
||||||
|
fprintf(db_out, currlang->uns_fmt, v);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +256,7 @@ print_val(tp, tp_sz, addr, compressed, indent, format)
|
||||||
if (fld->fld_bitsize < (sz << 3)) {
|
if (fld->fld_bitsize < (sz << 3)) {
|
||||||
/* apparently a bit field */
|
/* apparently a bit field */
|
||||||
/* ??? */
|
/* ??? */
|
||||||
fprintf(db_out, "<bitfield, %d, %ld>", fld->fld_bitsize, sz);
|
fprintf(db_out, "<bitfield, %ld, %ld>", fld->fld_bitsize, sz);
|
||||||
}
|
}
|
||||||
else print_val(fld->fld_type, sz, addr+(fld->fld_pos>>3), compressed, indent, format);
|
else print_val(fld->fld_type, sz, addr+(fld->fld_pos>>3), compressed, indent, format);
|
||||||
if (compressed && i > 1) {
|
if (compressed && i > 1) {
|
||||||
|
|
141
util/grind/run.c
141
util/grind/run.c
|
@ -26,12 +26,9 @@ extern struct idf *str2idf();
|
||||||
extern char *AObj;
|
extern char *AObj;
|
||||||
extern FILE *db_out;
|
extern FILE *db_out;
|
||||||
extern int debug;
|
extern int debug;
|
||||||
extern long pointer_size;
|
|
||||||
extern char *progname;
|
extern char *progname;
|
||||||
extern int child_interrupted;
|
extern int child_interrupted;
|
||||||
extern int interrupted;
|
extern int interrupted;
|
||||||
extern int stop_reason;
|
|
||||||
extern int stack_offset;
|
|
||||||
extern t_lineno currline;
|
extern t_lineno currline;
|
||||||
|
|
||||||
static int child_pid; /* process id of child */
|
static int child_pid; /* process id of child */
|
||||||
|
@ -39,17 +36,20 @@ static int to_child, from_child; /* file descriptors for communication */
|
||||||
static int child_status;
|
static int child_status;
|
||||||
static int restoring;
|
static int restoring;
|
||||||
static int fild1[2], fild2[2]; /* pipe file descriptors */
|
static int fild1[2], fild2[2]; /* pipe file descriptors */
|
||||||
|
|
||||||
int disable_intr = 1;
|
int disable_intr = 1;
|
||||||
|
|
||||||
int db_ss;
|
int db_ss;
|
||||||
|
int stack_offset;
|
||||||
|
|
||||||
static int catch_sigpipe();
|
void signal_child();
|
||||||
|
|
||||||
|
static void catch_sigpipe();
|
||||||
static int stopped();
|
static int stopped();
|
||||||
static int uputm(), ugetm();
|
static int uputm(), ugetm();
|
||||||
static t_addr curr_stop;
|
static t_addr curr_stop;
|
||||||
p_tree run_command;
|
p_tree run_command;
|
||||||
|
|
||||||
static
|
static void
|
||||||
ITOBUF(p, l, sz)
|
ITOBUF(p, l, sz)
|
||||||
register char *p;
|
register char *p;
|
||||||
long l;
|
long l;
|
||||||
|
@ -78,7 +78,7 @@ BUFTOI(p, sz)
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
init_run()
|
init_run()
|
||||||
{
|
{
|
||||||
/* take file descriptors so that listing cannot take them */
|
/* take file descriptors so that listing cannot take them */
|
||||||
|
@ -89,26 +89,24 @@ init_run()
|
||||||
pipe(fild2) < 0 ||
|
pipe(fild2) < 0 ||
|
||||||
fild1[0] != 3 ||
|
fild1[0] != 3 ||
|
||||||
fild2[1] != 6) {
|
fild2[1] != 6) {
|
||||||
return 0;
|
fatal("something wrong with file descriptors");
|
||||||
}
|
}
|
||||||
to_child = fild1[1];
|
to_child = fild1[1];
|
||||||
from_child = fild2[0];
|
from_child = fild2[0];
|
||||||
child_pid = 0;
|
child_pid = 0;
|
||||||
if (currfile) CurrentScope = currfile->sy_file->f_scope;
|
if (currfile) CurrentScope = currfile->sy_file->f_scope;
|
||||||
currline = 0;
|
currline = 0;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int errno;
|
extern int errno;
|
||||||
|
|
||||||
int
|
|
||||||
start_child(p)
|
start_child(p)
|
||||||
p_tree p;
|
p_tree p;
|
||||||
{
|
{
|
||||||
/* start up the process to be debugged and set up communication */
|
/* start up the process to be debugged and set up communication */
|
||||||
|
|
||||||
char *argp[MAXARG]; /* argument list */
|
char *argp[MAXARG]; /* argument list */
|
||||||
register p_tree pt = p->t_args[0], pt1;
|
register p_tree pt = p->t_args[0], pt1 = 0;
|
||||||
unsigned int nargs = 1; /* #args */
|
unsigned int nargs = 1; /* #args */
|
||||||
char *in_redirect = 0; /* standard input redirected */
|
char *in_redirect = 0; /* standard input redirected */
|
||||||
char *out_redirect = 0; /* standard output redirected */
|
char *out_redirect = 0; /* standard output redirected */
|
||||||
|
@ -134,20 +132,20 @@ start_child(p)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error("too many arguments");
|
error("too many arguments");
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OP_INPUT:
|
case OP_INPUT:
|
||||||
if (in_redirect) {
|
if (in_redirect) {
|
||||||
error("input redirected twice?");
|
error("input redirected twice?");
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
in_redirect = pt->t_str;
|
in_redirect = pt->t_str;
|
||||||
break;
|
break;
|
||||||
case OP_OUTPUT:
|
case OP_OUTPUT:
|
||||||
if (out_redirect) {
|
if (out_redirect) {
|
||||||
error("output redirected twice?");
|
error("output redirected twice?");
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
out_redirect = pt->t_str;
|
out_redirect = pt->t_str;
|
||||||
break;
|
break;
|
||||||
|
@ -162,7 +160,7 @@ start_child(p)
|
||||||
child_pid = fork();
|
child_pid = fork();
|
||||||
if (child_pid < 0) {
|
if (child_pid < 0) {
|
||||||
error("could not create child");
|
error("could not create child");
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
if (child_pid == 0) {
|
if (child_pid == 0) {
|
||||||
/* this is the child process */
|
/* this is the child process */
|
||||||
|
@ -205,11 +203,10 @@ start_child(p)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* debugger */
|
/* debugger; don't close fild1[0] and fild2[1]; we want those file
|
||||||
close(fild1[0]);
|
descriptors occupied!
|
||||||
close(fild2[1]);
|
*/
|
||||||
|
|
||||||
pipe(fild1); /* to occupy file descriptors */
|
|
||||||
signal(SIGPIPE, catch_sigpipe);
|
signal(SIGPIPE, catch_sigpipe);
|
||||||
{
|
{
|
||||||
struct message_hdr m;
|
struct message_hdr m;
|
||||||
|
@ -217,21 +214,20 @@ start_child(p)
|
||||||
if (! ugetm(&m)) {
|
if (! ugetm(&m)) {
|
||||||
error("child not responding");
|
error("child not responding");
|
||||||
init_run();
|
init_run();
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
curr_stop = BUFTOI(m.m_buf+1, (int) PS);
|
curr_stop = BUFTOI(m.m_buf+1, (int) PS);
|
||||||
CurrentScope = get_scope_from_addr(curr_stop);
|
CurrentScope = get_scope_from_addr(curr_stop);
|
||||||
}
|
}
|
||||||
perform_items();
|
perform_items();
|
||||||
if (! restoring && ! item_addr_actions(curr_stop, M_OK, 1)) {
|
if (! restoring) {
|
||||||
send_cont(1);
|
int stop_reason = item_addr_actions(curr_stop, 1, 1);
|
||||||
|
if (! stop_reason) (void) send_cont(1);
|
||||||
|
else (void) stopped("stopped", curr_stop, stop_reason);
|
||||||
}
|
}
|
||||||
else if (! restoring) {
|
|
||||||
stopped("stopped", curr_stop);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
signal_child(sig)
|
signal_child(sig)
|
||||||
{
|
{
|
||||||
if (child_pid) {
|
if (child_pid) {
|
||||||
|
@ -243,7 +239,7 @@ signal_child(sig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
catch_sigpipe()
|
catch_sigpipe()
|
||||||
{
|
{
|
||||||
child_pid = 0;
|
child_pid = 0;
|
||||||
|
@ -348,9 +344,10 @@ static struct message_hdr answer;
|
||||||
static int single_stepping;
|
static int single_stepping;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
stopped(s, a)
|
stopped(s, a, stop_reason)
|
||||||
char *s; /* stop message */
|
char *s; /* stop message */
|
||||||
t_addr a; /* address where stopped */
|
t_addr a; /* address where stopped */
|
||||||
|
int stop_reason; /* status entry causing the stop */
|
||||||
{
|
{
|
||||||
p_position pos;
|
p_position pos;
|
||||||
|
|
||||||
|
@ -377,16 +374,17 @@ could_send(m, stop_message)
|
||||||
t_addr a;
|
t_addr a;
|
||||||
static int level = 0;
|
static int level = 0;
|
||||||
int child_dead = 0;
|
int child_dead = 0;
|
||||||
|
int stop_reason;
|
||||||
|
|
||||||
level++;
|
level++;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
stop_reason = 0;
|
||||||
if (! child_pid) {
|
if (! child_pid) {
|
||||||
error("no process");
|
error("no process");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (m->m_type & M_DB_RUN) {
|
if (m->m_type & M_DB_RUN) {
|
||||||
disable_intr = 0;
|
disable_intr = 0;
|
||||||
stop_reason = 0;
|
|
||||||
stack_offset = 0;
|
stack_offset = 0;
|
||||||
}
|
}
|
||||||
if (!child_interrupted && (! uputm(m) || ! ugetm(&answer))) {
|
if (!child_interrupted && (! uputm(m) || ! ugetm(&answer))) {
|
||||||
|
@ -405,7 +403,7 @@ could_send(m, stop_message)
|
||||||
if (! level) {
|
if (! level) {
|
||||||
child_interrupted = 0;
|
child_interrupted = 0;
|
||||||
interrupted = 0;
|
interrupted = 0;
|
||||||
stopped("interrupted", (t_addr) BUFTOI(answer.m_buf+1, (int)PS));
|
return stopped("interrupted", (t_addr) BUFTOI(answer.m_buf+1, (int)PS), 0);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -428,11 +426,14 @@ could_send(m, stop_message)
|
||||||
}
|
}
|
||||||
a = BUFTOI(answer.m_buf+1, (int)PS);
|
a = BUFTOI(answer.m_buf+1, (int)PS);
|
||||||
type = answer.m_type & 0377;
|
type = answer.m_type & 0377;
|
||||||
|
if (type == M_END_SS) type = 0;
|
||||||
|
else if (type == M_OK || type == M_DB_SS) type = 1;
|
||||||
|
else type = 2;
|
||||||
if (m->m_type & M_DB_RUN) {
|
if (m->m_type & M_DB_RUN) {
|
||||||
/* run command */
|
/* run command */
|
||||||
CurrentScope = get_scope_from_addr((t_addr) a);
|
CurrentScope = get_scope_from_addr((t_addr) a);
|
||||||
if (! item_addr_actions(a, type, stop_message) &&
|
if (!(stop_reason = item_addr_actions(a, type, stop_message))
|
||||||
( type == M_DB_SS || type == M_OK)) {
|
&& (type == 1)) {
|
||||||
/* no explicit breakpoints at this position.
|
/* no explicit breakpoints at this position.
|
||||||
Also, child did not stop because of
|
Also, child did not stop because of
|
||||||
SETSS or SETSSF, otherwise we would
|
SETSS or SETSSF, otherwise we would
|
||||||
|
@ -444,16 +445,16 @@ could_send(m, stop_message)
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (type != M_END_SS && single_stepping) {
|
if (type != 0 && single_stepping) {
|
||||||
m->m_type = M_CLRSS;
|
m->m_type = M_CLRSS;
|
||||||
if (! uputm(m) || ! ugetm(&answer)) return 0;
|
if (! uputm(m) || ! ugetm(&answer)) return 0;
|
||||||
}
|
}
|
||||||
single_stepping = 0;
|
single_stepping = 0;
|
||||||
}
|
}
|
||||||
if (stop_message) {
|
|
||||||
stopped("stopped", a);
|
|
||||||
}
|
|
||||||
level--;
|
level--;
|
||||||
|
if (stop_message) {
|
||||||
|
return stopped("stopped", a, stop_reason);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
|
@ -513,6 +514,7 @@ get_string(size, from, to)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
set_bytes(size, from, to)
|
set_bytes(size, from, to)
|
||||||
long size;
|
long size;
|
||||||
char *from;
|
char *from;
|
||||||
|
@ -542,11 +544,11 @@ set_bytes(size, from, to)
|
||||||
}
|
}
|
||||||
|
|
||||||
t_addr
|
t_addr
|
||||||
get_dump(globmessage, globbuf, stackmessage, stackbuf)
|
get_dump(globbuf, stackbuf)
|
||||||
struct message_hdr *globmessage, *stackmessage;
|
|
||||||
char **globbuf, **stackbuf;
|
char **globbuf, **stackbuf;
|
||||||
{
|
{
|
||||||
struct message_hdr m;
|
struct message_hdr m;
|
||||||
|
struct message_hdr *globm, *stackm;
|
||||||
long sz;
|
long sz;
|
||||||
|
|
||||||
m.m_type = M_DUMP;
|
m.m_type = M_DUMP;
|
||||||
|
@ -566,51 +568,54 @@ get_dump(globmessage, globbuf, stackmessage, stackbuf)
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
*globmessage = answer;
|
|
||||||
sz = BUFTOI(answer.m_buf+1, (int)LS);
|
sz = BUFTOI(answer.m_buf+1, (int)LS);
|
||||||
*globbuf = malloc((unsigned) sz);
|
*globbuf = malloc((unsigned) (sz+sizeof(struct message_hdr)));
|
||||||
if (! ureceive(*globbuf, sz) || ! ugetm(stackmessage)) {
|
if (! *globbuf
|
||||||
|
|| ! ureceive(*globbuf+sizeof(struct message_hdr), sz)
|
||||||
|
|| ! ugetm(&m)) {
|
||||||
if (*globbuf) free(*globbuf);
|
if (*globbuf) free(*globbuf);
|
||||||
|
else error("could not allocate enougn memory");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
assert(stackmessage->m_type == M_DSTACK);
|
globm = (struct message_hdr *) *globbuf;
|
||||||
sz = BUFTOI(stackmessage->m_buf+1, (int)LS);
|
*globm = answer;
|
||||||
*stackbuf = malloc((unsigned) sz);
|
|
||||||
if (! ureceive(*stackbuf, sz)) {
|
assert(m.m_type == M_DSTACK);
|
||||||
if (*globbuf) free(*globbuf);
|
sz = BUFTOI(m.m_buf+1, (int)LS);
|
||||||
|
*stackbuf = malloc((unsigned) sz+sizeof(struct message_hdr));
|
||||||
|
if (! *stackbuf || ! ureceive(*stackbuf+sizeof(struct message_hdr), sz)) {
|
||||||
|
free(*globbuf);
|
||||||
if (*stackbuf) free(*stackbuf);
|
if (*stackbuf) free(*stackbuf);
|
||||||
|
else error("could not allocate enougn memory");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ITOBUF(globmessage->m_buf+SP_OFF, BUFTOI(stackmessage->m_buf+SP_OFF, (int)PS), (int) PS);
|
stackm = (struct message_hdr *) *stackbuf;
|
||||||
if (! *globbuf || ! *stackbuf) {
|
*stackm = m;
|
||||||
error("could not allocate enough memory");
|
ITOBUF(globm->m_buf+SP_OFF, BUFTOI(stackm->m_buf+SP_OFF, (int)PS), (int) PS);
|
||||||
if (*globbuf) free(*globbuf);
|
return BUFTOI(globm->m_buf+PC_OFF, (int)PS);
|
||||||
if (*stackbuf) free(*stackbuf);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return BUFTOI(globmessage->m_buf+PC_OFF, (int)PS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
put_dump(globmessage, globbuf, stackmessage, stackbuf)
|
put_dump(globbuf, stackbuf)
|
||||||
struct message_hdr *globmessage, *stackmessage;
|
|
||||||
char *globbuf, *stackbuf;
|
char *globbuf, *stackbuf;
|
||||||
{
|
{
|
||||||
struct message_hdr m;
|
struct message_hdr m;
|
||||||
int retval;
|
struct message_hdr *globm = (struct message_hdr *) globbuf,
|
||||||
|
*stackm = (struct message_hdr *) stackbuf;
|
||||||
|
|
||||||
|
stackbuf += sizeof(struct message_hdr);
|
||||||
|
globbuf += sizeof(struct message_hdr);
|
||||||
if (! child_pid) {
|
if (! child_pid) {
|
||||||
restoring = 1;
|
restoring = 1;
|
||||||
start_child(run_command);
|
start_child(run_command);
|
||||||
restoring = 0;
|
restoring = 0;
|
||||||
}
|
}
|
||||||
retval = uputm(globmessage)
|
return uputm(globm)
|
||||||
&& usend(globbuf, BUFTOI(globmessage->m_buf+1, (int) LS))
|
&& usend(globbuf, BUFTOI(globm->m_buf+1, (int) LS))
|
||||||
&& uputm(stackmessage)
|
&& uputm(stackm)
|
||||||
&& usend(stackbuf, BUFTOI(stackmessage->m_buf+1, (int) LS))
|
&& usend(stackbuf, BUFTOI(stackm->m_buf+1, (int) LS))
|
||||||
&& ugetm(&m)
|
&& ugetm(&m)
|
||||||
&& stopped("restored", BUFTOI(m.m_buf+1, (int) PS));
|
&& stopped("restored", BUFTOI(m.m_buf+1, (int) PS), 0);
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t_addr *
|
t_addr *
|
||||||
|
@ -688,7 +693,7 @@ singlestep(type, count)
|
||||||
{
|
{
|
||||||
struct message_hdr m;
|
struct message_hdr m;
|
||||||
|
|
||||||
m.m_type = type | (db_ss ? M_DB_SS : 0);
|
m.m_type = (type ? M_SETSSF : M_SETSS) | (db_ss ? M_DB_SS : 0);
|
||||||
ITOBUF(m.m_buf+1, count, (int) LS);
|
ITOBUF(m.m_buf+1, count, (int) LS);
|
||||||
single_stepping = 1;
|
single_stepping = 1;
|
||||||
if (could_send(&m, 1) && child_pid) return 1;
|
if (could_send(&m, 1) && child_pid) return 1;
|
||||||
|
@ -703,9 +708,9 @@ set_or_clear_breakpoint(a, type)
|
||||||
{
|
{
|
||||||
struct message_hdr m;
|
struct message_hdr m;
|
||||||
|
|
||||||
m.m_type = type;
|
m.m_type = type ? M_SETBP : M_CLRBP;
|
||||||
ITOBUF(m.m_buf+1, (long) a, (int) PS);
|
ITOBUF(m.m_buf+1, (long) a, (int) PS);
|
||||||
if (debug) printf("%s breakpoint at 0x%lx\n", type == M_SETBP ? "setting" : "clearing", (long) a);
|
if (debug) printf("%s breakpoint at 0x%lx\n", type ? "setting" : "clearing", (long) a);
|
||||||
if (child_pid && ! could_send(&m, 0)) {
|
if (child_pid && ! could_send(&m, 0)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -719,10 +724,10 @@ set_or_clear_trace(start, end, type)
|
||||||
{
|
{
|
||||||
struct message_hdr m;
|
struct message_hdr m;
|
||||||
|
|
||||||
m.m_type = type;
|
m.m_type = type ? M_SETTRACE : M_CLRTRACE;
|
||||||
ITOBUF(m.m_buf+1, (long)start, (int) PS);
|
ITOBUF(m.m_buf+1, (long)start, (int) PS);
|
||||||
ITOBUF(m.m_buf+PS+1, (long)end, (int) PS);
|
ITOBUF(m.m_buf+PS+1, (long)end, (int) PS);
|
||||||
if (debug) printf("%s trace at [0x%lx,0x%lx]\n", type == M_SETTRACE ? "setting" : "clearing", (long) start, (long) end);
|
if (debug) printf("%s trace at [0x%lx,0x%lx]\n", type ? "setting" : "clearing", (long) start, (long) end);
|
||||||
if (child_pid && ! could_send(&m, 0)) {
|
if (child_pid && ! could_send(&m, 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "idf.h"
|
#include "idf.h"
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
#include "message.h"
|
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
#include "langdep.h"
|
#include "langdep.h"
|
||||||
|
@ -267,7 +266,7 @@ print_node(f, p, top_level)
|
||||||
break;
|
break;
|
||||||
case OP_DUMP:
|
case OP_DUMP:
|
||||||
fputs("dump ", f);
|
fputs("dump ", f);
|
||||||
print_position(p->t_address, 1);
|
(void) print_position(p->t_address, 1);
|
||||||
break;
|
break;
|
||||||
case OP_RESTORE:
|
case OP_RESTORE:
|
||||||
fputs("restore ", f);
|
fputs("restore ", f);
|
||||||
|
@ -295,7 +294,7 @@ print_node(f, p, top_level)
|
||||||
case OP_WHEN:
|
case OP_WHEN:
|
||||||
fputs("when ", f);
|
fputs("when ", f);
|
||||||
if (p->t_address != NO_ADDR) {
|
if (p->t_address != NO_ADDR) {
|
||||||
print_position(p->t_address, 1);
|
(void) print_position(p->t_address, 1);
|
||||||
}
|
}
|
||||||
else print_node(f, p->t_args[0], 0);
|
else print_node(f, p->t_args[0], 0);
|
||||||
if (p->t_args[1]) {
|
if (p->t_args[1]) {
|
||||||
|
@ -315,7 +314,7 @@ print_node(f, p, top_level)
|
||||||
case OP_STOP:
|
case OP_STOP:
|
||||||
fputs("stop ", f);
|
fputs("stop ", f);
|
||||||
if (p->t_address != NO_ADDR) {
|
if (p->t_address != NO_ADDR) {
|
||||||
print_position(p->t_address, 1);
|
(void) print_position(p->t_address, 1);
|
||||||
}
|
}
|
||||||
else print_node(f, p->t_args[0], 0);
|
else print_node(f, p->t_args[0], 0);
|
||||||
if (p->t_args[1]) {
|
if (p->t_args[1]) {
|
||||||
|
@ -331,7 +330,7 @@ print_node(f, p, top_level)
|
||||||
fputs(" ", f);
|
fputs(" ", f);
|
||||||
}
|
}
|
||||||
if (p->t_address != NO_ADDR) {
|
if (p->t_address != NO_ADDR) {
|
||||||
print_position(p->t_address, 1);
|
(void) print_position(p->t_address, 1);
|
||||||
}
|
}
|
||||||
else print_node(f, p->t_args[0], 0);
|
else print_node(f, p->t_args[0], 0);
|
||||||
if (p->t_args[1]) {
|
if (p->t_args[1]) {
|
||||||
|
@ -340,7 +339,7 @@ print_node(f, p, top_level)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OP_AT:
|
case OP_AT:
|
||||||
fprintf(f, "at \"%s\":%ld", p->t_filename, p->t_lino);
|
fprintf(f, "at \"%s\":%d", p->t_filename, (int) p->t_lino);
|
||||||
break;
|
break;
|
||||||
case OP_IN:
|
case OP_IN:
|
||||||
fputs("in ", f);
|
fputs("in ", f);
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "sizes.h"
|
#include "sizes.h"
|
||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "message.h"
|
|
||||||
#include "langdep.h"
|
#include "langdep.h"
|
||||||
#include "expr.h"
|
#include "expr.h"
|
||||||
|
|
||||||
|
@ -303,12 +302,12 @@ tp_lookup(type_index)
|
||||||
p = &list_row[type_index[0]];
|
p = &list_row[type_index[0]];
|
||||||
while (type_index[1] >= p->len) {
|
while (type_index[1] >= p->len) {
|
||||||
int indx = p->len/NINCR;
|
int indx = p->len/NINCR;
|
||||||
p->len += NINCR;
|
|
||||||
if (p->len) {
|
if (p->len) {
|
||||||
p->row = (p_type **) Realloc((char *) p->row,
|
p->row = (p_type **) Realloc((char *) p->row,
|
||||||
(unsigned) (indx + 1) * sizeof(p_type *));
|
(unsigned) (indx + 1) * sizeof(p_type *));
|
||||||
}
|
}
|
||||||
else p->row = (p_type **) Malloc(sizeof(p_type *));
|
else p->row = (p_type **) Malloc(sizeof(p_type *));
|
||||||
|
p->len += NINCR;
|
||||||
p->row[indx] = (p_type *) Malloc(NINCR * sizeof(p_type));
|
p->row[indx] = (p_type *) Malloc(NINCR * sizeof(p_type));
|
||||||
for (i = NINCR-1; i >= 0; i--) {
|
for (i = NINCR-1; i >= 0; i--) {
|
||||||
p->row[indx][i] = 0;
|
p->row[indx][i] = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue