Annotation of coherent/b/bin/db/db4.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * db/db4.c
                      3:  * A debugger.
                      4:  * Breakpoints.
                      5:  */
                      6: 
                      7: #include "db.h"
                      8: 
                      9: /*
                     10:  * Delete a breakpoint.
                     11:  * If 'r' is set, it is a return breakpoint.
                     12:  * If 's' is set, it is a :sc breakpoint.
                     13:  */
                     14: int
                     15: bpt_del(t, addr) int t; ADDR_T addr;
                     16: {
                     17:        register int f;
                     18:        register BPT *bp;
                     19: 
                     20:        switch (t) {
                     21:        case 'b':       f = BBPT;       break;
                     22:        case 'r':       f = BRET;       break;
                     23:        case 's':       f = BSIN;       break;
                     24:        }
                     25: 
                     26:        for (bp = &bpt[0]; bp < &bpt[NBPT]; bp++) {
                     27:                if ((bp->b_flag & f) == 0 || bp->b_badd != addr)
                     28:                        continue;
                     29:                bp->b_flag &= ~f;
                     30:                return 1;
                     31:        }
                     32:        return 0;
                     33: }
                     34: 
                     35: /*
                     36:  * Initialize the breakpoint table.
                     37:  */
                     38: void
                     39: bpt_init()
                     40: {
                     41:        register BPT *bp;
                     42: 
                     43:        for (bp = &bpt[0]; bp < &bpt[NBPT]; bp++) {
                     44:                bp->b_flag = 0;
                     45:                bp->b_bcom = bp->b_rcom = NULL;
                     46:        }
                     47: }
                     48: 
                     49: /*
                     50:  * Display breakpoints.
                     51:  */
                     52: void
                     53: bpt_display()
                     54: {
                     55:        register BPT *bp;
                     56: 
                     57:        for (bp = &bpt[0]; bp < &bpt[NBPT]; bp++) {
                     58:                if (testint())
                     59:                        return;
                     60:                if ((bp->b_flag&BBPT) != 0)
                     61:                        bpt_print(' ', bp->b_badd, bp->b_bcom);
                     62:                if (testint())
                     63:                        return;
                     64:                if ((bp->b_flag&BRET) != 0)
                     65:                        bpt_print('r', bp->b_badd, bp->b_rcom);
                     66:                if (testint())
                     67:                        return;
                     68:                if ((bp->b_flag&BSIN) != 0)
                     69:                        bpt_print('s', bp->b_badd, "");
                     70:        }
                     71: }
                     72: 
                     73: /*
                     74:  * Print a breakpoint address, type and command.
                     75:  */
                     76: void
                     77: bpt_print(t, addr, cmd) int t; ADDR_T addr; register char *cmd;
                     78: {
                     79:        register int c;
                     80: 
                     81:        printx(addr_fmt, addr);
                     82:        printx("%c (", t);
                     83:        putaddr(ISEG, addr);
                     84:        printx(") ");
                     85:        while ((c = *cmd++) != '\0') {
                     86:                if (c == '\n') {
                     87:                        printx("\\n");
                     88:                        continue;
                     89:                }
                     90:                if (c == '\\') {
                     91:                        printx("\\\\");
                     92:                        continue;
                     93:                }
                     94:                putx(c);
                     95:        }
                     96:        putx('\n');
                     97: }
                     98: 
                     99: /*
                    100:  * Set a breakpoint.
                    101:  */
                    102: int
                    103: bpt_set(f, addr, fp, cmd) int f; ADDR_T addr, fp; char *cmd;
                    104: {
                    105:        register BPT *bp;
                    106:        int bits;
                    107: 
                    108:        dbprintf(("bpt_set(%d, 0x%lX, 0x%lX, %s)\n", f, addr, fp, cmd));
                    109: 
                    110:        /* Make sure "addr" is a valid text address. */
                    111:        add = addr;
                    112:        if (getb(ISEG, (char *)&bits, sizeof(bits)) == 0)
                    113:                return 0;
                    114: 
                    115:        /* Look for existing breakpoint at same address. */
                    116:        for (bp = &bpt[0]; bp < &bpt[NBPT]; bp++)
                    117:                if (bp->b_flag && bp->b_badd == addr)
                    118:                        goto out;
                    119: 
                    120:        /* Look for unused breakpoint. */
                    121:        for (bp = &bpt[0]; bp < &bpt[NBPT]; bp++)
                    122:                if (bp->b_flag == 0)
                    123:                        goto out;
                    124:        return 0;
                    125: 
                    126: out:
                    127:        dbprintf(("setting bpt[%d]\n", bp - bpt));
                    128:        if (f != BBPT && (bp->b_flag&f) != 0)
                    129:                return 0;               /* already set, ignore */
                    130:        bp->b_flag |= f;
                    131:        bp->b_badd = addr;
                    132:        bp->b_bins[0] = bits & 0xFF;    /* store original contents */
                    133:        switch (f) {
                    134:        case BBPT:
                    135:                bp->b_bcom = save_cmd(bp->b_bcom, cmd);
                    136:                break;
                    137:        case BRET:
                    138:                bp->b_rfpt = fp;
                    139:                bp->b_rcom = save_cmd(bp->b_rcom, cmd);
                    140:                break;
                    141:        case BSIN:
                    142:                bp->b_sfpt = fp;
                    143:                break;
                    144:        }
                    145:        return 1;
                    146: }
                    147: 
                    148: /* end of db/db4.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.