Annotation of uae/src/debug.c, revision 1.1.1.9

1.1.1.3   root        1:  /*
1.1       root        2:   * UAE - The Un*x Amiga Emulator
1.1.1.3   root        3:   *
1.1       root        4:   * Debugger
1.1.1.3   root        5:   *
1.1       root        6:   * (c) 1995 Bernd Schmidt
1.1.1.3   root        7:   *
1.1       root        8:   */
                      9: 
                     10: #include "sysconfig.h"
                     11: #include "sysdeps.h"
                     12: 
                     13: #include <ctype.h>
                     14: #include <signal.h>
                     15: 
                     16: #include "config.h"
                     17: #include "options.h"
1.1.1.3   root       18: #include "threaddep/penguin.h"
                     19: #include "uae.h"
1.1       root       20: #include "memory.h"
                     21: #include "custom.h"
                     22: #include "newcpu.h"
                     23: #include "debug.h"
                     24: #include "cia.h"
                     25: #include "xwin.h"
                     26: #include "gui.h"
1.1.1.9 ! root       27: #include "identify.h"
1.1       root       28: 
                     29: static int debugger_active = 0;
1.1.1.3   root       30: static uaecptr skipaddr;
1.1       root       31: static int do_skip;
                     32: int debugging = 0;
                     33: 
1.1.1.7   root       34: static FILE *logfile;
                     35: 
1.1.1.4   root       36: void activate_debugger (void)
1.1       root       37: {
1.1.1.7   root       38:     if (logfile)
                     39:        fclose (logfile);
                     40:     logfile = 0;
1.1       root       41:     do_skip = 0;
                     42:     if (debugger_active)
                     43:        return;
                     44:     debugger_active = 1;
1.1.1.8   root       45:     set_special (SPCFLAG_BRK);
1.1       root       46:     debugging = 1;
1.1.1.5   root       47:     /* use_debugger = 1; */
1.1       root       48: }
                     49: 
                     50: int firsthist = 0;
                     51: int lasthist = 0;
                     52: #ifdef NEED_TO_DEBUG_BADLY
                     53: struct regstruct history[MAX_HIST];
                     54: union flagu historyf[MAX_HIST];
                     55: #else
1.1.1.3   root       56: uaecptr history[MAX_HIST];
1.1       root       57: #endif
                     58: 
1.1.1.4   root       59: static void ignore_ws (char **c)
1.1       root       60: {
                     61:     while (**c && isspace(**c)) (*c)++;
                     62: }
                     63: 
1.1.1.4   root       64: static uae_u32 readhex (char **c)
1.1       root       65: {
1.1.1.3   root       66:     uae_u32 val = 0;
1.1       root       67:     char nc;
                     68: 
1.1.1.4   root       69:     ignore_ws (c);
1.1.1.3   root       70: 
1.1.1.4   root       71:     while (isxdigit(nc = **c)) {
1.1       root       72:        (*c)++;
                     73:        val *= 16;
                     74:        nc = toupper(nc);
                     75:        if (isdigit(nc)) {
                     76:            val += nc - '0';
                     77:        } else {
                     78:            val += nc - 'A' + 10;
                     79:        }
                     80:     }
                     81:     return val;
                     82: }
                     83: 
1.1.1.9 ! root       84: static uae_u32 readint (char **c)
        !            85: {
        !            86:     uae_u32 val = 0;
        !            87:     char nc;
        !            88:     int negative = 0;
        !            89: 
        !            90:     ignore_ws (c);
        !            91: 
        !            92:     if (**c == '-')
        !            93:        negative = 1, (*c)++;
        !            94:     while (isdigit(nc = **c)) {
        !            95:        (*c)++;
        !            96:        val *= 10;
        !            97:        val += nc - '0';
        !            98:     }
        !            99:     return val * (negative ? -1 : 1);
        !           100: }
        !           101: 
1.1.1.4   root      102: static char next_char( char **c)
1.1       root      103: {
1.1.1.4   root      104:     ignore_ws (c);
1.1       root      105:     return *(*c)++;
                    106: }
                    107: 
