Skip to content

Commit

Permalink
make remote monitor not return checkpoints more than once, patch #354…
Browse files Browse the repository at this point in the history
… by Andreas Signer

git-svn-id: https://svn.code.sf.net/p/vice-emu/code/trunk@44790 379a1393-f5fb-40a0-bcee-ef074d9b53f7
  • Loading branch information
mrdudz committed Nov 26, 2023
1 parent f20e97d commit 31b2f48
Showing 1 changed file with 18 additions and 66 deletions.
84 changes: 18 additions & 66 deletions vice/src/monitor/mon_breakpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct checkpoint_list_s {
typedef struct checkpoint_list_s checkpoint_list_t;

static int breakpoint_count;
static checkpoint_list_t *all_checkpoints;
static checkpoint_list_t *breakpoints[NUM_MEMSPACES];
static checkpoint_list_t *watchpoints_load[NUM_MEMSPACES];
static checkpoint_list_t *watchpoints_store[NUM_MEMSPACES];
Expand Down Expand Up @@ -102,58 +103,26 @@ static void remove_checkpoint_from_list(checkpoint_list_t **head, mon_checkpoint
*/
mon_checkpoint_t **mon_breakpoint_checkpoint_list_get(unsigned int *len) {
checkpoint_list_t *ptr;
int i;
mon_checkpoint_t **concat;

*len = 0;

for (i = FIRST_SPACE; i <= LAST_SPACE; i++) {
ptr = breakpoints[i];
while (ptr) {
++*len;
ptr = ptr->next;
}

ptr = watchpoints_load[i];
while (ptr) {
++*len;
ptr = ptr->next;
}

ptr = watchpoints_store[i];
while (ptr) {
++*len;
ptr = ptr->next;
}
ptr = all_checkpoints;
while (ptr) {
++*len;
ptr = ptr->next;
}

concat = lib_malloc(sizeof(mon_checkpoint_t *) * *len);

*len = -1;

for (i = FIRST_SPACE; i <= LAST_SPACE; i++) {
ptr = breakpoints[i];
while (ptr) {
++*len;
concat[*len] = ptr->checkpt;
ptr = ptr->next;
}

ptr = watchpoints_load[i];
while (ptr) {
++*len;
concat[*len] = ptr->checkpt;
ptr = ptr->next;
}

ptr = watchpoints_store[i];
while (ptr) {
++*len;
concat[*len] = ptr->checkpt;
ptr = ptr->next;
}
ptr = all_checkpoints;
while (ptr) {
++*len;
concat[*len] = ptr->checkpt;
ptr = ptr->next;
}

++*len;

return concat;
Expand All @@ -168,34 +137,14 @@ mon_checkpoint_t **mon_breakpoint_checkpoint_list_get(unsigned int *len) {
mon_checkpoint_t *mon_breakpoint_find_checkpoint(int brknum)
{
checkpoint_list_t *ptr;
int i;

for (i = FIRST_SPACE; i <= LAST_SPACE; i++) {
ptr = breakpoints[i];
while (ptr) {
if (ptr->checkpt->checknum == brknum) {
return ptr->checkpt;
}
ptr = ptr->next;
}

ptr = watchpoints_load[i];
while (ptr) {
if (ptr->checkpt->checknum == brknum) {
return ptr->checkpt;
}
ptr = ptr->next;
}

ptr = watchpoints_store[i];
while (ptr) {
if (ptr->checkpt->checknum == brknum) {
return ptr->checkpt;
}
ptr = ptr->next;
ptr = all_checkpoints;
while (ptr) {
if (ptr->checkpt->checknum == brknum) {
return ptr->checkpt;
}
ptr = ptr->next;
}

return NULL;
}

Expand Down Expand Up @@ -260,6 +209,7 @@ static void remove_checkpoint(mon_checkpoint_t *cp)
lib_free(cp->command);
cp->command = NULL;

remove_checkpoint_from_list(&all_checkpoints, cp);
if (cp->check_exec) {
remove_checkpoint_from_list(&(breakpoints[mem]), cp);
}
Expand Down Expand Up @@ -695,6 +645,7 @@ int breakpoint_add_checkpoint(MON_ADDR start_addr, MON_ADDR end_addr,
new_cp->temporary = is_temp;

mem = addr_memspace(start_addr);
add_to_checkpoint_list(&all_checkpoints, new_cp);
if (new_cp->check_exec) {
add_to_checkpoint_list(&(breakpoints[mem]), new_cp);
}
Expand Down Expand Up @@ -767,6 +718,7 @@ void mon_breakpoint_unset(MON_ADDR address)

if (ptr) {
/* there's a breakpoint, so remove it */
remove_checkpoint_from_list( &all_checkpoints, ptr->checkpt );
remove_checkpoint_from_list( &breakpoints[mem], ptr->checkpt );
}
}
Expand Down

0 comments on commit 31b2f48

Please sign in to comment.