73 if (strcmp(t->name, name) == 0) {
74 int retval = t->select(ctx);
82 LOG_ERROR(
"Error selecting '%s' as transport", t->name);
87 LOG_ERROR(
"No transport named '%s' is available.", name);
109 LOG_ERROR(
"Can't modify the set of allowed transports.");
117 LOG_INFO(
"only one transport option; autoselect '%s'", vector[0]);
143 for (t = transport_list; t; t = t->
next) {
144 if (strcmp(t->
name, new_transport->
name) == 0) {
145 LOG_ERROR(
"transport name already used");
150 if (!new_transport->
select || !new_transport->
init)
155 transport_list = new_transport;
198 argv = calloc(n + 1,
sizeof(
char *));
202 for (
unsigned i = 0; i < n; i++) {
205 for (t = transport_list; t; t = t->
next) {
221 for (
unsigned i = 0; i < n; i++)
231 LOG_ERROR(
"session transport was not selected. Use 'transport select <transport>'");
272 LOG_ERROR(
"Debug adapter does not support any transports? Check config file order.");
275 LOG_INFO(
"auto-selecting first available session transport \"%s\". " 281 Jim_SetResultString(interp, session->
name, -1);
285 if (!strcmp(session->
name, argv[1]->bytes)) {
287 Jim_SetResultString(interp, session->
name, -1);
290 LOG_ERROR(
"Can't change session's transport after the initial selection was made");
302 LOG_ERROR(
"Debug adapter doesn't support any transports?");
310 Jim_SetResultString(interp, session->
name, -1);
317 LOG_ERROR(
"Debug adapter doesn't support '%s' transport", argv[1]->bytes);
320 Jim_WrongNumArgs(interp, 1, argv,
"[too many parameters]");
328 .handler = handle_transport_init,
334 .help =
"Initialize this session's transport",
339 .handler = handle_transport_list,
341 .help =
"list all built-in transports",
348 .help =
"Select this session's transport",
349 .usage =
"[transport_name]",
358 .help =
"Transport command group",
static const struct command_registration transport_commands[]
static int jim_transport_select(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
Implements the Tcl "transport select" command, choosing the transport to be used in this debug sessio...
int register_commands(struct command_context *cmd_ctx, struct command *parent, const struct command_registration *cmds)
Register one or more commands in the specified context, as children of parent (or top-level commends...
int transport_register_commands(struct command_context *ctx)
Wrapper for transport lifecycle operations.
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
static int transport_select(struct command_context *ctx, const char *name)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly...
#define LOG_INFO(expr ...)
static const char *const * allowed_transports
NULL-terminated Vector of names of transports which the currently selected debug adapter supports...
void command_print(struct command_invocation *cmd, const char *format,...)
struct transport * next
Transports are stored in a singly linked list.
static const struct command_registration transport_group[]
#define LOG_ERROR(expr ...)
int(* select)(struct command_context *ctx)
When a transport is selected, this method registers its commands and activates the transport (e...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
#define ERROR_COMMAND_SYNTAX_ERROR
#define LOG_WARNING(expr ...)
COMMAND_HELPER(transport_list_parse, char ***vector)
Makes and stores a copy of a set of transports passed as parameters to a command. ...
int(* init)(struct command_context *ctx)
server startup uses this method to validate transport configuration.
struct command_context * global_cmd_ctx
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
struct transport * get_current_transport(void)
Returns the transport currently being used by this debug or programming session.
const char * usage
a string listing the options and arguments, required or optional
const char * name
Each transport has a unique name, used to select it from among the alternatives.
static struct transport * transport_list
List of transports known to OpenOCD.
COMMAND_HANDLER(handle_transport_init)
int transport_register(struct transport *new_transport)
Registers a transport.
#define LOG_DEBUG(expr ...)
int allow_transports(struct command_context *ctx, const char *const *vector)
Called by debug adapter drivers, or affiliated Tcl config scripts, to declare the set of transports s...
static struct transport * session