file reorg, pathnames.h, paths.h
[unix-history] / usr / src / old / dbx / events.c
index 645d23c..7a2704e 100644 (file)
@@ -1,8 +1,14 @@
-/* Copyright (c) 1982 Regents of the University of California */
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
 
 
-static char sccsid[] = "@(#)events.c 1.3 4/8/83";
+#ifndef lint
+static char sccsid[] = "@(#)events.c   5.3 (Berkeley) %G%";
+#endif not lint
 
 
-static char rcsid[] = "$Header: events.c,v 1.3 84/03/27 10:20:41 linton Exp $";
+static char rcsid[] = "$Header: events.c,v 1.3 87/07/08 18:46:02 donn Exp $";
 
 /*
  * Event/breakpoint managment.
 
 /*
  * Event/breakpoint managment.
@@ -22,28 +28,37 @@ static char rcsid[] = "$Header: events.c,v 1.3 84/03/27 10:20:41 linton Exp $";
 #include "lists.h"
 
 #ifndef public
 #include "lists.h"
 
 #ifndef public
+
 typedef struct Event *Event;
 typedef struct Breakpoint *Breakpoint;
 
 typedef struct Event *Event;
 typedef struct Breakpoint *Breakpoint;
 
-Boolean inst_tracing;
-Boolean single_stepping;
-Boolean isstopped;
-
 #include "symbols.h"
 
 #include "symbols.h"
 
-Symbol linesym;
-Symbol procsym;
-Symbol pcsym;
-Symbol retaddrsym;
-
 #define addevent(cond, cmdlist) event_alloc(false, cond, cmdlist)
 #define event_once(cond, cmdlist) event_alloc(true, cond, cmdlist)
 
 #define addevent(cond, cmdlist) event_alloc(false, cond, cmdlist)
 #define event_once(cond, cmdlist) event_alloc(true, cond, cmdlist)
 
+/*
+ * When tracing variables we keep a copy of their most recent value
+ * and compare it to the current one each time a breakpoint occurs.
+ * MAXTRSIZE is the maximum size variable we allow.
+ */
+
+#define MAXTRSIZE 512
+
 #endif
 
 #endif
 
+public boolean inst_tracing;
+public boolean single_stepping;
+public boolean isstopped;
+
+public Symbol linesym;
+public Symbol procsym;
+public Symbol pcsym;
+public Symbol retaddrsym;
+
 struct Event {
     unsigned int id;
 struct Event {
     unsigned int id;
-    Boolean temporary;
+    boolean temporary;
     Node condition;
     Cmdlist actions;
 };
     Node condition;
     Cmdlist actions;
 };
@@ -53,6 +68,7 @@ struct Breakpoint {
     Address bpaddr;    
     Lineno bpline;
     Cmdlist actions;
     Address bpaddr;    
     Lineno bpline;
     Cmdlist actions;
+    boolean temporary;
 };
 
 typedef List Eventlist;
 };
 
 typedef List Eventlist;
@@ -63,8 +79,9 @@ typedef List Bplist;
 
 private Eventlist eventlist;           /* list of active events */
 private Bplist bplist;                 /* list of active breakpoints */
 
 private Eventlist eventlist;           /* list of active events */
 private Bplist bplist;                 /* list of active breakpoints */
