63 if (strcmp(t->name,
name) == 0) {
64 int retval = t->select(ctx);
72 LOG_ERROR(
"Error selecting '%s' as transport", t->name);
99 LOG_ERROR(
"Can't modify the set of allowed transports.");
107 LOG_INFO(
"only one transport option; autoselecting '%s'", vector[0]);
134 if (strcmp(t->
name, new_transport->
name) == 0) {
135 LOG_ERROR(
"transport name already used");
140 if (!new_transport->
select || !new_transport->
init)
188 argv = calloc(n + 1,
sizeof(
char *));
192 for (
unsigned int i = 0; i < n; i++) {
211 for (
unsigned int i = 0; i < n; i++)
221 LOG_ERROR(
"session transport was not selected. Use 'transport select <transport>'");
264 command_print(
CMD,
"Debug adapter does not support any transports? Check config file order.");
267 LOG_INFO(
"auto-selecting first available session transport \"%s\". "
283 command_print(
CMD,
"Can't change session's transport after the initial selection was made");
314 .handler = handle_transport_init,
320 .help =
"Initialize this session's transport",
325 .handler = handle_transport_list,
327 .help =
"list all built-in transports",
332 .handler = handle_transport_select,
334 .help =
"Select this session's transport",
335 .usage =
"[transport_name]",
344 .help =
"Transport command group",
void command_print(struct command_invocation *cmd, const char *format,...)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
static int register_commands(struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds)
Register one or more commands in the specified context, as children of parent (or top-level commends,...
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
const char * usage
a string listing the options and arguments, required or optional
Wrapper for transport lifecycle operations.
int(* select)(struct command_context *ctx)
When a transport is selected, this method registers its commands and activates the transport (e....
int(* init)(struct command_context *ctx)
server startup uses this method to validate transport configuration.
struct transport * next
Transports are stored in a singly linked list.
const char * name
Each transport has a unique name, used to select it from among the alternatives.
static const struct command_registration transport_group[]
struct command_context * global_cmd_ctx
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 * transport_list
List of transports known to OpenOCD.
COMMAND_HELPER(transport_list_parse, char ***vector)
Makes and stores a copy of a set of transports passed as parameters to a command.
static int transport_select(struct command_context *ctx, const char *name)
COMMAND_HANDLER(handle_transport_init)
static const char *const * allowed_transports
NULL-terminated Vector of names of transports which the currently selected debug adapter supports.
static const struct command_registration transport_commands[]
int transport_register_commands(struct command_context *ctx)
static struct transport * session
struct transport * get_current_transport(void)
Returns the transport currently being used by this debug or programming session.
int transport_register(struct transport *new_transport)
Registers a transport.