diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2023-05-06 21:59:31 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2023-05-18 10:14:56 +0000 |
commit | d5c177cd3def7002f18270742ff3b1380feb45c5 (patch) | |
tree | f6d0992868ad7048de749bda1bc6cd88cc232a0a /src/target | |
parent | 7fa29dc5196accb3ea159e6a29fd969640e30421 (diff) | |
download | riscv-openocd-d5c177cd3def7002f18270742ff3b1380feb45c5.zip riscv-openocd-d5c177cd3def7002f18270742ff3b1380feb45c5.tar.gz riscv-openocd-d5c177cd3def7002f18270742ff3b1380feb45c5.tar.bz2 |
server: gdb: export gdb_actual_connections through a function
The internal variable 'gdb_actual_connections' is used by log and
by semihosting to determine if there are active GDB connections.
Keep the variable local in server's code and only export its value
through a dedicated function.
This solves the issue detected by 'parse' of the variable defined
as global but not declared in any include file.
Change-Id: I6e14f4cb1097787404094636f8a2a291340222dd
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7673
Tested-by: jenkins
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/semihosting_common.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/target/semihosting_common.c b/src/target/semihosting_common.c index dc0dae2..3ed112b 100644 --- a/src/target/semihosting_common.c +++ b/src/target/semihosting_common.c @@ -39,6 +39,7 @@ #include <helper/binarybuffer.h> #include <helper/log.h> +#include <server/gdb_server.h> #include <sys/stat.h> /** @@ -92,9 +93,6 @@ static int semihosting_common_fileio_info(struct target *target, static int semihosting_common_fileio_end(struct target *target, int result, int fileio_errno, bool ctrl_c); -/* Attempts to include gdb_server.h failed. */ -extern int gdb_actual_connections; - /** * Initialize common semihosting support. * @@ -493,7 +491,7 @@ int semihosting_common(struct target *target) int code = semihosting_get_field(target, 1, fields); if (type == ADP_STOPPED_APPLICATION_EXIT) { - if (!gdb_actual_connections) + if (!gdb_get_actual_connections()) exit(code); else { fprintf(stderr, @@ -508,7 +506,7 @@ int semihosting_common(struct target *target) } } else { if (semihosting->param == ADP_STOPPED_APPLICATION_EXIT) { - if (!gdb_actual_connections) + if (!gdb_get_actual_connections()) exit(0); else { fprintf(stderr, @@ -517,14 +515,14 @@ int semihosting_common(struct target *target) } else if (semihosting->param == ADP_STOPPED_RUN_TIME_ERROR) { /* Chosen more or less arbitrarily to have a nicer message, * otherwise all other return the same exit code 1. */ - if (!gdb_actual_connections) + if (!gdb_get_actual_connections()) exit(1); else { fprintf(stderr, "semihosting: *** application exited with error ***\n"); } } else { - if (!gdb_actual_connections) + if (!gdb_get_actual_connections()) exit(1); else { fprintf(stderr, @@ -584,7 +582,7 @@ int semihosting_common(struct target *target) int code = semihosting_get_field(target, 1, fields); if (type == ADP_STOPPED_APPLICATION_EXIT) { - if (!gdb_actual_connections) + if (!gdb_get_actual_connections()) exit(code); else { fprintf(stderr, |