From: Jakob Gruber Date: Mon, 10 Sep 2012 08:54:00 +0000 (+0200) Subject: core: Deinitialize GDB in avr_terminate() X-Git-Tag: v1.0~7 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=dc3747065c3e00715808918b54337d99abba6fc3;p=sx%2Fsimavr.git core: Deinitialize GDB in avr_terminate() This is relevant when running multiple simavr sessions in a single program. --- diff --git a/simavr/sim/sim_avr.c b/simavr/sim/sim_avr.c index 7869f0d..d3e6706 100644 --- a/simavr/sim/sim_avr.c +++ b/simavr/sim/sim_avr.c @@ -64,6 +64,10 @@ void avr_terminate(avr_t * avr) { if (avr->special_deinit) avr->special_deinit(avr); + if (avr->gdb) { + avr_deinit_gdb(avr); + avr->gdb = NULL; + } if (avr->vcd) { avr_vcd_close(avr->vcd); avr->vcd = NULL; diff --git a/simavr/sim/sim_gdb.c b/simavr/sim/sim_gdb.c index 5c7dd97..faa016f 100644 --- a/simavr/sim/sim_gdb.c +++ b/simavr/sim/sim_gdb.c @@ -566,3 +566,12 @@ int avr_gdb_init(avr_t * avr) return 0; } + +void avr_deinit_gdb(avr_t * avr) +{ + if (avr->gdb->listen != -1) + close(avr->gdb->listen); + if (avr->gdb->s != -1) + close(avr->gdb->s); + free(avr->gdb); +} diff --git a/simavr/sim/sim_gdb.h b/simavr/sim/sim_gdb.h index 2c672c3..225291b 100644 --- a/simavr/sim/sim_gdb.h +++ b/simavr/sim/sim_gdb.h @@ -39,6 +39,8 @@ enum avr_gdb_watch_type { int avr_gdb_init(avr_t * avr); +void avr_deinit_gdb(avr_t * avr); + // call from the main AVR decoder thread int avr_gdb_processor(avr_t * avr, int sleep);