Mercurial > repos > blastem
comparison debug.c @ 566:624dd5106060
Add backtrace (bt) command to 68K debugger
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 02 Mar 2014 14:41:43 -0800 |
parents | 9324f721efa6 |
children | f822d9216968 |
comparison
equal
deleted
inserted
replaced
565:9324f721efa6 | 566:624dd5106060 |
---|---|
529 case 'c': | 529 case 'c': |
530 puts("Continuing"); | 530 puts("Continuing"); |
531 debugging = 0; | 531 debugging = 0; |
532 break; | 532 break; |
533 case 'b': | 533 case 'b': |
534 param = find_param(input_buf); | 534 if (input_buf[1] == 't') { |
535 if (!param) { | 535 uint32_t stack = context->aregs[7]; |
536 fputs("b command requires a parameter\n", stderr); | 536 if (stack >= 0xE00000) { |
537 break; | 537 stack &= 0xFFFF; |
538 } | 538 uint8_t non_adr_count = 0; |
539 value = strtol(param, NULL, 16); | 539 do { |
540 insert_breakpoint(context, value, (uint8_t *)debugger); | 540 uint32_t bt_address = ram[stack/2] << 16 | ram[stack/2+1]; |
541 new_bp = malloc(sizeof(bp_def)); | 541 bt_address = get_instruction_start(context->native_code_map, bt_address - 2); |
542 new_bp->next = breakpoints; | 542 if (bt_address) { |
543 new_bp->address = value; | 543 stack += 4; |
544 new_bp->index = bp_index++; | 544 non_adr_count = 0; |
545 breakpoints = new_bp; | 545 uint16_t *bt_pc = NULL; |
546 printf("68K Breakpoint %d set at %X\n", new_bp->index, value); | 546 if (bt_address < 0x400000) { |
547 bt_pc = cart + bt_address/2; | |
548 } else if(bt_address > 0xE00000) { | |
549 bt_pc = ram + (bt_address & 0xFFFF)/2; | |
550 } | |
551 m68k_decode(bt_pc, &inst, bt_address); | |
552 m68k_disasm(&inst, input_buf); | |
553 printf("%X: %s\n", bt_address, input_buf); | |
554 } else { | |
555 //non-return address value on stack can be word wide | |
556 stack += 2; | |
557 non_adr_count++; | |
558 } | |
559 stack &= 0xFFFF; | |
560 } while (stack && non_adr_count < 6); | |
561 } | |
562 } else { | |
563 param = find_param(input_buf); | |
564 if (!param) { | |
565 fputs("b command requires a parameter\n", stderr); | |
566 break; | |
567 } | |
568 value = strtol(param, NULL, 16); | |
569 insert_breakpoint(context, value, (uint8_t *)debugger); | |
570 new_bp = malloc(sizeof(bp_def)); | |
571 new_bp->next = breakpoints; | |
572 new_bp->address = value; | |
573 new_bp->index = bp_index++; | |
574 breakpoints = new_bp; | |
575 printf("68K Breakpoint %d set at %X\n", new_bp->index, value); | |
576 } | |
547 break; | 577 break; |
548 case 'a': | 578 case 'a': |
549 param = find_param(input_buf); | 579 param = find_param(input_buf); |
550 if (!param) { | 580 if (!param) { |
551 fputs("a command requires a parameter\n", stderr); | 581 fputs("a command requires a parameter\n", stderr); |