comparison m68k_core.c @ 2400:c97609fe8315

Implement watchpoints in Z80 debugger
author Michael Pavone <pavone@retrodev.com>
date Sat, 23 Dec 2023 23:03:31 -0800
parents 68eba54b60f7
children b733a10488c6
comparison
equal deleted inserted replaced
2399:68eba54b60f7 2400:c97609fe8315
921 context->options->write_8 = new_write8; 921 context->options->write_8 = new_write8;
922 } 922 }
923 923
924 void m68k_add_watchpoint(m68k_context *context, uint32_t address, uint32_t size) 924 void m68k_add_watchpoint(m68k_context *context, uint32_t address, uint32_t size)
925 { 925 {
926 uint32_t end = address + size; 926 uint32_t end = address + size - 1;
927 for (uint32_t i = 0; i < context->num_watchpoints; i++) 927 for (uint32_t i = 0; i < context->num_watchpoints; i++)
928 { 928 {
929 if (context->watchpoints[i].start == address && context->watchpoints[i].end == end) { 929 if (context->watchpoints[i].start == address && context->watchpoints[i].end == end) {
930 return; 930 return;
931 } 931 }
942 .check_change = chunk && (chunk->flags & MMAP_READ) 942 .check_change = chunk && (chunk->flags & MMAP_READ)
943 }; 943 };
944 if (context->watchpoint_min > address) { 944 if (context->watchpoint_min > address) {
945 context->watchpoint_min = address; 945 context->watchpoint_min = address;
946 } 946 }
947 if (context->watchpoint_max < address + size) { 947 if (context->watchpoint_max < end) {
948 context->watchpoint_max = address + size; 948 context->watchpoint_max = end;
949 } 949 }
950 } 950 }
951 951
952 void m68k_remove_watchpoint(m68k_context *context, uint32_t address, uint32_t size) 952 void m68k_remove_watchpoint(m68k_context *context, uint32_t address, uint32_t size)
953 { 953 {
954 uint32_t end = address + size; 954 uint32_t end = address + size - 1;
955 for (uint32_t i = 0; i < context->num_watchpoints; i++) 955 for (uint32_t i = 0; i < context->num_watchpoints; i++)
956 { 956 {
957 if (context->watchpoints[i].start == address && context->watchpoints[i].end == end) { 957 if (context->watchpoints[i].start == address && context->watchpoints[i].end == end) {
958 context->watchpoints[i] = context->watchpoints[context->num_watchpoints-1]; 958 context->watchpoints[i] = context->watchpoints[context->num_watchpoints-1];
959 context->num_watchpoints--; 959 context->num_watchpoints--;