1.1.1.4   root      108: static int more_params (char **c)
1.1       root      109: {
1.1.1.4   root      110:     ignore_ws (c);
1.1       root      111:     return (**c) != 0;
                    112: }
                    113: 
1.1.1.4   root      114: static void dumpmem (uaecptr addr, uaecptr *nxmem, int lines)
1.1       root      115: {
                    116:     broken_in = 0;
1.1.1.4   root      117:     for (;lines-- && !broken_in;) {
1.1       root      118:        int i;
1.1.1.4   root      119:        printf ("%08lx ", addr);
                    120:        for (i = 0; i < 16; i++) {
                    121:            printf ("%04x ", get_word(addr)); addr += 2;
1.1       root      122:        }
1.1.1.4   root      123:        printf ("\n");
1.1       root      124:     }
                    125:     *nxmem = addr;
                    126: }
                    127: 
1.1.1.3   root      128: static void foundmod (uae_u32 ptr, char *type)
1.1.1.2   root      129: {
1.1.1.3   root      130:     char name[21];
                    131:     uae_u8 *ptr2 = chipmemory + ptr;
                    132:     int i,length;
                    133: 
                    134:     printf ("Found possible %s module at 0x%lx.\n", type, ptr);
                    135:     memcpy (name, ptr2, 20);
                    136:     name[20] = '\0';
                    137: 
                    138:     /* Browse playlist */
                    139:     length = 0;
                    140:     for (i = 0x3b8; i < 0x438; i++)
                    141:        if (ptr2[i] > length)
                    142:            length = ptr2[i];
                    143: 
                    144:     length = (length+1)*1024 + 0x43c;
                    145: 
                    146:     /* Add sample lengths */
                    147:     ptr2 += 0x2A;
1.1.1.4   root      148:     for (i = 0; i < 31; i++, ptr2 += 30)
1.1.1.3   root      149:        length += 2*((ptr2[0]<<8)+ptr2[1]);
1.1.1.2   root      150:     
1.1.1.4   root      151:     printf ("Name \"%s\", Length 0x%lx bytes.\n", name, length);
1.1.1.3   root      152: }
                    153: 
1.1.1.4   root      154: static void modulesearch (void)
1.1.1.3   root      155: {
                    156:     uae_u8 *p = get_real_address (0);
                    157:     uae_u32 ptr;
                    158: 
1.1.1.4   root      159:     for (ptr = 0; ptr < allocated_chipmem - 40; ptr += 2, p += 2) {
1.1.1.2   root      160:        /* Check for Mahoney & Kaktus */
                    161:        /* Anyone got the format of old 15 Sample (SoundTracker)modules? */
1.1.1.3   root      162:        if (ptr >= 0x438 && p[0] == 'M' && p[1] == '.' && p[2] == 'K' && p[3] == '.')
                    163:            foundmod (ptr - 0x438, "ProTracker (31 samples)");
                    164: 
                    165:        if (ptr >= 0x438 && p[0] == 'F' && p[1] == 'L' && p[2] == 'T' && p[3] == '4')
                    166:            foundmod (ptr - 0x438, "Startrekker");
                    167: 
                    168:        if (strncmp ((char *)p, "SMOD", 4) == 0) {
                    169:            printf ("Found possible FutureComposer 1.3 module at 0x%lx, length unknown.\n", ptr);
                    170:        }
                    171:        if (strncmp ((char *)p, "FC14", 4) == 0) {
                    172:            printf ("Found possible FutureComposer 1.4 module at 0x%lx, length unknown.\n", ptr);
                    173:        }
                    174:        if (p[0] == 0x48 && p[1] == 0xe7 && p[4] == 0x61 && p[5] == 0
                    175:            && p[8] == 0x4c && p[9] == 0xdf && p[12] == 0x4e && p[13] == 0x75
                    176:            && p[14] == 0x48 && p[15] == 0xe7 && p[18] == 0x61 && p[19] == 0
                    177:            && p[22] == 0x4c && p[23] == 0xdf && p[26] == 0x4e && p[27] == 0x75) {
                    178:            printf ("Found possible Whittaker module at 0x%lx, length unknown.\n", ptr);
                    179:        }
                    180:        if (p[4] == 0x41 && p[5] == 0xFA) {
                    181:            int i;
                    182: 
                    183:            for (i = 0; i < 0x240; i += 2)
                    184:                if (p[i] == 0xE7 && p[i + 1] == 0x42 && p[i + 2] == 0x41 && p[i + 3] == 0xFA)
                    185:                    break;
                    186:            if (i < 0x240) {
                    187:                uae_u8 *p2 = p + i + 4;
                    188:                for (i = 0; i < 0x30; i += 2)
                    189:                    if (p2[i] == 0xD1 && p2[i + 1] == 0xFA) {
                    190:                        printf ("Found possible MarkII module at %lx, length unknown.\n", ptr);
                    191:                    }
                    192:            }
1.1.1.2   root      193:        }
                    194:     }
                    195: }
                    196: 
