command: Run clang-format across the code

This commit is contained in:
dragonmux 2022-07-26 12:11:20 +01:00 committed by Piotr Esden-Tempski
parent f85265438c
commit 68a6a7b85e
1 changed files with 80 additions and 90 deletions

View File

@ -102,7 +102,7 @@ const struct command_s cmd_list[] = {
#if defined(PLATFORM_HAS_DEBUG) && (PC_HOSTED == 0)
{"debug_bmp", (cmd_handler)cmd_debug_bmp, "Output BMP \"debug\" strings to the second vcom: (enable|disable)"},
#endif
{NULL, NULL, NULL}
{NULL, NULL, NULL},
};
bool connect_assert_nrst;
@ -120,7 +120,8 @@ int command_process(target *t, char *cmd)
/* Initial estimate for argc */
for (char *s = cmd; *s; s++)
if((*s == ' ') || (*s == '\t')) argc++;
if ((*s == ' ') || (*s == '\t'))
argc++;
/* This needs replacing with something more sensible.
* It should be pinging -Wvla among other things, and it failing is straight-up UB
@ -352,22 +353,17 @@ bool cmd_frequency(target *t, int argc, char **argv)
else
gdb_outf("Max SWJ freq %08" PRIx32 "\n", freq);
return true;
}
static void display_target(int i, target *t, void *context)
{
(void)context;
if (!strcmp(target_driver_name(t), "ARM Cortex-M")) {
gdb_outf("***%2d%sUnknown %s Designer 0x%03x Partno 0x%03x %s\n",
i, target_attached(t)?" * ":" ",
target_driver_name(t),
target_designer(t),
target_idcode(t),
gdb_outf("***%2d%sUnknown %s Designer 0x%03x Partno 0x%03x %s\n", i, target_attached(t) ? " * " : " ",
target_driver_name(t), target_designer(t), target_idcode(t),
(target_core_name(t)) ? target_core_name(t) : "");
} else {
gdb_outf("%2d %c %s %s\n", i, target_attached(t)?'*':' ',
target_driver_name(t),
gdb_outf("%2d %c %s %s\n", i, target_attached(t) ? '*' : ' ', target_driver_name(t),
(target_core_name(t)) ? target_core_name(t) : "");
}
}
@ -428,8 +424,7 @@ static bool cmd_connect_reset(target *t, int argc, const char **argv)
}
if (print_status) {
gdb_outf("Assert nRST during connect: %s\n",
connect_assert_nrst ? "enabled" : "disabled");
gdb_outf("Assert nRST during connect: %s\n", connect_assert_nrst ? "enabled" : "disabled");
}
return true;
}
@ -439,8 +434,7 @@ static bool cmd_halt_timeout(target *t, int argc, const char **argv)
(void)t;
if (argc > 1)
cortexm_wait_timeout = atol(argv[1]);
gdb_outf("Cortex-M timeout to wait for device haltes: %d\n",
cortexm_wait_timeout);
gdb_outf("Cortex-M timeout to wait for device haltes: %d\n", cortexm_wait_timeout);
return true;
}
@ -470,14 +464,12 @@ static bool cmd_target_power(target *t, int argc, const char **argv)
{
(void)t;
if (argc == 1) {
gdb_outf("Target Power: %s\n",
platform_target_get_power() ? "enabled" : "disabled");
gdb_outf("Target Power: %s\n", platform_target_get_power() ? "enabled" : "disabled");
} else if (argc == 2) {
bool want_enable = false;
if (parse_enable_or_disable(argv[1], &want_enable)) {
if (want_enable
&& !platform_target_get_power()
&& platform_target_voltage_sense() > POWER_CONFLICT_THRESHOLD) {
if (want_enable && !platform_target_get_power() &&
platform_target_voltage_sense() > POWER_CONFLICT_THRESHOLD) {
/* want to enable target power, but VREF > 0.5V sensed -> cancel */
gdb_outf("Target already powered (%s)\n", platform_target_voltage());
} else {
@ -494,7 +486,8 @@ static bool cmd_target_power(target *t, int argc, const char **argv)
#ifdef ENABLE_RTT
const char *onoroffstr[2] = {"off", "on"};
static const char* onoroff(bool bval) {
static const char *onoroff(bool bval)
{
return bval ? onoroffstr[1] : onoroffstr[0];
}
@ -504,27 +497,25 @@ static bool cmd_rtt(target *t, int argc, const char **argv)
if ((argc == 1) || ((argc == 2) && !strncmp(argv[1], "enabled", strlen(argv[1])))) {
rtt_enabled = true;
rtt_found = false;
}
else if ((argc == 2) && !strncmp(argv[1], "disabled", strlen(argv[1]))) {
} else if ((argc == 2) && !strncmp(argv[1], "disabled", strlen(argv[1]))) {
rtt_enabled = false;
rtt_found = false;
}
else if ((argc == 2) && !strncmp(argv[1], "status", strlen(argv[1]))) {
gdb_outf("rtt: %s found: %s ident: ",
onoroff(rtt_enabled), rtt_found ? "yes" : "no");
} else if ((argc == 2) && !strncmp(argv[1], "status", strlen(argv[1]))) {
gdb_outf("rtt: %s found: %s ident: ", onoroff(rtt_enabled), rtt_found ? "yes" : "no");
if (rtt_ident[0] == '\0')
gdb_out("off");
else
gdb_outf("\"%s\"", rtt_ident);
gdb_outf(" halt: %s", onoroff(target_no_background_memory_access(t)));
gdb_out(" channels: ");
if (rtt_auto_channel) gdb_out("auto ");
if (rtt_auto_channel)
gdb_out("auto ");
for (uint32_t i = 0; i < MAX_RTT_CHAN; i++)
if (rtt_channel[i].is_enabled) gdb_outf("%d ", i);
gdb_outf("\nmax poll ms: %u min poll ms: %u max errs: %u\n",
rtt_max_poll_ms, rtt_min_poll_ms, rtt_max_poll_errs);
}
else if ((argc >= 2) && !strncmp(argv[1], "channel", strlen(argv[1]))) {
if (rtt_channel[i].is_enabled)
gdb_outf("%d ", i);
gdb_outf(
"\nmax poll ms: %u min poll ms: %u max errs: %u\n", rtt_max_poll_ms, rtt_min_poll_ms, rtt_max_poll_errs);
} else if ((argc >= 2) && !strncmp(argv[1], "channel", strlen(argv[1]))) {
/* mon rtt channel switches to auto rtt channel selection
mon rtt channel number... selects channels given */
for (uint32_t i = 0; i < MAX_RTT_CHAN; i++)
@ -539,42 +530,39 @@ static bool cmd_rtt(target *t, int argc, const char **argv)
rtt_channel[chan].is_enabled = true;
}
}
}
else if ((argc == 2) && !strncmp(argv[1], "ident", strlen(argv[1]))) {
} else if ((argc == 2) && !strncmp(argv[1], "ident", strlen(argv[1]))) {
rtt_ident[0] = '\0';
}
else if ((argc == 2) && !strncmp(argv[1], "poll", strlen(argv[1])))
} else if ((argc == 2) && !strncmp(argv[1], "poll", strlen(argv[1])))
gdb_outf("%u %u %u\n", rtt_max_poll_ms, rtt_min_poll_ms, rtt_max_poll_errs);
else if ((argc == 2) && !strncmp(argv[1], "cblock", strlen(argv[1]))) {
gdb_outf("cbaddr: 0x%x\n", rtt_cbaddr);
gdb_out("ch ena cfg i/o buf@ size head@ tail@ flg\n");
for (uint32_t i = 0; i < MAX_RTT_CHAN; i++) {
gdb_outf("%2d %c %c %s 0x%08x %5d 0x%08x 0x%08x %d\n",
i, rtt_channel[i].is_enabled ? 'y' : 'n', rtt_channel[i].is_configured ? 'y' : 'n',
rtt_channel[i].is_output ? "out" : "in ", rtt_channel[i].buf_addr, rtt_channel[i].buf_size,
rtt_channel[i].head_addr, rtt_channel[i].tail_addr, rtt_channel[i].flag);
gdb_outf("%2d %c %c %s 0x%08x %5d 0x%08x 0x%08x %d\n", i, rtt_channel[i].is_enabled ? 'y' : 'n',
rtt_channel[i].is_configured ? 'y' : 'n', rtt_channel[i].is_output ? "out" : "in ",
rtt_channel[i].buf_addr, rtt_channel[i].buf_size, rtt_channel[i].head_addr, rtt_channel[i].tail_addr,
rtt_channel[i].flag);
}
}
else if ((argc == 3) && !strncmp(argv[1], "ident", strlen(argv[1]))) {
} else if ((argc == 3) && !strncmp(argv[1], "ident", strlen(argv[1]))) {
strncpy(rtt_ident, argv[2], sizeof(rtt_ident));
rtt_ident[sizeof(rtt_ident) - 1] = '\0';
for (uint32_t i = 0; i < sizeof(rtt_ident); i++)
if (rtt_ident[i] == '_') rtt_ident[i] = ' ';
}
else if ((argc == 5) && !strncmp(argv[1], "poll", strlen(argv[1]))) {
if (rtt_ident[i] == '_')
rtt_ident[i] = ' ';
} else if ((argc == 5) && !strncmp(argv[1], "poll", strlen(argv[1]))) {
/* set polling params */
int32_t new_max_poll_ms = atoi(argv[2]);
int32_t new_min_poll_ms = atoi(argv[3]);
int32_t new_max_poll_errs = atoi(argv[4]);
if ((new_max_poll_ms >= 0) && (new_min_poll_ms >= 0) && (new_max_poll_errs >= 0)
&& (new_max_poll_ms >= new_min_poll_ms)) {
if ((new_max_poll_ms >= 0) && (new_min_poll_ms >= 0) && (new_max_poll_errs >= 0) &&
(new_max_poll_ms >= new_min_poll_ms)) {
rtt_max_poll_ms = new_max_poll_ms;
rtt_min_poll_ms = new_min_poll_ms;
rtt_max_poll_errs = new_max_poll_errs;
}
else gdb_out("how?\n");
}
else gdb_out("what?\n");
} else
gdb_out("how?\n");
} else
gdb_out("what?\n");
return true;
}
#endif
@ -593,7 +581,8 @@ static bool cmd_traceswo(target *t, int argc, const char **argv)
/* argument: optional baud rate for async mode */
if ((argc > 1) && (*argv[1] >= '0') && (*argv[1] <= '9')) {
baudrate = atoi(argv[1]);
if (baudrate == 0) baudrate = SWO_DEFAULT_BAUD;
if (baudrate == 0)
baudrate = SWO_DEFAULT_BAUD;
decode_arg = 2;
}
#endif
@ -650,23 +639,24 @@ static bool cmd_debug_bmp(target *t, int argc, const char **argv)
}
if (print_status) {
gdb_outf("Debug mode is %s\n",
debug_bmp ? "enabled" : "disabled");
gdb_outf("Debug mode is %s\n", debug_bmp ? "enabled" : "disabled");
}
return true;
}
#endif
static bool cmd_heapinfo(target *t, int argc, const char **argv)
{
if (t == NULL) gdb_out("not attached\n");
if (t == NULL)
gdb_out("not attached\n");
else if (argc == 5) {
target_addr heap_base = strtoul(argv[1], NULL, 16);
target_addr heap_limit = strtoul(argv[2], NULL, 16);
target_addr stack_base = strtoul(argv[3], NULL, 16);
target_addr stack_limit = strtoul(argv[4], NULL, 16);
gdb_outf("heapinfo heap_base: %p heap_limit: %p stack_base: %p stack_limit: %p\n",
heap_base, heap_limit, stack_base, stack_limit);
gdb_outf("heapinfo heap_base: %p heap_limit: %p stack_base: %p stack_limit: %p\n", heap_base, heap_limit,
stack_base, stack_limit);
target_set_heapinfo(t, heap_base, heap_limit, stack_base, stack_limit);
} else gdb_outf("heapinfo heap_base heap_limit stack_base stack_limit\n");
} else
gdb_outf("heapinfo heap_base heap_limit stack_base stack_limit\n");
return true;
}