diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2018-05-21 16:14:33 +0200 |
---|---|---|
committer | Matthias Welwarsky <matthias@welwarsky.de> | 2018-09-07 08:18:22 +0100 |
commit | ab858febb6ca6e5dada1492e96c00d8b12c575c0 (patch) | |
tree | 6474d3e3a0861d717ce77baf53f4ebd797eec714 /src/target/target.c | |
parent | 11019a824d0273012e9b253fd63ddda6a2468c83 (diff) | |
download | riscv-openocd-ab858febb6ca6e5dada1492e96c00d8b12c575c0.zip riscv-openocd-ab858febb6ca6e5dada1492e96c00d8b12c575c0.tar.gz riscv-openocd-ab858febb6ca6e5dada1492e96c00d8b12c575c0.tar.bz2 |
gdb_server: add per target option "-gdb-port"
The argument passed to global config command "gdb_port" is usually,
but not always, a TCP port number. In case of multiple targets, this
numeric value is used as the first port of a set of consecutive TCP
ports assigned one per target.
If the argument is not a numeric value (e.g. "pipe", "disabled", ...)
then incrementing it for the next target has no sense.
Add the option "-gdb-port number" to the commands "target create" and
"$target_name configure" to override, for the specific target, the
general global configuration.
This permits to use a per target "-gdb-port disabled", when no gdb
port is required for that specific target.
It also makes possible to choose a custom TCP port number for each
target, overriding the usual sequence of consecutive port numbers.
Change-Id: I3b9a1910b28ab4bc757e839d0e5d08ffc29f7ab4
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4530
Tested-by: jenkins
Reviewed-by: Christopher Head <chead@zaber.com>
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
Diffstat (limited to 'src/target/target.c')
-rw-r--r-- | src/target/target.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/target/target.c b/src/target/target.c index 68f9321..253928d 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1927,6 +1927,7 @@ static void target_destroy(struct target *target) target->smp = 0; } + free(target->gdb_port_override); free(target->type); free(target->trace_info); free(target->fileio_info); @@ -4537,6 +4538,7 @@ enum target_cfg_param { TCFG_DBGBASE, TCFG_RTOS, TCFG_DEFER_EXAMINE, + TCFG_GDB_PORT, }; static Jim_Nvp nvp_config_opts[] = { @@ -4552,6 +4554,7 @@ static Jim_Nvp nvp_config_opts[] = { { .name = "-dbgbase", .value = TCFG_DBGBASE }, { .name = "-rtos", .value = TCFG_RTOS }, { .name = "-defer-examine", .value = TCFG_DEFER_EXAMINE }, + { .name = "-gdb-port", .value = TCFG_GDB_PORT }, { .name = NULL, .value = -1 } }; @@ -4839,6 +4842,20 @@ no_params: /* loop for more */ break; + case TCFG_GDB_PORT: + if (goi->isconfigure) { + const char *s; + e = Jim_GetOpt_String(goi, &s, NULL); + if (e != JIM_OK) + return e; + target->gdb_port_override = strdup(s); + } else { + if (goi->argc != 0) + goto no_params; + } + Jim_SetResultString(goi->interp, target->gdb_port_override ? : "undefined", -1); + /* loop for more */ + break; } } /* while (goi->argc) */ @@ -5613,6 +5630,8 @@ static int target_create(Jim_GetOptInfo *goi) target->rtos = NULL; target->rtos_auto_detect = false; + target->gdb_port_override = NULL; + /* Do the rest as "configure" options */ goi->isconfigure = 1; e = target_configure(goi, target); @@ -5635,6 +5654,7 @@ static int target_create(Jim_GetOptInfo *goi) } if (e != JIM_OK) { + free(target->gdb_port_override); free(target->type); free(target); return e; @@ -5652,6 +5672,7 @@ static int target_create(Jim_GetOptInfo *goi) e = (*(target->type->target_create))(target, goi->interp); if (e != ERROR_OK) { LOG_DEBUG("target_create failed"); + free(target->gdb_port_override); free(target->type); free(target->cmd_name); free(target); |