1990-08-31 18:22:53 +00:00
|
|
|
/* $Header$ */
|
|
|
|
|
|
|
|
#include <alloc.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "position.h"
|
|
|
|
#include "tree.h"
|
|
|
|
#include "operator.h"
|
1990-10-11 08:42:07 +00:00
|
|
|
#include "message.h"
|
1990-08-31 18:22:53 +00:00
|
|
|
|
|
|
|
extern FILE *db_out;
|
|
|
|
extern int db_ss;
|
1990-10-17 17:00:03 +00:00
|
|
|
int stop_reason;
|
1990-08-31 18:22:53 +00:00
|
|
|
|
|
|
|
typedef struct item {
|
1990-10-11 08:42:07 +00:00
|
|
|
struct item *i_next;
|
|
|
|
struct tree *i_node;
|
|
|
|
int i_disabled;
|
|
|
|
int i_itemno;
|
1990-08-31 18:22:53 +00:00
|
|
|
} t_item, *p_item;
|
|
|
|
|
|
|
|
/* STATICALLOCDEF "item" 10 */
|
|
|
|
|
|
|
|
struct itemlist {
|
|
|
|
p_item il_first, il_last;
|
|
|
|
int il_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct itemlist item_list;
|
|
|
|
|
1990-10-11 08:42:07 +00:00
|
|
|
static int
|
1990-08-31 18:22:53 +00:00
|
|
|
in_item_list(p)
|
|
|
|
p_tree p;
|
|
|
|
{
|
|
|
|
register p_item i = item_list.il_first;
|
|
|
|
|
|
|
|
while (i) {
|
|
|
|
if (i->i_node == p) return 1;
|
|
|
|
i = i->i_next;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1990-10-11 08:42:07 +00:00
|
|
|
static
|
|
|
|
pr_item(i)
|
|
|
|
p_item i;
|
|
|
|
{
|
|
|
|
fprintf(db_out, "(%d)\t", i->i_itemno);
|
|
|
|
print_node(i->i_node, 0);
|
|
|
|
fputs(i->i_disabled ? " (disabled)\n": "\n", db_out);
|
|
|
|
}
|
|
|
|
|
1990-08-31 18:22:53 +00:00
|
|
|
int
|
1990-10-17 17:00:03 +00:00
|
|
|
item_addr_actions(a, mess_type, may_stop)
|
1990-08-31 18:22:53 +00:00
|
|
|
t_addr a;
|
1990-10-17 17:00:03 +00:00
|
|
|
int mess_type;
|
|
|
|
int may_stop;
|
1990-08-31 18:22:53 +00:00
|
|
|
{
|
|
|
|
/* Perform actions associated with position 'a', and return 1 if we must stop
|
|
|
|
there, and 0 if not.
|
|
|
|
*/
|
|
|
|
register p_item i = item_list.il_first;
|
|
|
|
int stopping = 0;
|
|
|
|
|
1990-10-17 17:00:03 +00:00
|
|
|
stop_reason = 0;
|
|
|
|
for (i = item_list.il_first; i != 0; i = i->i_next) {
|
1990-08-31 18:22:53 +00:00
|
|
|
register p_tree p = i->i_node;
|
|
|
|
|
1990-10-17 17:00:03 +00:00
|
|
|
if (! i->i_disabled
|
|
|
|
&& (p->t_address == a || p->t_address == NO_ADDR)) {
|
1990-08-31 18:22:53 +00:00
|
|
|
switch(p->t_oper) {
|
1990-10-17 17:00:03 +00:00
|
|
|
case OP_STOP:
|
1990-10-29 11:38:35 +00:00
|
|
|
if (mess_type != M_DB_SS && mess_type != M_OK) break;
|
1990-10-17 17:00:03 +00:00
|
|
|
if (! p->t_args[1] || eval_cond(p->t_args[1])) {
|
|
|
|
if (! stop_reason) stop_reason = i->i_itemno;
|
|
|
|
stopping = 1;
|
|
|
|
}
|
|
|
|
break;
|
1990-08-31 18:22:53 +00:00
|
|
|
case OP_TRACE:
|
1990-10-17 17:00:03 +00:00
|
|
|
case OP_WHEN:
|
|
|
|
case OP_DUMP:
|
|
|
|
case OP_DISPLAY:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = item_list.il_first; i != 0; i = i->i_next) {
|
|
|
|
register p_tree p = i->i_node;
|
|
|
|
|
|
|
|
if (! i->i_disabled
|
|
|
|
&& (p->t_address == a || p->t_address == NO_ADDR)) {
|
|
|
|
switch(p->t_oper) {
|
|
|
|
case OP_TRACE:
|
1990-10-29 11:38:35 +00:00
|
|
|
if ((! stopping && mess_type != M_END_SS)
|
1990-10-17 17:00:03 +00:00
|
|
|
|| p->t_args[2] || ! may_stop) {
|
|
|
|
perform(p, a);
|
|
|
|
}
|
|
|
|
break;
|
1990-08-31 18:22:53 +00:00
|
|
|
case OP_WHEN:
|
1990-10-11 08:42:07 +00:00
|
|
|
perform(p, a);
|
1990-08-31 18:22:53 +00:00
|
|
|
break;
|
|
|
|
case OP_STOP:
|
|
|
|
case OP_DUMP:
|
1990-09-20 17:51:14 +00:00
|
|
|
case OP_DISPLAY:
|
1990-08-31 18:22:53 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return stopping;
|
|
|
|
}
|
|
|
|
|
1990-09-20 17:51:14 +00:00
|
|
|
handle_displays()
|
|
|
|
{
|
|
|
|
register p_item i = item_list.il_first;
|
|
|
|
|
|
|
|
while (i) {
|
|
|
|
register p_tree p = i->i_node;
|
|
|
|
|
1990-10-11 08:42:07 +00:00
|
|
|
if (! i->i_disabled && p->t_oper == OP_DISPLAY) do_print(p);
|
1990-09-20 17:51:14 +00:00
|
|
|
i = i->i_next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1990-08-31 18:22:53 +00:00
|
|
|
add_to_item_list(p)
|
|
|
|
p_tree p;
|
|
|
|
{
|
|
|
|
p_item i;
|
|
|
|
|
|
|
|
if (in_item_list(p)) return 1;
|
|
|
|
|
|
|
|
i = new_item();
|
|
|
|
i->i_node = p;
|
1990-10-17 17:00:03 +00:00
|
|
|
if (p->t_address == NO_ADDR
|
|
|
|
&& (p->t_oper != OP_TRACE || ! p->t_args[0])) db_ss++;
|
1990-08-31 18:22:53 +00:00
|
|
|
if (item_list.il_first == 0) {
|
|
|
|
item_list.il_first = i;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
item_list.il_last->i_next = i;
|
|
|
|
}
|
1990-10-11 08:42:07 +00:00
|
|
|
i->i_itemno = ++item_list.il_count;
|
1990-08-31 18:22:53 +00:00
|
|
|
item_list.il_last = i;
|
1990-10-11 08:42:07 +00:00
|
|
|
pr_item(i);
|
1990-08-31 18:22:53 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
p_tree
|
|
|
|
remove_from_item_list(n)
|
|
|
|
int n;
|
|
|
|
{
|
|
|
|
register p_item i = item_list.il_first, prev = 0;
|
1990-10-29 11:38:35 +00:00
|
|
|
p_tree p;
|
1990-08-31 18:22:53 +00:00
|
|
|
|
|
|
|
while (i) {
|
1990-10-11 08:42:07 +00:00
|
|
|
if (i->i_itemno == n) break;
|
1990-08-31 18:22:53 +00:00
|
|
|
prev = i;
|
|
|
|
i = i->i_next;
|
|
|
|
}
|
1990-10-29 11:38:35 +00:00
|
|
|
if (! i) {
|
|
|
|
error("no item %d in current status", n);
|
|
|
|
return 0;
|
1990-08-31 18:22:53 +00:00
|
|
|
}
|
1990-10-29 11:38:35 +00:00
|
|
|
if (i->i_itemno == stop_reason) stop_reason = 0;
|
|
|
|
if (prev) {
|
|
|
|
prev->i_next = i->i_next;
|
|
|
|
}
|
|
|
|
else item_list.il_first = i->i_next;
|
|
|
|
if (i == item_list.il_last) item_list.il_last = prev;
|
|
|
|
p = i->i_node;
|
|
|
|
if (p->t_address == NO_ADDR
|
|
|
|
&& (p->t_oper != OP_TRACE || ! p->t_args[0])) db_ss--;
|
|
|
|
free_item(i);
|
1990-08-31 18:22:53 +00:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
p_tree
|
|
|
|
get_from_item_list(n)
|
|
|
|
int n;
|
|
|
|
{
|
|
|
|
register p_item i = item_list.il_first;
|
|
|
|
|
|
|
|
while (i) {
|
1990-10-11 08:42:07 +00:00
|
|
|
if (i->i_itemno == n) return i->i_node;
|
1990-08-31 18:22:53 +00:00
|
|
|
i = i->i_next;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1990-10-11 08:42:07 +00:00
|
|
|
able_item(n, kind)
|
|
|
|
int n;
|
1990-08-31 18:22:53 +00:00
|
|
|
{
|
|
|
|
register p_item i = item_list.il_first;
|
1990-10-11 08:42:07 +00:00
|
|
|
register p_tree p;
|
1990-08-31 18:22:53 +00:00
|
|
|
|
1990-10-11 08:42:07 +00:00
|
|
|
while (i) {
|
|
|
|
if (i->i_itemno == n) break;
|
|
|
|
i = i->i_next;
|
|
|
|
}
|
|
|
|
if (! i) {
|
|
|
|
error("no item %d in current status", n);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
p = i->i_node;
|
|
|
|
if (i->i_disabled == kind) {
|
|
|
|
warning("item %d already %sabled", n, kind ? "dis" : "en");
|
|
|
|
return;
|
|
|
|
}
|
1990-10-17 17:00:03 +00:00
|
|
|
if (p->t_address == NO_ADDR
|
|
|
|
&& (p->t_oper != OP_TRACE || ! p->t_args[0])) {
|
1990-10-11 08:42:07 +00:00
|
|
|
db_ss += kind == 1 ? (-1) : 1;
|
|
|
|
}
|
|
|
|
i->i_disabled = kind;
|
|
|
|
switch(p->t_oper) {
|
|
|
|
case OP_STOP:
|
|
|
|
case OP_WHEN:
|
1990-10-29 11:38:35 +00:00
|
|
|
setstop(p, kind ? M_CLRBP : M_SETBP);
|
1990-10-11 08:42:07 +00:00
|
|
|
break;
|
|
|
|
case OP_TRACE:
|
1990-10-29 11:38:35 +00:00
|
|
|
settrace(p, kind ? M_CLRTRACE : M_SETTRACE);
|
1990-10-11 08:42:07 +00:00
|
|
|
break;
|
1990-08-31 18:22:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1990-10-11 08:42:07 +00:00
|
|
|
print_items()
|
1990-08-31 18:22:53 +00:00
|
|
|
{
|
1990-10-11 08:42:07 +00:00
|
|
|
register p_item i = item_list.il_first;
|
|
|
|
|
|
|
|
for (; i; i = i->i_next) {
|
|
|
|
pr_item(i);
|
|
|
|
}
|
1990-08-31 18:22:53 +00:00
|
|
|
}
|
|
|
|
|
1990-10-29 11:38:35 +00:00
|
|
|
perform_items()
|
1990-08-31 18:22:53 +00:00
|
|
|
{
|
|
|
|
register p_item i = item_list.il_first;
|
|
|
|
|
|
|
|
for (; i; i = i->i_next) {
|
1990-10-11 08:42:07 +00:00
|
|
|
if (! i->i_disabled && i->i_node->t_oper != OP_DUMP) eval(i->i_node);
|
1990-08-31 18:22:53 +00:00
|
|
|
}
|
|
|
|
}
|