-private Integer eventid;               /* id number of next allocated event */
-private Integer trid;                  /* id number of next allocated trace */
+private Event curevent;                        /* most recently created event */
+private integer eventid;               /* id number of current event */
+private integer trid;                  /* id number of current trace */
 
 typedef struct Trcmd {
     Integer trid;
 
 typedef struct Trcmd {
     Integer trid;
@@ -115,7 +132,7 @@ public bpinit()
  */
 
 public Event event_alloc(istmp, econd, cmdlist)
  */
 
 public Event event_alloc(istmp, econd, cmdlist)
-Boolean istmp;
+boolean istmp;
 Node econd;
 Cmdlist cmdlist;
 {
 Node econd;
 Cmdlist cmdlist;
 {
@@ -128,6 +145,7 @@ Cmdlist cmdlist;
     e->condition = econd;
     e->actions = cmdlist;
     eventlist_append(e, eventlist);
     e->condition = econd;
     e->actions = cmdlist;
     eventlist_append(e, eventlist);
+    curevent = e;
     translate(e);
     return e;
 }
     translate(e);
     return e;
 }
@@ -322,11 +340,11 @@ Node exp;
  * This can only be done if there are no breakpoints within the function.
  */
 
  * This can only be done if there are no breakpoints within the function.
  */
 
-public Boolean canskip(f)
+public boolean canskip(f)
 Symbol f;
 {
     Breakpoint p;
 Symbol f;
 {
     Breakpoint p;
-    Boolean ok;
+    boolean ok;
 
     ok = true;
     foreach (Breakpoint, p, bplist)
 
     ok = true;
     foreach (Breakpoint, p, bplist)
@@ -444,9 +462,10 @@ Cmdlist actions;
     p->bpaddr = addr;
     p->bpline = line;
     p->actions = actions;
     p->bpaddr = addr;
     p->bpline = line;
     p->actions = actions;
+    p->temporary = false;
     if (tracebpts) {
        if (e == nil) {
     if (tracebpts) {
        if (e == nil) {
-           printf("new bp at 0x%x for event ??\n", addr, e->id);
+           printf("new bp at 0x%x for event ??\n", addr);
        } else {
            printf("new bp at 0x%x for event %d\n", addr, e->id);
        }
        } else {
            printf("new bp at 0x%x for event %d\n", addr, e->id);
        }
@@ -478,10 +497,10 @@ public bpfree()
  * and if so do the associated commands.
  */
 
  * and if so do the associated commands.
  */
 
-public Boolean bpact()
+public boolean bpact()
 {
     register Breakpoint p;
 {
     register Breakpoint p;
-    Boolean found;
+    boolean found;
     integer eventId;
 
     found = false;
     integer eventId;
 
     found = false;
@@ -502,6 +521,9 @@ public Boolean bpact()
            if (isstopped) {
                eventId = p->event->id;
            }
            if (isstopped) {
                eventId = p->event->id;
            }
+           if (p->temporary) {
+               list_delete(list_curitem(bplist), bplist);
+           }
        }
     endfor
     if (isstopped) {
        }
     endfor
     if (isstopped) {
@@ -524,7 +546,7 @@ public Boolean bpact()
  */
 
 public traceon(inst, event, cmdlist)
  */
 
 public traceon(inst, event, cmdlist)
-Boolean inst;
+boolean inst;
 Event event;
 Cmdlist cmdlist;
 {
 Event event;
 Cmdlist cmdlist;
 {
@@ -532,11 +554,17 @@ Cmdlist cmdlist;
     Breakpoint bp;
     Cmdlist actions;
     Address ret;
     Breakpoint bp;
     Cmdlist actions;
     Address ret;
+    Event e;
 
 
+    if (event == nil) {
+       e = curevent;
+    } else {
+       e = event;
+    }
     trcmd = new(Trcmd);
     ++trid;
     trcmd->trid = trid;
     trcmd = new(Trcmd);
     ++trid;
     trcmd->trid = trid;
-    trcmd->event = event;
+    trcmd->event = e;
     trcmd->cmdlist = cmdlist;
     single_stepping = true;
     if (inst) {
     trcmd->cmdlist = cmdlist;
     single_stepping = true;
     if (inst) {
@@ -548,10 +576,11 @@ Cmdlist cmdlist;
     ret = return_addr();
     if (ret != 0) {
        actions = buildcmdlist(build(O_TRACEOFF, trcmd->trid));
     ret = return_addr();
     if (ret != 0) {
        actions = buildcmdlist(build(O_TRACEOFF, trcmd->trid));
-       bp = bp_alloc(event, (Address) ret, 0, actions);
+       bp = bp_alloc(e, (Address) ret, 0, actions);
+       bp->temporary = true;
     }
     if (tracebpts) {
     }
     if (tracebpts) {
-       printf("adding trace %d for event %d\n", trcmd->trid, event->id);
+       printf("adding trace %d for event %d\n", trcmd->trid, e->id);
     }
 }
 
     }
 }
 
@@ -564,7 +593,7 @@ public traceoff(id)
 Integer id;
 {
     register Trcmd t;
 Integer id;
 {
     register Trcmd t;
-    register Boolean found;
+    register boolean found;
 
     found = false;
     foreach (Trcmd, t, eachline)
 
     found = false;
     foreach (Trcmd, t, eachline)
@@ -585,7 +614,8 @@ Integer id;
            }
        endfor
        if (not found) {
            }
        endfor
        if (not found) {
-           panic("missing trid %d", id);
+           beginerrmsg();
+           fprintf(stderr, "[internal error: trace id %d not found]\n", id);
        }
     }
     if (list_size(eachinst) == 0) {
        }
     }
     if (list_size(eachinst) == 0) {
@@ -634,19 +664,19 @@ public printnews()
  * note it if we're tracing lines.
  */
 
  * note it if we're tracing lines.
  */
 
-private Boolean chklist();
+private boolean chklist();
 
 public callnews(iscall)
 
 public callnews(iscall)
-Boolean iscall;
+boolean iscall;
 {
     if (not chklist(eachline, iscall)) {
        chklist(eachinst, iscall);
     }
 }
 
 {
     if (not chklist(eachline, iscall)) {
        chklist(eachinst, iscall);
     }
 }
 
-private Boolean chklist(list, iscall)
+private boolean chklist(list, iscall)
 List list;
 List list;
-Boolean iscall;
+boolean iscall;
 {
     register Trcmd t;
     register Command cmd;
 {
     register Trcmd t;
     register Command cmd;
@@ -668,14 +698,6 @@ Boolean iscall;
     return false;
 }
 
     return false;
 }
 
-/*
- * When tracing variables we keep a copy of their most recent value
- * and compare it to the current one each time a breakpoint occurs.
- * MAXTRSIZE is the maximum size variable we allow.
- */
-
-#define MAXTRSIZE 512
-
 /*
  * List of variables being watched.
  */
 /*
  * List of variables being watched.
  */
@@ -700,7 +722,7 @@ private Trinfo findtrinfo(p)
 Node p;
 {
     register Trinfo tp;
 Node p;
 {
     register Trinfo tp;
-    Boolean isnew;
+    boolean isnew;
 
     isnew = true;
     if (trinfolist == nil) {
 
     isnew = true;
     if (trinfolist == nil) {
@@ -739,17 +761,20 @@ Node p;
     register Trinfo tp;
     register int n;
     char buff[MAXTRSIZE];
     register Trinfo tp;
     register int n;
     char buff[MAXTRSIZE];
+    Filename curfile;
     static Lineno prevline;
     static Lineno prevline;
+    static Filename prevfile;
 
     tp = findtrinfo(p);
     n = size(p->nodetype);
     dread(buff, tp->traddr, n);
 
     tp = findtrinfo(p);
     n = size(p->nodetype);
     dread(buff, tp->traddr, n);
+    curfile = srcfilename(pc);
     if (tp->trvalue == nil) {
        tp->trvalue = newarr(char, n);
        mov(buff, tp->trvalue, n);
        mov(buff, sp, n);
        sp += n;
     if (tp->trvalue == nil) {
        tp->trvalue = newarr(char, n);
        mov(buff, tp->trvalue, n);
        mov(buff, sp, n);
        sp += n;
-       printf("initially (at line %d):\t", curline);
+       printf("initially (at line %d in \"%s\"):\t", curline, curfile);
        prtree(stdout, p);
        printf(" = ");
        printval(p->nodetype);
        prtree(stdout, p);
        printf(" = ");
        printval(p->nodetype);
@@ -758,13 +783,14 @@ Node p;
        mov(buff, tp->trvalue, n);
        mov(buff, sp, n);
        sp += n;
        mov(buff, tp->trvalue, n);
        mov(buff, sp, n);
        sp += n;
-       printf("after line %d:\t", prevline);
+       printf("after line %d in \"%s\":\t", prevline, prevfile);
        prtree(stdout, p);
        printf(" = ");
        printval(p->nodetype);
        putchar('\n');
     }
     prevline = curline;
        prtree(stdout, p);
        printf(" = ");
        printval(p->nodetype);
        putchar('\n');
     }
     prevline = curline;
+    prevfile = curfile;
 }
 
 /*
 }
 
 /*