1.1.1.9 ! root      197: static void dump_traps (void)
        !           198: {
        !           199:     int i;
        !           200:     for (i = 0; trap_labels[i].name; i++) {
        !           201:        printf("$%02x: %s\t $%08x\n", trap_labels[i].adr,
        !           202:               trap_labels[i].name, get_long (trap_labels[i].adr));
        !           203:     }
        !           204: }
        !           205: 
        !           206: static void dump_ints (void)
        !           207: {
        !           208:     int i;     
        !           209:     for (i = 0; int_labels[i].name; i++) {
        !           210:        printf ("$%02x: %s\t $%08x\n", int_labels[i].adr,
        !           211:                int_labels[i].name, get_long (int_labels[i].adr));
        !           212:     }
        !           213: }
        !           214: 
        !           215: static void disassemble_wait (FILE *file, unsigned long insn)
        !           216: {
        !           217:     uae_u8 vp,hp,ve,he,bfd,v_mask,h_mask;
        !           218: 
        !           219:     vp = (insn & 0xff000000) >> 24;
        !           220:     hp = (insn & 0x00fe0000) >> 16;
        !           221:     ve = (insn & 0x00007f00) >> 8;
        !           222:     he = (insn & 0x000000fe);
        !           223:     bfd = insn & 0x00008000 >> 15;
        !           224: 
        !           225:     /* bit15 can never be masked out*/
        !           226:     v_mask = vp & (ve | 0x80);
        !           227:     h_mask = hp & he;
        !           228:     if (v_mask > 0) {
        !           229:        fprintf (file, "vpos ");
        !           230:        if (ve != 0x7f) {
        !           231:            fprintf (file, "& 0x%02x ", ve);
        !           232:        }
        !           233:        fprintf (file, ">= 0x%02x", v_mask);
        !           234:     }
        !           235:     if (he > 0) {
        !           236:        if (v_mask > 0) {
        !           237:            fprintf (file," and");
        !           238:        }
        !           239:        fprintf (file, " hpos ");
        !           240:        if (he != 0xfe) {
        !           241:            fprintf (file, "& 0x%02x ", he);
        !           242:        }
        !           243:        fprintf (file, ">= 0x%02x", h_mask);
        !           244:     } else {
        !           245:        fprintf (file, ", ignore horizontal");
        !           246:     }
        !           247: 
        !           248:     fprintf (file, ".\n                        \t; VP %02x, VE %02x; HP %02x, HE %02x; BFD %d\n",
        !           249:             vp, ve, hp, he, bfd);
        !           250: }
        !           251: 
        !           252: /* simple decode copper by Mark Cox */
        !           253: static void decode_copper_insn (FILE* file, unsigned long insn, unsigned long addr)
        !           254: {
        !           255:     uae_u32 insn_type = insn & 0x00010001;
        !           256:     int hpos, vpos;
        !           257:     char record[] = "          ";
        !           258:     if (find_copper_record (addr, &hpos, &vpos)) {
        !           259:        sprintf (record, " [%03x %03x]", vpos, hpos);
        !           260:     }
        !           261: 
        !           262:     fprintf (file, "%08lx: %04lx %04lx%s\t; ", addr, insn >> 16, insn & 0xFFFF, record);
        !           263: 
        !           264:     switch (insn_type) {
        !           265:     case 0x00010000: /* WAIT insn */
        !           266:        fprintf (file, "Wait for ");
        !           267:        disassemble_wait (file, insn);
        !           268: 
        !           269:        if (insn == 0xfffffffe)
        !           270:            fprintf (file, "                           \t; End of Copperlist\n");
        !           271: 
        !           272:        break;
        !           273: 
        !           274:     case 0x00010001: /* SKIP insn */
        !           275:        fprintf (file, "Skip if ");
        !           276:        disassemble_wait (file, insn);
        !           277:        break;
        !           278: 
        !           279:     case 0x00000000:
        !           280:     case 0x00000001: /* MOVE insn */
        !           281:        fprintf (file, "%s := 0x%04lx\n",
        !           282:                 custd[(insn & 0x01fe0000) >> 17].name,
        !           283:                 insn & 0x0000ffff);
        !           284: 
        !           285:        if ((insn & 0xfe000000) != 0) {
        !           286:            fprintf (file, "                        \t;OCS Compatibility warning: bits 15-9 should be 0 for compatibility with OCS\n");
        !           287:        }
        !           288:        /* 01fe0000 register destination address
        !           289:           fe000000 should be 0 for compatibility (at least in ocs
        !           290:           0000ffff data to be put in register destination */
        !           291:        break;
        !           292: 
        !           293:     default:
        !           294:        abort ();
        !           295:     }
        !           296: 
        !           297: }
        !           298: 
        !           299: 
        !           300: static uaecptr decode_copperlist (FILE* file, uaecptr address, int nolines)
        !           301: {
        !           302:     uae_u32 insn;
        !           303:     while (nolines-- > 0) {
        !           304:        insn = get_long (address);
        !           305:        decode_copper_insn (file, insn, address);
        !           306:        address += 4;
        !           307:     }
        !           308:     return address;
        !           309:     /* You may wonder why I don't stop this at the end of the copperlist?
        !           310:      * Well, often nice things are hidden at the end and it is debatable the actual 
        !           311:      * values that mean the end of the copperlist */
        !           312: }
        !           313: 
        !           314: 
