From 4ad41b9ae8f6da9a7e8613598847964ccc64c1b6 Mon Sep 17 00:00:00 2001 From: Juan Cruz Varela Date: Wed, 1 Jan 2020 17:01:22 -0300 Subject: [PATCH] Allow to optionally specify gdb listening port --- simavr/sim/run_avr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/simavr/sim/run_avr.c b/simavr/sim/run_avr.c index 90a9ef9..fd2cdc5 100644 --- a/simavr/sim/run_avr.c +++ b/simavr/sim/run_avr.c @@ -44,7 +44,7 @@ display_usage( " [--help|-h] Display this usage message and exit\n" " [--trace, -t] Run full scale decoder trace\n" " [-ti ] Add traces for IRQ vector \n" - " [--gdb|-g] Listen for gdb connection on port 1234\n" + " [--gdb|-g []] Listen for gdb connection on (default 1234)\n" " [-ff <.hex file>] Load next .hex file as flash\n" " [-ee <.hex file>] Load next .hex file as eeprom\n" " [--input|-i ] A .vcd file to use as input signals\n" @@ -90,6 +90,7 @@ main( int trace = 0; int gdb = 0; int log = 1; + int port = 1234; char name[24] = ""; uint32_t loadBase = AVR_SEGMENT_OFFSET_FLASH; int trace_vectors[8] = {0}; @@ -196,6 +197,8 @@ main( trace_vectors[trace_vectors_count++] = atoi(argv[++pi]); } else if (!strcmp(argv[pi], "-g") || !strcmp(argv[pi], "--gdb")) { gdb++; + if (pi < (argc-2) && argv[pi+1][0] != '-' ) + port = atoi(argv[++pi]); } else if (!strcmp(argv[pi], "-v")) { log++; } else if (!strcmp(argv[pi], "-ee")) { @@ -273,7 +276,7 @@ main( } // even if not setup at startup, activate gdb if crashing - avr->gdb_port = 1234; + avr->gdb_port = port; if (gdb) { avr->state = cpu_Stopped; avr_gdb_init(avr); -- 2.39.5