if (current_gdb_connection == NULL)
{
- command_print(cmd_ctx,
+ command_print(CMD_CTX,
"gdb_sync command can only be run from within gdb using \"monitor gdb_sync\"");
return ERROR_FAIL;
}
COMMAND_HANDLER(handle_gdb_memory_map_command)
{
if (CMD_ARGC == 1)
- {
- if (strcmp(args[0], "enable") == 0)
- {
- gdb_use_memory_map = 1;
- return ERROR_OK;
- }
- else if (strcmp(args[0], "disable") == 0)
- {
- gdb_use_memory_map = 0;
- return ERROR_OK;
- }
- else
- LOG_WARNING("invalid gdb_memory_map configuration directive %s", args[0]);
- }
+ COMMAND_PARSE_ENABLE(CMD_ARGV[0], gdb_use_memory_map);
return ERROR_COMMAND_SYNTAX_ERROR;
}
COMMAND_HANDLER(handle_gdb_flash_program_command)
{
if (CMD_ARGC == 1)
- {
- if (strcmp(args[0], "enable") == 0)
- {
- gdb_flash_program = 1;
- return ERROR_OK;
- }
- else if (strcmp(args[0], "disable") == 0)
- {
- gdb_flash_program = 0;
- return ERROR_OK;
- }
- else
- LOG_WARNING("invalid gdb_flash_program configuration directive: %s", args[0]);
- }
+ COMMAND_PARSE_ENABLE(CMD_ARGV[0], gdb_flash_program);
return ERROR_COMMAND_SYNTAX_ERROR;
}
COMMAND_HANDLER(handle_gdb_report_data_abort_command)
{
if (CMD_ARGC == 1)
- {
- if (strcmp(args[0], "enable") == 0)
- {
- gdb_report_data_abort = 1;
- return ERROR_OK;
- }
- else if (strcmp(args[0], "disable") == 0)
- {
- gdb_report_data_abort = 0;
- return ERROR_OK;
- }
- else
- LOG_WARNING("invalid gdb_report_data_abort configuration directive: %s", args[0]);
- }
+ COMMAND_PARSE_ENABLE(CMD_ARGV[0], gdb_report_data_abort);
return ERROR_COMMAND_SYNTAX_ERROR;
}
} else if (CMD_ARGC == 1)
{
gdb_breakpoint_override = 1;
- if (strcmp(args[0], "hard") == 0)
+ if (strcmp(CMD_ARGV[0], "hard") == 0)
{
gdb_breakpoint_override_type = BKPT_HARD;
- } else if (strcmp(args[0], "soft") == 0)
+ } else if (strcmp(CMD_ARGV[0], "soft") == 0)
{
gdb_breakpoint_override_type = BKPT_SOFT;
- } else if (strcmp(args[0], "disable") == 0)
+ } else if (strcmp(CMD_ARGV[0], "disable") == 0)
{
gdb_breakpoint_override = 0;
}
return ERROR_OK;
}
-int gdb_register_commands(struct command_context *command_context)
+static const struct command_registration gdb_command_handlers[] = {
+ {
+ .name = "gdb_sync",
+ .handler = &handle_gdb_sync_command,
+ .mode = COMMAND_ANY,
+ .help = "next stepi will return immediately allowing "
+ "GDB to fetch register state without affecting "
+ "target state",
+ },
+ {
+ .name = "gdb_port",
+ .handler = &handle_gdb_port_command,
+ .mode = COMMAND_ANY,
+ .help = "daemon configuration command gdb_port",
+ .usage = "<port>",
+ },
+ {
+ .name = "gdb_memory_map",
+ .handler = &handle_gdb_memory_map_command,
+ .mode = COMMAND_CONFIG,
+ .help = "enable or disable memory map",
+ .usage = "enable|disable"
+ },
+ {
+ .name = "gdb_flash_program",
+ .handler = &handle_gdb_flash_program_command,
+ .mode = COMMAND_CONFIG,
+ .help = "enable or disable flash program",
+ .usage = "enable|disable"
+ },
+ {
+ .name = "gdb_report_data_abort",
+ .handler = &handle_gdb_report_data_abort_command,
+ .mode = COMMAND_CONFIG,
+ .help = "enable or disable reporting data aborts",
+ .usage = "enable|disable"
+ },
+ {
+ .name = "gdb_breakpoint_override",
+ .handler = &handle_gdb_breakpoint_override_command,
+ .mode = COMMAND_EXEC,
+ .help = "force type of breakpoint "
+ "used by gdb 'break' commands.",
+ .usage = "hard|soft|disable",
+ },
+ COMMAND_REGISTRATION_DONE
+};
+
+int gdb_register_commands(struct command_context *cmd_ctx)
{
- register_command(command_context, NULL, "gdb_sync",
- handle_gdb_sync_command, COMMAND_ANY,
- "next stepi will return immediately allowing GDB to "
- "fetch register state without affecting target state");
- register_command(command_context, NULL, "gdb_port",
- handle_gdb_port_command, COMMAND_ANY,
- "daemon configuration command gdb_port");
- register_command(command_context, NULL, "gdb_memory_map",
- handle_gdb_memory_map_command, COMMAND_CONFIG,
- "enable or disable memory map");
- register_command(command_context, NULL, "gdb_flash_program",
- handle_gdb_flash_program_command, COMMAND_CONFIG,
- "enable or disable flash program");
- register_command(command_context, NULL, "gdb_report_data_abort",
- handle_gdb_report_data_abort_command, COMMAND_CONFIG,
- "enable or disable reporting data aborts");
- register_command(command_context, NULL, "gdb_breakpoint_override",
- handle_gdb_breakpoint_override_command, COMMAND_EXEC,
- "hard/soft/disable - force type of breakpoint "
- "used by gdb 'break' commands.");
- return ERROR_OK;
+ return register_commands(cmd_ctx, NULL, gdb_command_handlers);
}