1.1.1.4   root      315: /* cheat-search by Holger Jakob */
                    316: static void cheatsearch (char **c)
                    317: {
                    318:     uae_u8 *p = get_real_address (0);
                    319:     static uae_u32 *vlist = NULL;
                    320:     uae_u32 ptr;
                    321:     uae_u32 val = 0;
                    322:     uae_u32 type = 0; /* not yet */
                    323:     uae_u32 count = 0;
                    324:     uae_u32 fcount = 0;
                    325:     uae_u32 full = 0;
                    326:     char nc;
                    327: 
                    328:     ignore_ws (c);
                    329: 
                    330:     while (isxdigit (nc = **c)) {
                    331:        (*c)++;
                    332:        val *= 10;
                    333:        nc = toupper (nc);
                    334:        if (isdigit (nc)) {
                    335:            val += nc - '0';
                    336:        }
                    337:     }
                    338:     if (vlist == NULL) {
                    339:        vlist = malloc (256*4);
                    340:        if (vlist != 0) {
                    341:            for (count = 0; count<255; count++)
                    342:                vlist[count] = 0;
                    343:            count = 0;
                    344:            for (ptr = 0; ptr < allocated_chipmem - 40; ptr += 2, p += 2) {
                    345:                if (ptr >= 0x438 && p[3] == (val & 0xff)
                    346:                    && p[2] == (val >> 8 & 0xff)
                    347:                    && p[1] == (val >> 16 & 0xff)
                    348:                    && p[0] == (val >> 24 & 0xff))
                    349:                {
                    350:                    if (count < 255) {
                    351:                        vlist[count++]=ptr;
                    352:                        printf ("%08x: %x%x%x%x\n",ptr,p[0],p[1],p[2],p[3]);
                    353:                    } else
                    354:                        full = 1;
                    355:                }
                    356:            }
                    357:            printf ("Found %d possible addresses with %d\n",count,val);
                    358:            printf ("Now continue with 'g' and use 'C' with a different value\n");
                    359:        }
                    360:     } else {
                    361:        for (count = 0; count<255; count++) {
                    362:            if (p[vlist[count]+3] == (val & 0xff)
                    363:                && p[vlist[count]+2] == (val>>8 & 0xff) 
                    364:                && p[vlist[count]+1] == (val>>16 & 0xff)
                    365:                && p[vlist[count]] == (val>>24 & 0xff))
                    366:            {
                    367:                fcount++;
                    368:                printf ("%08x: %x%x%x%x\n", vlist[count], p[vlist[count]],
                    369:                        p[vlist[count]+1], p[vlist[count]+2], p[vlist[count]+3]);
                    370:            }
                    371:        }
                    372:        printf ("%d hits of %d found\n",fcount,val);
                    373:        free (vlist);
                    374:        vlist = NULL;
                    375:     }
                    376: }
                    377: 
                    378: static void writeintomem (char **c)
                    379: {
                    380:     uae_u8 *p = get_real_address (0);
                    381:     uae_u32 addr = 0;
                    382:     uae_u32 val = 0;
                    383:     char nc;
                    384: 
                    385:     ignore_ws(c);
                    386:     while (isxdigit(nc = **c)) {
                    387:        (*c)++;
                    388:        addr *= 16;
                    389:        nc = toupper(nc);
                    390:        if (isdigit(nc)) {
                    391:            addr += nc - '0';
                    392:        } else {
                    393:            addr += nc - 'A' + 10;
                    394:        }
                    395:     }
                    396:     ignore_ws(c);
                    397:     while (isxdigit(nc = **c)) {
                    398:        (*c)++;
                    399:        val *= 10;
                    400:        nc = toupper(nc);
                    401:        if (isdigit(nc)) {
                    402:            val += nc - '0';
                    403:        }
                    404:     }
                    405: 
                    406:     if (addr < allocated_chipmem) {
                    407:       p[addr] = val>>24 & 0xff;
                    408:       p[addr+1] = val>>16 & 0xff;
                    409:       p[addr+2] = val>>8 & 0xff;
                    410:       p[addr+3] = val & 0xff;
1.1.1.9 ! root      411:       printf ("Wrote %d at %08x\n",val,addr);
1.1.1.4   root      412:     } else
1.1.1.9 ! root      413:       printf ("Invalid address %08x\n",addr);
        !           414: }
        !           415: 
        !           416: static void show_exec_tasks (void)
        !           417: {
        !           418:     uaecptr execbase = get_long (4);
        !           419:     uaecptr taskready = get_long (execbase + 406);
        !           420:     uaecptr taskwait = get_long (execbase + 420);
        !           421:     uaecptr node, end;
        !           422:     printf ("execbase at 0x%08lx\n", (unsigned long) execbase);
        !           423:     printf ("Current:\n");
        !           424:     node = get_long (execbase + 276);
        !           425:     printf ("%08lx: %08lx %s\n", node, 0, get_real_address (get_long (node + 10)));
        !           426:     printf ("Ready:\n");
        !           427:     node = get_long (taskready);
        !           428:     end = get_long (taskready + 4);
        !           429:     while (node) {
        !           430:        printf ("%08lx: %08lx %s\n", node, 0, get_real_address (get_long (node + 10)));
        !           431:        node = get_long (node);
        !           432:     }
        !           433:     printf ("Waiting:\n");
        !           434:     node = get_long (taskwait);
        !           435:     end = get_long (taskwait + 4);
        !           436:     while (node) {
        !           437:        printf ("%08lx: %08lx %s\n", node, 0, get_real_address (get_long (node + 10)));
        !           438:        node = get_long (node);
        !           439:     }
1.1.1.4   root      440: }
1.1.1.7   root      441: 
1.1.1.8   root      442: static int trace_same_insn_count;
                    443: static uae_u8 trace_insn_copy[10];
                    444: static struct regstruct trace_prev_regs;
