If you disable all access through TCP/IP, you will need to
use the command line @option{-pipe} option.
+@anchor{gdb_port}
@deffn {Command} gdb_port [number]
@cindex GDB server
Normally gdb listens to a TCP/IP port, but GDB can also
second target will listen on gdb_port + 1, and so on.
When not specified during the configuration stage,
the port @var{number} defaults to 3333.
+When @var{number} is not a numeric value, incrementing it to compute
+the next port number does not work. In this case, specify the proper
+@var{number} for each target by using the option @code{-gdb-port} of the
+commands @command{target create} or @command{$target_name configure}.
+@xref{gdbportoverride,,option -gdb-port}.
Note: when using "gdb_port pipe", increasing the default remote timeout in
gdb (with 'set remotetimeout') is recommended. An insufficient timeout may
cause initialization to fail with "Unknown remote qXfer reply: OK".
-
@end deffn
@deffn {Command} tcl_port [number]
where it is a mandatory configuration for the target run control.
@xref{armcrosstrigger,,ARM Cross-Trigger Interface},
for instruction on how to declare and control a CTI instance.
+
+@anchor{gdbportoverride}
+@item @code{-gdb-port} @var{number} -- see command @command{gdb_port} for the
+possible values of the parameter @var{number}, which are not only numeric values.
+Use this option to override, for this target only, the global parameter set with
+command @command{gdb_port}.
+@xref{gdb_port,,command gdb_port}.
@end itemize
@end deffn
if (NULL == gdb_service)
return -ENOMEM;
+ LOG_DEBUG("starting gdb server for %s on %s", target_name(target), port);
+
gdb_service->target = target;
gdb_service->core[0] = -1;
gdb_service->core[1] = -1;
static int gdb_target_add_one(struct target *target)
{
+ /* one gdb instance per smp list */
+ if ((target->smp) && (target->gdb_service))
+ return ERROR_OK;
+
+ if (target->gdb_port_override) {
+ if (strcmp(target->gdb_port_override, "disabled") == 0) {
+ LOG_INFO("gdb port disabled");
+ return ERROR_OK;
+ }
+ return gdb_target_start(target, target->gdb_port_override);
+ }
+
if (strcmp(gdb_port, "disabled") == 0) {
LOG_INFO("gdb port disabled");
return ERROR_OK;
}
- /* one gdb instance per smp list */
- if ((target->smp) && (target->gdb_service))
- return ERROR_OK;
int retval = gdb_target_start(target, gdb_port_next);
if (retval == ERROR_OK) {
+ /* save the port number so can be queried with
+ * $target_name cget -gdb-port
+ */
+ target->gdb_port_override = strdup(gdb_port_next);
+
long portnumber;
/* If we can parse the port number
* then we increment the port number for the next target.
int gdb_target_add_all(struct target *target)
{
- if (strcmp(gdb_port, "disabled") == 0) {
- LOG_INFO("gdb server disabled");
- return ERROR_OK;
- }
-
if (NULL == target) {
LOG_WARNING("gdb services need one or more targets defined");
return ERROR_OK;
target->smp = 0;
}
+ free(target->gdb_port_override);
free(target->type);
free(target->trace_info);
free(target->fileio_info);
TCFG_DBGBASE,
TCFG_RTOS,
TCFG_DEFER_EXAMINE,
+ TCFG_GDB_PORT,
};
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 }
};
/* 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) */
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);
}
if (e != JIM_OK) {
+ free(target->gdb_port_override);
free(target->type);
free(target);
return e;
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);
/* file-I/O information for host to do syscall */
struct gdb_fileio_info *fileio_info;
+ char *gdb_port_override; /* target-specific override for gdb_port */
+
/* The semihosting information, extracted from the target. */
struct semihosting *semihosting;
};