Mercurial > repos > blastem
comparison debug.c @ 2386:9f178feb3cb0
Prefix most hex-formatted values output by debugger with $ for consistency with number literal parsing
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 21 Nov 2023 21:35:14 -0800 |
parents | 1b21290358a8 |
children | 5f4917b9ecfa |
comparison
equal
deleted
inserted
replaced
2385:ce9f5a42c481 | 2386:9f178feb3cb0 |
---|---|
1421 m68k_context *context = root->cpu_context; | 1421 m68k_context *context = root->cpu_context; |
1422 if (size == 'b') { | 1422 if (size == 'b') { |
1423 *out = m68k_read_byte(*out, context); | 1423 *out = m68k_read_byte(*out, context); |
1424 } else if (size == 'l') { | 1424 } else if (size == 'l') { |
1425 if (*out & 1) { | 1425 if (*out & 1) { |
1426 fprintf(stderr, "Longword access to odd addresses (%X) is not allowed\n", *out); | 1426 fprintf(stderr, "Longword access to odd addresses ($%X) is not allowed\n", *out); |
1427 return 0; | 1427 return 0; |
1428 } | 1428 } |
1429 *out = m68k_read_long(*out, context); | 1429 *out = m68k_read_long(*out, context); |
1430 } else { | 1430 } else { |
1431 if (*out & 1) { | 1431 if (*out & 1) { |
1432 fprintf(stderr, "Wword access to odd addresses (%X) is not allowed\n", *out); | 1432 fprintf(stderr, "Wword access to odd addresses ($%X) is not allowed\n", *out); |
1433 return 0; | 1433 return 0; |
1434 } | 1434 } |
1435 *out = m68k_read_word(*out, context); | 1435 *out = m68k_read_word(*out, context); |
1436 } | 1436 } |
1437 return 1; | 1437 return 1; |
1442 m68k_context *context = root->cpu_context; | 1442 m68k_context *context = root->cpu_context; |
1443 if (size == 'b') { | 1443 if (size == 'b') { |
1444 write_byte(address, value, (void **)context->mem_pointers, &context->options->gen, context); | 1444 write_byte(address, value, (void **)context->mem_pointers, &context->options->gen, context); |
1445 } else if (size == 'l') { | 1445 } else if (size == 'l') { |
1446 if (address & 1) { | 1446 if (address & 1) { |
1447 fprintf(stderr, "Longword access to odd addresses (%X) is not allowed\n", address); | 1447 fprintf(stderr, "Longword access to odd addresses ($%X) is not allowed\n", address); |
1448 return 0; | 1448 return 0; |
1449 } | 1449 } |
1450 write_word(address, value >> 16, (void **)context->mem_pointers, &context->options->gen, context); | 1450 write_word(address, value >> 16, (void **)context->mem_pointers, &context->options->gen, context); |
1451 write_word(address + 2, value, (void **)context->mem_pointers, &context->options->gen, context); | 1451 write_word(address + 2, value, (void **)context->mem_pointers, &context->options->gen, context); |
1452 } else { | 1452 } else { |
1453 if (address & 1) { | 1453 if (address & 1) { |
1454 fprintf(stderr, "Wword access to odd addresses (%X) is not allowed\n", address); | 1454 fprintf(stderr, "Wword access to odd addresses ($%X) is not allowed\n", address); |
1455 return 0; | 1455 return 0; |
1456 } | 1456 } |
1457 write_word(address, value, (void **)context->mem_pointers, &context->options->gen, context); | 1457 write_word(address, value, (void **)context->mem_pointers, &context->options->gen, context); |
1458 } | 1458 } |
1459 return 1; | 1459 return 1; |
2743 if (!array->set) { | 2743 if (!array->set) { |
2744 fprintf(stderr, "Array %s is read-only\n", set_expr->right->op.v.str); | 2744 fprintf(stderr, "Array %s is read-only\n", set_expr->right->op.v.str); |
2745 return 1; | 2745 return 1; |
2746 } | 2746 } |
2747 if (address.v.u32 >= array->size) { | 2747 if (address.v.u32 >= array->size) { |
2748 fprintf(stderr, "Address %X is out of bounds for array %s\n", address.v.u32, set_expr->right->op.v.str); | 2748 fprintf(stderr, "Address $%X is out of bounds for array %s\n", address.v.u32, set_expr->right->op.v.str); |
2749 return 1; | 2749 return 1; |
2750 } | 2750 } |
2751 } | 2751 } |
2752 break; | 2752 break; |
2753 default: | 2753 default: |
2783 } | 2783 } |
2784 var->set(var, value); | 2784 var->set(var, value); |
2785 } else if (array) { | 2785 } else if (array) { |
2786 array->set(array, address.v.u32, value); | 2786 array->set(array, address.v.u32, value); |
2787 } else if (!root->write_mem(root, address.v.u32, value.v.u32, size)) { | 2787 } else if (!root->write_mem(root, address.v.u32, value.v.u32, size)) { |
2788 fprintf(stderr, "Failed to write to address %X\n", address.v.u32); | 2788 fprintf(stderr, "Failed to write to address $%X\n", address.v.u32); |
2789 } | 2789 } |
2790 return 1; | 2790 return 1; |
2791 } | 2791 } |
2792 | 2792 |
2793 static uint8_t cmd_variable(debug_root *root, parsed_command *cmd) | 2793 static uint8_t cmd_variable(debug_root *root, parsed_command *cmd) |
2963 while (len < *padding) | 2963 while (len < *padding) |
2964 { | 2964 { |
2965 putchar(' '); | 2965 putchar(' '); |
2966 len++; | 2966 len++; |
2967 } | 2967 } |
2968 printf("%X\n", (uint32_t)val.intval); | 2968 printf("$%X\n", (uint32_t)val.intval); |
2969 } | 2969 } |
2970 | 2970 |
2971 static uint8_t cmd_symbols(debug_root *root, parsed_command *cmd) | 2971 static uint8_t cmd_symbols(debug_root *root, parsed_command *cmd) |
2972 { | 2972 { |
2973 char *filename = cmd->raw ? strip_ws(cmd->raw) : NULL; | 2973 char *filename = cmd->raw ? strip_ws(cmd->raw) : NULL; |
3043 new_bp->address = address; | 3043 new_bp->address = address; |
3044 new_bp->mask = 0xFFFFFF; | 3044 new_bp->mask = 0xFFFFFF; |
3045 new_bp->index = root->bp_index++; | 3045 new_bp->index = root->bp_index++; |
3046 new_bp->type = BP_TYPE_CPU; | 3046 new_bp->type = BP_TYPE_CPU; |
3047 root->breakpoints = new_bp; | 3047 root->breakpoints = new_bp; |
3048 printf("68K Breakpoint %d set at %X\n", new_bp->index, address); | 3048 printf("68K Breakpoint %d set at $%X\n", new_bp->index, address); |
3049 return 1; | 3049 return 1; |
3050 } | 3050 } |
3051 | 3051 |
3052 static void on_vdp_reg_write(vdp_context *context, uint16_t reg, uint16_t value) | 3052 static void on_vdp_reg_write(vdp_context *context, uint16_t reg, uint16_t value) |
3053 { | 3053 { |
3075 for (uint32_t i = 0; debugging && i < (*this_bp)->num_commands; i++) | 3075 for (uint32_t i = 0; debugging && i < (*this_bp)->num_commands; i++) |
3076 { | 3076 { |
3077 debugging = run_command(root, (*this_bp)->commands + i); | 3077 debugging = run_command(root, (*this_bp)->commands + i); |
3078 } | 3078 } |
3079 if (debugging) { | 3079 if (debugging) { |
3080 printf("VDP Register Breakpoint %d hit on register write %X - Old: %X, New: %X\n", (*this_bp)->index, reg, context->regs[reg], value); | 3080 printf("VDP Register Breakpoint %d hit on register write $%X - Old: $%X, New: $%X\n", (*this_bp)->index, reg, context->regs[reg], value); |
3081 gen->header.enter_debugger = 1; | 3081 gen->header.enter_debugger = 1; |
3082 if (gen->m68k->sync_cycle > gen->m68k->current_cycle + 1) { | 3082 if (gen->m68k->sync_cycle > gen->m68k->current_cycle + 1) { |
3083 gen->m68k->sync_cycle = gen->m68k->current_cycle + 1; | 3083 gen->m68k->sync_cycle = gen->m68k->current_cycle + 1; |
3084 } | 3084 } |
3085 if (gen->m68k->target_cycle > gen->m68k->sync_cycle) { | 3085 if (gen->m68k->target_cycle > gen->m68k->sync_cycle) { |
3874 new_bp->address = address; | 3874 new_bp->address = address; |
3875 new_bp->mask = 0xFFFF; | 3875 new_bp->mask = 0xFFFF; |
3876 new_bp->type = BP_TYPE_CPU; | 3876 new_bp->type = BP_TYPE_CPU; |
3877 new_bp->index = root->bp_index++; | 3877 new_bp->index = root->bp_index++; |
3878 root->breakpoints = new_bp; | 3878 root->breakpoints = new_bp; |
3879 printf("Z80 Breakpoint %d set at %X\n", new_bp->index, address); | 3879 printf("Z80 Breakpoint %d set at $%X\n", new_bp->index, address); |
3880 return 1; | 3880 return 1; |
3881 } | 3881 } |
3882 | 3882 |
3883 static uint8_t cmd_advance_z80(debug_root *root, parsed_command *cmd) | 3883 static uint8_t cmd_advance_z80(debug_root *root, parsed_command *cmd) |
3884 { | 3884 { |