Annotation of uae/debug.c, revision 1.1.1.1

1.1       root        1:  /* 
                      2:   * UAE - The Un*x Amiga Emulator
                      3:   * 
                      4:   * Debugger
                      5:   * 
                      6:   * (c) 1995 Bernd Schmidt
                      7:   * 
                      8:   */
                      9: 
                     10: #include <ctype.h>
                     11: #include <stdio.h>
                     12: #include <stdlib.h>
                     13: #include <signal.h>
                     14: 
                     15: #include "config.h"
                     16: #include "amiga.h"
                     17: #include "options.h"
                     18: #include "debug.h"
                     19: #include "memory.h"
                     20: #include "custom.h"
                     21: #include "newcpu.h"
                     22: #include "cia.h"
                     23: #include "xwin.h"
                     24: 
                     25: #ifdef __cplusplus
                     26: static void sigbrkhandler(...)
                     27: #else
                     28: static void sigbrkhandler(int foo)
                     29: #endif
                     30: {
                     31:     broken_in = true;
                     32:     specialflags |= SPCFLAG_BRK;
                     33:     signal(SIGINT, sigbrkhandler);
                     34: }
                     35: 
                     36: static void ignore_ws(char **c)
                     37: {
                     38:     while (**c && isspace(**c)) (*c)++;
                     39: }
                     40: 
                     41: static ULONG readhex(char **c)
                     42: {
                     43:     ULONG val = 0;
                     44:     char nc;
                     45: 
                     46:     ignore_ws(c);
                     47:     
                     48:     while (isxdigit(nc = **c)){
                     49:        (*c)++;
                     50:        val *= 16;
                     51:        nc = toupper(nc);
                     52:        if (isdigit(nc)) {
                     53:            val += nc - '0';
                     54:        } else {
                     55:            val += nc - 'A' + 10;
                     56:        }
                     57:     }
                     58:     return val;
                     59: }
                     60: 
                     61: static char next_char(char **c)
                     62: {
                     63:     ignore_ws(c);
                     64:     return *(*c)++;
                     65: }
                     66: 
                     67: static bool more_params(char **c)
                     68: {
                     69:     ignore_ws(c);
                     70:     return (**c) != 0;
                     71: }
                     72: 
                     73: static void dumpmem(CPTR addr, CPTR *nxmem, int lines)
                     74: {
                     75:     broken_in = false;
                     76:     for (;lines-- && !broken_in;){
                     77:        int i;
                     78:        printf("%08lx ", addr);
                     79:        for(i=0; i< 16; i++) {
                     80:            printf("%04x ", get_word(addr)); addr += 2;
                     81:        }
                     82:        printf("\n");
                     83:     }
                     84:     *nxmem = addr;
                     85: }
                     86: 
                     87: void debug(void)
                     88: {
                     89:     char input[80],c;
                     90:     CPTR nextpc,nxdis,nxmem;
                     91:     
                     92:     if (debuggable())
                     93:        signal(SIGINT, sigbrkhandler);
                     94:     
                     95:     if (!debuggable() || !use_debugger) {
                     96:        MC68000_run();
                     97:        if (!debuggable()) {        
                     98:            dumpcustom();
                     99:            return;
                    100:        }
                    101:     }
                    102:     printf("debugging...\n");
                    103:     MC68000_dumpstate(&nextpc);
                    104:     nxdis = nextpc; nxmem = 0;
                    105:     for(;;){
                    106:        char cmd,*inptr;
                    107:        
                    108:        bogusframe = true;
                    109:        printf(">");
                    110:        fgets(input, 80, stdin);
                    111:        inptr = input;
                    112:        cmd = next_char(&inptr);
                    113:        switch(cmd){
                    114:         case 'q': 
                    115:            return;
                    116:         case 'c':
                    117:            dumpcia(); dumpcustom(); 
                    118:            break;
                    119:         case 'r':
                    120:            MC68000_dumpstate(&nextpc);
                    121:            break;
                    122:         case 'd': 
                    123:            {
                    124:                ULONG daddr;
                    125:                int count;
                    126:                
                    127:                if (more_params(&inptr))
                    128:                    daddr = readhex(&inptr);
                    129:                else 
                    130:                    daddr = nxdis;
                    131:                if (more_params(&inptr))
                    132:                    count = readhex(&inptr); 
                    133:                else
                    134:                    count = 10;
                    135:                MC68000_disasm(daddr, &nxdis, count);
                    136:            }
                    137:            break;
                    138:         case 't': 
                    139:            MC68000_step(); 
                    140:            MC68000_dumpstate(&nextpc); 
                    141:            break;
                    142:         case 'z': 
                    143:            MC68000_skip(nextpc);
                    144:            MC68000_dumpstate(&nextpc);
                    145:            nxdis = nextpc; 
                    146:            break;
                    147:         case 'f': 
                    148:            MC68000_skip(readhex(&inptr));
                    149:            MC68000_dumpstate(&nextpc); 
                    150:            break;
                    151:         case 'g':
                    152:            if (more_params (&inptr))
                    153:                m68k_setpc (readhex (&inptr));
                    154:            MC68000_run();
                    155:            MC68000_dumpstate(&nextpc);
                    156:            break;
                    157:         case 'm':
                    158:            {
                    159:                ULONG maddr; int lines;
                    160:                if (more_params(&inptr))
                    161:                    maddr = readhex(&inptr); 
                    162:                else 
                    163:                    maddr = nxmem;
                    164:                if (more_params(&inptr))
                    165:                    lines = readhex(&inptr); 
                    166:                else 
                    167:                    lines = 16;
                    168:                dumpmem(maddr, &nxmem, lines);
                    169:            }
                    170:            break;
                    171:        }
                    172:     }
                    173: }

unix.superglobalmegacorp.com

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