mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
kgdb patches for 6.13
A relatively modest collection of changes: * Adopt kstrtoint() and kstrtol() instead of the simple_strtoXX family for better error checking of user input. * Align the print behavour when breakpoints are enabled and disabled by adopting the current behaviour of breakpoint disable for both. * Remove some of the (rather odd and user hostile) hex fallbacks and require kdb users to prefix with 0x instead. * Tidy up (and fix) control code handling in kdb's keyboard code. This makes the control code handling at the keyboard behave the same way as it does via the UART. * Switch my own entry in MAINTAINERS to my @kernel.org address. Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org> -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEELzVBU1D3lWq6cKzwfOMlXTn3iKEFAmc7bV4ACgkQfOMlXTn3 iKE9Mw/9G80KzejHGaSbzA17ELmxvCeQYQtnpbOiySpvzmIQWkOT7RBhqvqSD/+b 8tCT1aE/QHgkYRSIGTtCVILMSrJ1v2yJR5yuNOXAQgpwVCKq13hq4t7OFBpd+f2K kiY+UCpOOLb7okhjwT5I8hwI1wiHw9VOfcVq2BbBrcQPSoPfAI3iQ8PXUZHu4uq9 EB2OZskFxnIRtCJWXzEayXwzpD0mI9j0Ab+TEm32X3RU+BF0kGLfRvTKYl9jWkBc jsW4BKGOa+dfO5tu8zhVGxk5pssNeomaBNwRLD2EqtlmQJOkiGEk7qsR8z8aeETx uGbmfa4glrZj1V66bOeq9i+qqoAB9VY4TWw2/KSGOaQYsKHcK58EmSzq5nM0Abex rJbOBslsTYBMxz0z5qW8GyD20WtjgMSGtCmAu7OmlDJJdcksYsy6CY+gkfUsVS87 ZA4U0y8zvpyjMt2EKMS5o0/511bwzFtWtqEmiEBqfkX/NUJanaEBTt943NbnJEgu i8J+62B69G2X6gXjRZdncGC+MTWH/o93wmZk5u7bgdO0Wqk9t/EArILp4P9Ieco9 TpblPvcqEjfzBwkQKGMX5zhiR1YHzQn4sC4SmFUjczwuEjnmN0jEPMappG7bxI1c MEX5mPVQdRHO0N4jN/a7qC5PONbi8gKtnhfmCPbTGPwLF87DOEc= =rlg/ -----END PGP SIGNATURE----- Merge tag 'kgdb-6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux Pull kgdb updates from Daniel Thompson: "A relatively modest collection of changes: - Adopt kstrtoint() and kstrtol() instead of the simple_strtoXX family for better error checking of user input. - Align the print behavour when breakpoints are enabled and disabled by adopting the current behaviour of breakpoint disable for both. - Remove some of the (rather odd and user hostile) hex fallbacks and require kdb users to prefix with 0x instead. - Tidy up (and fix) control code handling in kdb's keyboard code. This makes the control code handling at the keyboard behave the same way as it does via the UART. - Switch my own entry in MAINTAINERS to my @kernel.org address" * tag 'kgdb-6.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux: kdb: fix ctrl+e/a/f/b/d/p/n broken in keyboard mode MAINTAINERS: Use Daniel Thompson's korg address for kgdb work kdb: Fix breakpoint enable to be silent if already enabled kdb: Remove fallback interpretation of arbitrary numbers as hex trace: kdb: Replace simple_strtoul with kstrtoul in kdb_ftdump kdb: Replace the use of simple_strto with safer kstrto in kdb_main
This commit is contained in:
commit
f89a687aae
@ -12670,7 +12670,7 @@ F: samples/kfifo/
|
|||||||
|
|
||||||
KGDB / KDB /debug_core
|
KGDB / KDB /debug_core
|
||||||
M: Jason Wessel <jason.wessel@windriver.com>
|
M: Jason Wessel <jason.wessel@windriver.com>
|
||||||
M: Daniel Thompson <daniel.thompson@linaro.org>
|
M: Daniel Thompson <danielt@kernel.org>
|
||||||
R: Douglas Anderson <dianders@chromium.org>
|
R: Douglas Anderson <dianders@chromium.org>
|
||||||
L: kgdb-bugreport@lists.sourceforge.net
|
L: kgdb-bugreport@lists.sourceforge.net
|
||||||
S: Maintained
|
S: Maintained
|
||||||
|
@ -460,13 +460,15 @@ static int kdb_bc(int argc, const char **argv)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case KDBCMD_BE:
|
case KDBCMD_BE:
|
||||||
|
if (bp->bp_enabled)
|
||||||
|
break;
|
||||||
|
|
||||||
bp->bp_enabled = 1;
|
bp->bp_enabled = 1;
|
||||||
|
|
||||||
kdb_printf("Breakpoint %d at "
|
kdb_printf("Breakpoint %d at "
|
||||||
kdb_bfd_vma_fmt " enabled",
|
kdb_bfd_vma_fmt " enabled\n",
|
||||||
i, bp->bp_addr);
|
i, bp->bp_addr);
|
||||||
|
|
||||||
kdb_printf("\n");
|
|
||||||
break;
|
break;
|
||||||
case KDBCMD_BD:
|
case KDBCMD_BD:
|
||||||
if (!bp->bp_enabled)
|
if (!bp->bp_enabled)
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#define KBD_STAT_OBF 0x01 /* Keyboard output buffer full */
|
#define KBD_STAT_OBF 0x01 /* Keyboard output buffer full */
|
||||||
#define KBD_STAT_MOUSE_OBF 0x20 /* Mouse output buffer full */
|
#define KBD_STAT_MOUSE_OBF 0x20 /* Mouse output buffer full */
|
||||||
|
|
||||||
|
#define CTRL(c) ((c) - 64)
|
||||||
|
|
||||||
static int kbd_exists;
|
static int kbd_exists;
|
||||||
static int kbd_last_ret;
|
static int kbd_last_ret;
|
||||||
|
|
||||||
@ -123,24 +125,24 @@ int kdb_get_kbd_char(void)
|
|||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Special Key */
|
/* Translate special keys to equivalent CTRL control characters */
|
||||||
switch (scancode) {
|
switch (scancode) {
|
||||||
case 0xF: /* Tab */
|
case 0xF: /* Tab */
|
||||||
return 9;
|
return CTRL('I');
|
||||||
case 0x53: /* Del */
|
case 0x53: /* Del */
|
||||||
return 4;
|
return CTRL('D');
|
||||||
case 0x47: /* Home */
|
case 0x47: /* Home */
|
||||||
return 1;
|
return CTRL('A');
|
||||||
case 0x4F: /* End */
|
case 0x4F: /* End */
|
||||||
return 5;
|
return CTRL('E');
|
||||||
case 0x4B: /* Left */
|
case 0x4B: /* Left */
|
||||||
return 2;
|
return CTRL('B');
|
||||||
case 0x48: /* Up */
|
case 0x48: /* Up */
|
||||||
return 16;
|
return CTRL('P');
|
||||||
case 0x50: /* Down */
|
case 0x50: /* Down */
|
||||||
return 14;
|
return CTRL('N');
|
||||||
case 0x4D: /* Right */
|
case 0x4D: /* Right */
|
||||||
return 6;
|
return CTRL('F');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scancode == 0xe0)
|
if (scancode == 0xe0)
|
||||||
@ -172,6 +174,19 @@ int kdb_get_kbd_char(void)
|
|||||||
switch (KTYP(keychar)) {
|
switch (KTYP(keychar)) {
|
||||||
case KT_LETTER:
|
case KT_LETTER:
|
||||||
case KT_LATIN:
|
case KT_LATIN:
|
||||||
|
switch (keychar) {
|
||||||
|
/* non-printable supported control characters */
|
||||||
|
case CTRL('A'): /* Home */
|
||||||
|
case CTRL('B'): /* Left */
|
||||||
|
case CTRL('D'): /* Del */
|
||||||
|
case CTRL('E'): /* End */
|
||||||
|
case CTRL('F'): /* Right */
|
||||||
|
case CTRL('I'): /* Tab */
|
||||||
|
case CTRL('N'): /* Down */
|
||||||
|
case CTRL('P'): /* Up */
|
||||||
|
return keychar;
|
||||||
|
}
|
||||||
|
|
||||||
if (isprint(keychar))
|
if (isprint(keychar))
|
||||||
break; /* printable characters */
|
break; /* printable characters */
|
||||||
fallthrough;
|
fallthrough;
|
||||||
|
@ -306,8 +306,8 @@ static int kdbgetulenv(const char *match, unsigned long *value)
|
|||||||
return KDB_NOTENV;
|
return KDB_NOTENV;
|
||||||
if (strlen(ep) == 0)
|
if (strlen(ep) == 0)
|
||||||
return KDB_NOENVVALUE;
|
return KDB_NOENVVALUE;
|
||||||
|
if (kstrtoul(ep, 0, value))
|
||||||
*value = simple_strtoul(ep, NULL, 0);
|
return KDB_BADINT;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -402,42 +402,15 @@ static void kdb_printenv(void)
|
|||||||
*/
|
*/
|
||||||
int kdbgetularg(const char *arg, unsigned long *value)
|
int kdbgetularg(const char *arg, unsigned long *value)
|
||||||
{
|
{
|
||||||
char *endp;
|
if (kstrtoul(arg, 0, value))
|
||||||
unsigned long val;
|
|
||||||
|
|
||||||
val = simple_strtoul(arg, &endp, 0);
|
|
||||||
|
|
||||||
if (endp == arg) {
|
|
||||||
/*
|
|
||||||
* Also try base 16, for us folks too lazy to type the
|
|
||||||
* leading 0x...
|
|
||||||
*/
|
|
||||||
val = simple_strtoul(arg, &endp, 16);
|
|
||||||
if (endp == arg)
|
|
||||||
return KDB_BADINT;
|
return KDB_BADINT;
|
||||||
}
|
|
||||||
|
|
||||||
*value = val;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int kdbgetu64arg(const char *arg, u64 *value)
|
int kdbgetu64arg(const char *arg, u64 *value)
|
||||||
{
|
{
|
||||||
char *endp;
|
if (kstrtou64(arg, 0, value))
|
||||||
u64 val;
|
|
||||||
|
|
||||||
val = simple_strtoull(arg, &endp, 0);
|
|
||||||
|
|
||||||
if (endp == arg) {
|
|
||||||
|
|
||||||
val = simple_strtoull(arg, &endp, 16);
|
|
||||||
if (endp == arg)
|
|
||||||
return KDB_BADINT;
|
return KDB_BADINT;
|
||||||
}
|
|
||||||
|
|
||||||
*value = val;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,10 +446,10 @@ int kdb_set(int argc, const char **argv)
|
|||||||
*/
|
*/
|
||||||
if (strcmp(argv[1], "KDBDEBUG") == 0) {
|
if (strcmp(argv[1], "KDBDEBUG") == 0) {
|
||||||
unsigned int debugflags;
|
unsigned int debugflags;
|
||||||
char *cp;
|
int ret;
|
||||||
|
|
||||||
debugflags = simple_strtoul(argv[2], &cp, 0);
|
ret = kstrtouint(argv[2], 0, &debugflags);
|
||||||
if (cp == argv[2] || debugflags & ~KDB_DEBUG_FLAG_MASK) {
|
if (ret || debugflags & ~KDB_DEBUG_FLAG_MASK) {
|
||||||
kdb_printf("kdb: illegal debug flags '%s'\n",
|
kdb_printf("kdb: illegal debug flags '%s'\n",
|
||||||
argv[2]);
|
argv[2]);
|
||||||
return 0;
|
return 0;
|
||||||
@ -1619,10 +1592,10 @@ static int kdb_md(int argc, const char **argv)
|
|||||||
if (!argv[0][3])
|
if (!argv[0][3])
|
||||||
valid = 1;
|
valid = 1;
|
||||||
else if (argv[0][3] == 'c' && argv[0][4]) {
|
else if (argv[0][3] == 'c' && argv[0][4]) {
|
||||||
char *p;
|
if (kstrtouint(argv[0] + 4, 10, &repeat))
|
||||||
repeat = simple_strtoul(argv[0] + 4, &p, 10);
|
return KDB_BADINT;
|
||||||
mdcount = ((repeat * bytesperword) + 15) / 16;
|
mdcount = ((repeat * bytesperword) + 15) / 16;
|
||||||
valid = !*p;
|
valid = 1;
|
||||||
}
|
}
|
||||||
last_repeat = repeat;
|
last_repeat = repeat;
|
||||||
} else if (strcmp(argv[0], "md") == 0)
|
} else if (strcmp(argv[0], "md") == 0)
|
||||||
@ -2083,16 +2056,11 @@ static int kdb_dmesg(int argc, const char **argv)
|
|||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
return KDB_ARGCOUNT;
|
return KDB_ARGCOUNT;
|
||||||
if (argc) {
|
if (argc) {
|
||||||
char *cp;
|
if (kstrtoint(argv[1], 0, &lines))
|
||||||
lines = simple_strtol(argv[1], &cp, 0);
|
|
||||||
if (*cp)
|
|
||||||
lines = 0;
|
lines = 0;
|
||||||
if (argc > 1) {
|
if (argc > 1 && (kstrtoint(argv[2], 0, &adjust) || adjust < 0))
|
||||||
adjust = simple_strtoul(argv[2], &cp, 0);
|
|
||||||
if (*cp || adjust < 0)
|
|
||||||
adjust = 0;
|
adjust = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* disable LOGGING if set */
|
/* disable LOGGING if set */
|
||||||
diag = kdbgetintenv("LOGGING", &logging);
|
diag = kdbgetintenv("LOGGING", &logging);
|
||||||
@ -2428,14 +2396,12 @@ static int kdb_help(int argc, const char **argv)
|
|||||||
static int kdb_kill(int argc, const char **argv)
|
static int kdb_kill(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
long sig, pid;
|
long sig, pid;
|
||||||
char *endp;
|
|
||||||
struct task_struct *p;
|
struct task_struct *p;
|
||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
return KDB_ARGCOUNT;
|
return KDB_ARGCOUNT;
|
||||||
|
|
||||||
sig = simple_strtol(argv[1], &endp, 0);
|
if (kstrtol(argv[1], 0, &sig))
|
||||||
if (*endp)
|
|
||||||
return KDB_BADINT;
|
return KDB_BADINT;
|
||||||
if ((sig >= 0) || !valid_signal(-sig)) {
|
if ((sig >= 0) || !valid_signal(-sig)) {
|
||||||
kdb_printf("Invalid signal parameter.<-signal>\n");
|
kdb_printf("Invalid signal parameter.<-signal>\n");
|
||||||
@ -2443,8 +2409,7 @@ static int kdb_kill(int argc, const char **argv)
|
|||||||
}
|
}
|
||||||
sig = -sig;
|
sig = -sig;
|
||||||
|
|
||||||
pid = simple_strtol(argv[2], &endp, 0);
|
if (kstrtol(argv[2], 0, &pid))
|
||||||
if (*endp)
|
|
||||||
return KDB_BADINT;
|
return KDB_BADINT;
|
||||||
if (pid <= 0) {
|
if (pid <= 0) {
|
||||||
kdb_printf("Process ID must be large than 0.\n");
|
kdb_printf("Process ID must be large than 0.\n");
|
||||||
|
@ -96,22 +96,19 @@ static int kdb_ftdump(int argc, const char **argv)
|
|||||||
{
|
{
|
||||||
int skip_entries = 0;
|
int skip_entries = 0;
|
||||||
long cpu_file;
|
long cpu_file;
|
||||||
char *cp;
|
int err;
|
||||||
int cnt;
|
int cnt;
|
||||||
int cpu;
|
int cpu;
|
||||||
|
|
||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
return KDB_ARGCOUNT;
|
return KDB_ARGCOUNT;
|
||||||
|
|
||||||
if (argc) {
|
if (argc && kstrtoint(argv[1], 0, &skip_entries))
|
||||||
skip_entries = simple_strtol(argv[1], &cp, 0);
|
return KDB_BADINT;
|
||||||
if (*cp)
|
|
||||||
skip_entries = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
cpu_file = simple_strtol(argv[2], &cp, 0);
|
err = kstrtol(argv[2], 0, &cpu_file);
|
||||||
if (*cp || cpu_file >= NR_CPUS || cpu_file < 0 ||
|
if (err || cpu_file >= NR_CPUS || cpu_file < 0 ||
|
||||||
!cpu_online(cpu_file))
|
!cpu_online(cpu_file))
|
||||||
return KDB_BADINT;
|
return KDB_BADINT;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user