1.1.1.4   root      445: void debug (void)
1.1       root      446: {
1.1.1.4   root      447:     char input[80];
1.1.1.9 ! root      448:     uaecptr nextpc,nxdis,nxmem,nxcopper;
1.1       root      449: 
                    450:     bogusframe = 1;
1.1.1.3   root      451: 
1.1.1.7   root      452:     if (do_skip && skipaddr == 0xC0DEDBAD) {
1.1.1.8   root      453: #if 0
                    454:        if (trace_same_insn_count > 0) {
                    455:            if (memcmp (trace_insn_copy, regs.pc_p, 10) == 0
                    456:                && memcmp (trace_prev_regs.regs, regs.regs, sizeof regs.regs) == 0)
                    457:            {
                    458:                trace_same_insn_count++;
                    459:                return;
                    460:            }
                    461:        }
                    462:        if (trace_same_insn_count > 1)
                    463:            fprintf (logfile, "[ repeated %d times ]\n", trace_same_insn_count);
                    464: #endif
1.1.1.7   root      465:        m68k_dumpstate (logfile, &nextpc);
1.1.1.8   root      466:        trace_same_insn_count = 1;
                    467:        memcpy (trace_insn_copy, regs.pc_p, 10);
                    468:        memcpy (&trace_prev_regs, &regs, sizeof regs);
1.1.1.7   root      469:     }
                    470: 
1.1       root      471:     if (do_skip && (m68k_getpc() != skipaddr/* || regs.a[0] != 0x1e558*/)) {
1.1.1.8   root      472:        set_special (SPCFLAG_BRK);
1.1       root      473:        return;
                    474:     }
                    475:     do_skip = 0;
                    476: 
                    477: #ifdef NEED_TO_DEBUG_BADLY
                    478:     history[lasthist] = regs;
                    479:     historyf[lasthist] = regflags;
                    480: #else
                    481:     history[lasthist] = m68k_getpc();
                    482: #endif
                    483:     if (++lasthist == MAX_HIST) lasthist = 0;
                    484:     if (lasthist == firsthist) {
                    485:        if (++firsthist == MAX_HIST) firsthist = 0;
                    486:     }
                    487: 
1.1.1.7   root      488:     m68k_dumpstate (stdout, &nextpc);
1.1.1.9 ! root      489:     nxdis = nextpc; nxmem = nxcopper = 0;
1.1       root      490: 
1.1.1.4   root      491:     for (;;) {
                    492:        char cmd, *inptr;
1.1.1.3   root      493: 
1.1.1.4   root      494:        printf (">");
1.1.1.2   root      495:        fflush (stdout);
1.1.1.4   root      496:        if (fgets (input, 80, stdin) == 0)
1.1.1.2   root      497:            return;
1.1       root      498:        inptr = input;
1.1.1.4   root      499:        cmd = next_char (&inptr);
                    500:        switch (cmd) {
1.1.1.9 ! root      501:        case 'c': dumpcia (); dumpdisk (); dumpcustom (); break;
        !           502:        case 'i': dump_ints (); break;
        !           503:        case 'e': dump_traps (); break;
        !           504:        case 'r': m68k_dumpstate (stdout, &nextpc); break;
        !           505:        case 'M': modulesearch (); break;
        !           506:        case 'C': cheatsearch (&inptr); break; 
        !           507:        case 'W': writeintomem (&inptr); break;
        !           508:        case 'S':
        !           509:        {
        !           510:            uae_u8 *memp;
        !           511:            uae_u32 src, len;
        !           512:            char *name;
        !           513:            FILE *fp;
        !           514: 
        !           515:            if (!more_params (&inptr))
        !           516:                goto S_argh;
1.1.1.3   root      517: 
1.1.1.9 ! root      518:            name = inptr;
        !           519:            while (*inptr != '\0' && !isspace (*inptr))
1.1.1.3   root      520:                inptr++;
1.1.1.9 ! root      521:            if (!isspace (*inptr))
        !           522:                goto S_argh;
1.1.1.3   root      523: 
1.1.1.9 ! root      524:            *inptr = '\0';
        !           525:            inptr++;
        !           526:            if (!more_params (&inptr))
        !           527:                goto S_argh;
        !           528:            src = readhex (&inptr);
        !           529:            if (!more_params (&inptr))
        !           530:                goto S_argh;
        !           531:            len = readhex (&inptr);
        !           532:            if (! valid_address (src, len)) {
        !           533:                printf ("Invalid memory block\n");
1.1.1.3   root      534:                break;
                    535:            }
1.1.1.9 ! root      536:            memp = get_real_address (src);
        !           537:            fp = fopen (name, "w");
        !           538:            if (fp == NULL) {
        !           539:                printf ("Couldn't open file\n");
        !           540:                break;
1.1       root      541:            }
1.1.1.9 ! root      542:            if (fwrite (memp, 1, len, fp) != len) {
        !           543:                printf ("Error writing file\n");
        !           544:            }
        !           545:            fclose (fp);
        !           546:            break;
        !           547: 
        !           548:          S_argh:
        !           549:            printf ("S command needs more arguments!\n");
1.1       root      550:            break;
1.1.1.9 ! root      551:        }
        !           552:        case 'd':
        !           553:        {
        !           554:            uae_u32 daddr;
        !           555:            int count;
        !           556: 
        !           557:            if (more_params(&inptr))
        !           558:                daddr = readhex(&inptr);
        !           559:            else
        !           560:                daddr = nxdis;
        !           561:            if (more_params(&inptr))
        !           562:                count = readhex(&inptr);
        !           563:            else
        !           564:                count = 10;
        !           565:            m68k_disasm (stdout, daddr, &nxdis, count);
        !           566:        }
        !           567:        break;
        !           568:        case 'T': show_exec_tasks (); break;
        !           569:        case 't': set_special (SPCFLAG_BRK); return;
        !           570:        case 'z':
1.1       root      571:            skipaddr = nextpc;
                    572:            do_skip = 1;
1.1.1.8   root      573:            set_special (SPCFLAG_BRK);
1.1       root      574:            return;
                    575: 
1.1.1.9 ! root      576:        case 'f':
1.1.1.7   root      577:            skipaddr = readhex (&inptr);
1.1       root      578:            do_skip = 1;
1.1.1.8   root      579:            set_special (SPCFLAG_BRK);
                    580:            if (skipaddr == 0xC0DEDBAD) {
                    581:                trace_same_insn_count = 0;
1.1.1.7   root      582:                logfile = fopen ("uae.trace", "w");
1.1.1.8   root      583:                memcpy (trace_insn_copy, regs.pc_p, 10);
                    584:                memcpy (&trace_prev_regs, &regs, sizeof regs);
                    585:            }
1.1       root      586:            return;
                    587: 
1.1.1.9 ! root      588:        case 'q': uae_quit();
1.1.1.3   root      589:            debugger_active = 0;
                    590:            debugging = 0;
                    591:            return;
                    592: 
1.1.1.9 ! root      593:        case 'g':
1.1       root      594:            if (more_params (&inptr))
                    595:                m68k_setpc (readhex (&inptr));
1.1.1.3   root      596:            fill_prefetch_0 ();
1.1       root      597:            debugger_active = 0;
                    598:            debugging = 0;
                    599:            return;
                    600: 
1.1.1.9 ! root      601:        case 'H':
        !           602:        {
        !           603:            int count;
        !           604:            int temp;
1.1       root      605: #ifdef NEED_TO_DEBUG_BADLY
1.1.1.9 ! root      606:            struct regstruct save_regs = regs;
        !           607:            union flagu save_flags = regflags;
1.1       root      608: #endif
                    609: 
1.1.1.9 ! root      610:            if (more_params(&inptr))
        !           611:                count = readhex(&inptr);
        !           612:            else
        !           613:                count = 10;
        !           614:            if (count < 0)
        !           615:                break;
        !           616:            temp = lasthist;
        !           617:            while (count-- > 0 && temp != firsthist) {
        !           618:                if (temp == 0) temp = MAX_HIST-1; else temp--;
        !           619:            }
        !           620:            while (temp != lasthist) {
1.1       root      621: #ifdef NEED_TO_DEBUG_BADLY
1.1.1.9 ! root      622:                regs = history[temp];
        !           623:                regflags = historyf[temp];
        !           624:                m68k_dumpstate (NULL);
1.1       root      625: #else
1.1.1.9 ! root      626:                m68k_disasm (stdout, history[temp], NULL, 1);
1.1       root      627: #endif
1.1.1.9 ! root      628:                if (++temp == MAX_HIST) temp = 0;
        !           629:            }
1.1       root      630: #ifdef NEED_TO_DEBUG_BADLY
1.1.1.9 ! root      631:            regs = save_regs;
        !           632:            regflags = save_flags;
1.1       root      633: #endif
1.1.1.9 ! root      634:        }
        !           635:        break;
        !           636:        case 'm':
        !           637:        {
        !           638:            uae_u32 maddr; int lines;
        !           639:            if (more_params(&inptr))
        !           640:                maddr = readhex(&inptr);
        !           641:            else
        !           642:                maddr = nxmem;
        !           643:            if (more_params(&inptr))
        !           644:                lines = readhex(&inptr);
        !           645:            else
        !           646:                lines = 16;
        !           647:            dumpmem(maddr, &nxmem, lines);
        !           648:        }
        !           649:        break;
        !           650:        case 'o':
        !           651:        {
        !           652:            uae_u32 maddr;
        !           653:            int lines;
        !           654:  
        !           655:            if (more_params(&inptr)) {
        !           656:                maddr = readhex(&inptr);
        !           657:                if (maddr == 1 || maddr == 2)
        !           658:                    maddr = get_copper_address (maddr);         
1.1       root      659:            }
1.1.1.9 ! root      660:            else
        !           661:                maddr = nxcopper;
        !           662: 
        !           663:            if (more_params (&inptr))
        !           664:                lines = readhex (&inptr);
        !           665:            else
        !           666:                lines = 10;
        !           667: 
        !           668:            nxcopper = decode_copperlist (stdout, maddr, lines);
1.1       root      669:            break;
1.1.1.9 ! root      670:        }
        !           671:        case 'O':
        !           672:            if (more_params (&inptr)) {
        !           673:                int plane = readint (&inptr);
        !           674:                int offs = readint (&inptr);
        !           675:                if (plane >= 0 && plane < 8)
        !           676:                    bploff[plane] = offs;
        !           677:            } else {
        !           678:                int i;
        !           679:                for (i = 0; i < 8; i++)
        !           680:                    printf ("Plane %d offset %d\n", i, bploff[i]);
1.1.1.3   root      681:            }
                    682:            break;
1.1.1.9 ! root      683:        case 'h':
        !           684:        case '?':
        !           685:        {
        !           686:            printf ("          HELP for UAE Debugger\n");
        !           687:            printf ("         -----------------------\n\n");
        !           688:            printf ("  g: <address>          Start execution at the current address or <address>\n");
        !           689:            printf ("  c:                    Dump state of the CIA and custom chips\n");
        !           690:            printf ("  r:                    Dump state of the CPU\n");
        !           691:            printf ("  m <address> <lines>:  Memory dump starting at <address>\n");
        !           692:            printf ("  d <address> <lines>:  Disassembly starting at <address>\n");
        !           693:            printf ("  t:                    Step one instruction\n");
        !           694:            printf ("  z:                    Step through one instruction - useful for JSR, DBRA etc\n");
        !           695:            printf ("  f <address>:          Step forward until PC == <address>\n");
        !           696:            printf ("  i:                    Dump contents of interrupt registers\n");
        !           697:            printf ("  e:                    Dump contents of trap vectors\n");
        !           698:            printf ("  o <1|2|addr> <lines>: View memory as Copper Instructions\n");
        !           699:            printf ("  O:                    Display bitplane offsets\n");
        !           700:            printf ("  O <plane> <offset>:   Offset a bitplane\n");
        !           701:            printf ("  H <count>:            Show PC history <count> instructions\n");
        !           702:            printf ("  M:                    Search for *Tracker sound modules\n");
        !           703:            printf ("  C <value>:            Search for values like energy or lifes in games\n");
        !           704:            printf ("  W <address> <value>:  Write into Amiga memory\n");
        !           705:            printf ("  S <file> <addr> <n>:  Save a block of Amiga memory\n");
        !           706:            printf ("  T:                    Show exec tasks and their PCs\n");
        !           707:            printf ("  h,?:                  Show this help page\n");
        !           708:            printf ("  q:                    Quit the emulator. You don't want to use this command.\n\n");
        !           709:        }
        !           710:        break;
1.1       root      711:        }
                    712:     }
                    713: }

unix.superglobalmegacorp.com

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