Skip to content

Commit

Permalink
sim_gdb: fix for restore callbacks issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hovercraft-github committed Oct 20, 2016
1 parent 96a612e commit c312e66
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions simavr/sim/sim_gdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,10 @@ gdb_handle_command(
*/
gdb_send_reply(g, "1");
break;
} else if (strncmp(cmd, "Offsets", 7) == 0) {
gdb_send_reply(g, "Text=0;Data=800000;Bss=800000");
break;
// Rmoving the following 3 lines fixes #150 issue:
// } else if (strncmp(cmd, "Offsets", 7) == 0) {
// gdb_send_reply(g, "Text=0;Data=800000;Bss=800000");
// break;
} else if (strncmp(cmd, "Xfer:memory-map:read", 20) == 0) {
snprintf(rep, sizeof(rep),
"l<memory-map>\n"
Expand Down Expand Up @@ -616,6 +617,9 @@ int
avr_gdb_init(
avr_t * avr )
{
if (avr->gdb)
return 0; // GDB server already is active

avr_gdb_t * g = malloc(sizeof(avr_gdb_t));
memset(g, 0, sizeof(avr_gdb_t));

Expand Down Expand Up @@ -656,20 +660,30 @@ avr_gdb_init(

return 0;

error:
free(g);
return -1;
error:
if (g->listen >= 0)
close(g->listen);
free(g);

return -1;
}

void
avr_deinit_gdb(
avr_t * avr )
{
if (!avr->gdb)
return;
avr->run = avr_callback_run_raw; // restore normal callbacks
avr->sleep = avr_callback_sleep_raw;
if (avr->gdb->listen != -1)
close(avr->gdb->listen);
close(avr->gdb->listen);
avr->gdb->listen = -1;
if (avr->gdb->s != -1)
close(avr->gdb->s);
close(avr->gdb->s);
avr->gdb->s = -1;
free(avr->gdb);
avr->gdb = NULL;

network_release();
}

0 comments on commit c312e66

Please sign in to comment.