kgdb fixes for 4.20-rc3
The most important changes here are two fixes for kdb regressions causes by the hashing of %p pointers together with a fix for a potential overflow in kdb tab completion handling (and warning fix). Also included are a set of changes in preparation to (eventually) enable -Wimplicit-fallthrough. Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org> -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEELzVBU1D3lWq6cKzwfOMlXTn3iKEFAlvrOikACgkQfOMlXTn3 iKGn0Q//Sy5haqIR2LjvuQ/31RclfGgKf7Cbuw9uUg4rP7iAtt99nahe2p+96aoW j7FceyQr/qg7OzK4vP+Ncw8PEus1WPXx1gr5oAY58BJgTsDLacsS55oCDHzOS52u dYlsyEEaLUrZnU/dU1Aq1DpLutCBfINVe8vmvnzOx+zbi3wGKAqRwH2BbAy2Cb7R 8wnuMMJByQYBAjAREb2Pnof4BSdhwvXk7R2vnaLNoSP7TllIw+nqk77dgbj0aDFh kOJuR4B4xr+W+dZxLvkItzWda3BWTYSsjHpRBQs8psxpvbwwwp8N+OZXszZUc1Ur 0Tz63KX2Qub1tA1iu7HtPhCpAwYAlLvgTTcb5DXLvuYe9ES5Mt2tCXYqDG2Grj7R Y+7JulA/uhnKkYYGTXeewV+6r6W+8f4TfKg0xxvxo06Gv9v/ptN8rF+EjGgNiIcb q0TmGFx0Kz2ZLgWsGBWG5Zv4+PFKBLDoJapH4512WFPFOXPib70C1DNRqSv0b/6A oxwbK+zti+Jj25Tww64ye6VYqmySUc5oh2BX8wp7ULF8Idx5i5FHY24HS6mqgtRl ZMb5xKY/HsnoWqj1PNYRZGW/LqLKrBgA5lcr7gWqPZZGkIc0jSqgtjSoNjU/Sn4i j75Poe3H+eVR09GfQieB6BUX6aYzJabBnhYQUp/MFBy0ZzLHVdc= =WnqF -----END PGP SIGNATURE----- Merge tag 'kgdb-fixes-4.20-rc3' of https://git.linaro.org/people/daniel.thompson/linux Pull kgdb fixes from Daniel Thompson: "The most important changes here are two fixes for kdb regressions causes by the hashing of %p pointers together with a fix for a potential overflow in kdb tab completion handling (and warning fix). Also included are a set of changes in preparation to (eventually) enable -Wimplicit-fallthrough" * tag 'kgdb-fixes-4.20-rc3' of https://git.linaro.org/people/daniel.thompson/linux: kdb: kdb_support: mark expected switch fall-throughs kdb: kdb_keyboard: mark expected switch fall-throughs kdb: kdb_main: refactor code in kdb_md_line kdb: Use strscpy with destination buffer size kdb: print real address of pointers instead of hashed addresses kdb: use correct pointer when 'btc' calls 'btt'
This commit is contained in:
commit
9746e46737
|
@ -179,14 +179,14 @@ kdb_bt(int argc, const char **argv)
|
|||
kdb_printf("no process for cpu %ld\n", cpu);
|
||||
return 0;
|
||||
}
|
||||
sprintf(buf, "btt 0x%p\n", KDB_TSK(cpu));
|
||||
sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu));
|
||||
kdb_parse(buf);
|
||||
return 0;
|
||||
}
|
||||
kdb_printf("btc: cpu status: ");
|
||||
kdb_parse("cpu\n");
|
||||
for_each_online_cpu(cpu) {
|
||||
sprintf(buf, "btt 0x%p\n", KDB_TSK(cpu));
|
||||
sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu));
|
||||
kdb_parse(buf);
|
||||
touch_nmi_watchdog();
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ static char *kdb_read(char *buffer, size_t bufsize)
|
|||
int count;
|
||||
int i;
|
||||
int diag, dtab_count;
|
||||
int key;
|
||||
int key, buf_size, ret;
|
||||
|
||||
|
||||
diag = kdbgetintenv("DTABCOUNT", &dtab_count);
|
||||
|
@ -336,9 +336,8 @@ poll_again:
|
|||
else
|
||||
p_tmp = tmpbuffer;
|
||||
len = strlen(p_tmp);
|
||||
count = kallsyms_symbol_complete(p_tmp,
|
||||
sizeof(tmpbuffer) -
|
||||
(p_tmp - tmpbuffer));
|
||||
buf_size = sizeof(tmpbuffer) - (p_tmp - tmpbuffer);
|
||||
count = kallsyms_symbol_complete(p_tmp, buf_size);
|
||||
if (tab == 2 && count > 0) {
|
||||
kdb_printf("\n%d symbols are found.", count);
|
||||
if (count > dtab_count) {
|
||||
|
@ -350,9 +349,13 @@ poll_again:
|
|||
}
|
||||
kdb_printf("\n");
|
||||
for (i = 0; i < count; i++) {
|
||||
if (WARN_ON(!kallsyms_symbol_next(p_tmp, i)))
|
||||
ret = kallsyms_symbol_next(p_tmp, i, buf_size);
|
||||
if (WARN_ON(!ret))
|
||||
break;
|
||||
kdb_printf("%s ", p_tmp);
|
||||
if (ret != -E2BIG)
|
||||
kdb_printf("%s ", p_tmp);
|
||||
else
|
||||
kdb_printf("%s... ", p_tmp);
|
||||
*(p_tmp + len) = '\0';
|
||||
}
|
||||
if (i >= dtab_count)
|
||||
|
|
|
@ -173,11 +173,11 @@ int kdb_get_kbd_char(void)
|
|||
case KT_LATIN:
|
||||
if (isprint(keychar))
|
||||
break; /* printable characters */
|
||||
/* drop through */
|
||||
/* fall through */
|
||||
case KT_SPEC:
|
||||
if (keychar == K_ENTER)
|
||||
break;
|
||||
/* drop through */
|
||||
/* fall through */
|
||||
default:
|
||||
return -1; /* ignore unprintables */
|
||||
}
|
||||
|
|
|
@ -1192,7 +1192,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
|
|||
if (reason == KDB_REASON_DEBUG) {
|
||||
/* special case below */
|
||||
} else {
|
||||
kdb_printf("\nEntering kdb (current=0x%p, pid %d) ",
|
||||
kdb_printf("\nEntering kdb (current=0x%px, pid %d) ",
|
||||
kdb_current, kdb_current ? kdb_current->pid : 0);
|
||||
#if defined(CONFIG_SMP)
|
||||
kdb_printf("on processor %d ", raw_smp_processor_id());
|
||||
|
@ -1208,7 +1208,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs,
|
|||
*/
|
||||
switch (db_result) {
|
||||
case KDB_DB_BPT:
|
||||
kdb_printf("\nEntering kdb (0x%p, pid %d) ",
|
||||
kdb_printf("\nEntering kdb (0x%px, pid %d) ",
|
||||
kdb_current, kdb_current->pid);
|
||||
#if defined(CONFIG_SMP)
|
||||
kdb_printf("on processor %d ", raw_smp_processor_id());
|
||||
|
@ -1493,6 +1493,7 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr,
|
|||
char cbuf[32];
|
||||
char *c = cbuf;
|
||||
int i;
|
||||
int j;
|
||||
unsigned long word;
|
||||
|
||||
memset(cbuf, '\0', sizeof(cbuf));
|
||||
|
@ -1538,25 +1539,9 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr,
|
|||
wc.word = word;
|
||||
#define printable_char(c) \
|
||||
({unsigned char __c = c; isascii(__c) && isprint(__c) ? __c : '.'; })
|
||||
switch (bytesperword) {
|
||||
case 8:
|
||||
for (j = 0; j < bytesperword; j++)
|
||||
*c++ = printable_char(*cp++);
|
||||
*c++ = printable_char(*cp++);
|
||||
*c++ = printable_char(*cp++);
|
||||
*c++ = printable_char(*cp++);
|
||||
addr += 4;
|
||||
case 4:
|
||||
*c++ = printable_char(*cp++);
|
||||
*c++ = printable_char(*cp++);
|
||||
addr += 2;
|
||||
case 2:
|
||||
*c++ = printable_char(*cp++);
|
||||
addr++;
|
||||
case 1:
|
||||
*c++ = printable_char(*cp++);
|
||||
addr++;
|
||||
break;
|
||||
}
|
||||
addr += bytesperword;
|
||||
#undef printable_char
|
||||
}
|
||||
}
|
||||
|
@ -2048,7 +2033,7 @@ static int kdb_lsmod(int argc, const char **argv)
|
|||
if (mod->state == MODULE_STATE_UNFORMED)
|
||||
continue;
|
||||
|
||||
kdb_printf("%-20s%8u 0x%p ", mod->name,
|
||||
kdb_printf("%-20s%8u 0x%px ", mod->name,
|
||||
mod->core_layout.size, (void *)mod);
|
||||
#ifdef CONFIG_MODULE_UNLOAD
|
||||
kdb_printf("%4d ", module_refcount(mod));
|
||||
|
@ -2059,7 +2044,7 @@ static int kdb_lsmod(int argc, const char **argv)
|
|||
kdb_printf(" (Loading)");
|
||||
else
|
||||
kdb_printf(" (Live)");
|
||||
kdb_printf(" 0x%p", mod->core_layout.base);
|
||||
kdb_printf(" 0x%px", mod->core_layout.base);
|
||||
|
||||
#ifdef CONFIG_MODULE_UNLOAD
|
||||
{
|
||||
|
@ -2341,7 +2326,7 @@ void kdb_ps1(const struct task_struct *p)
|
|||
return;
|
||||
|
||||
cpu = kdb_process_cpu(p);
|
||||
kdb_printf("0x%p %8d %8d %d %4d %c 0x%p %c%s\n",
|
||||
kdb_printf("0x%px %8d %8d %d %4d %c 0x%px %c%s\n",
|
||||
(void *)p, p->pid, p->parent->pid,
|
||||
kdb_task_has_cpu(p), kdb_process_cpu(p),
|
||||
kdb_task_state_char(p),
|
||||
|
@ -2354,7 +2339,7 @@ void kdb_ps1(const struct task_struct *p)
|
|||
} else {
|
||||
if (KDB_TSK(cpu) != p)
|
||||
kdb_printf(" Error: does not match running "
|
||||
"process table (0x%p)\n", KDB_TSK(cpu));
|
||||
"process table (0x%px)\n", KDB_TSK(cpu));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2687,7 +2672,7 @@ int kdb_register_flags(char *cmd,
|
|||
for_each_kdbcmd(kp, i) {
|
||||
if (kp->cmd_name && (strcmp(kp->cmd_name, cmd) == 0)) {
|
||||
kdb_printf("Duplicate kdb command registered: "
|
||||
"%s, func %p help %s\n", cmd, func, help);
|
||||
"%s, func %px help %s\n", cmd, func, help);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ typedef struct __ksymtab {
|
|||
unsigned long sym_start;
|
||||
unsigned long sym_end;
|
||||
} kdb_symtab_t;
|
||||
extern int kallsyms_symbol_next(char *prefix_name, int flag);
|
||||
extern int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size);
|
||||
extern int kallsyms_symbol_complete(char *prefix_name, int max_len);
|
||||
|
||||
/* Exported Symbols for kernel loadable modules to use. */
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
int kdbgetsymval(const char *symname, kdb_symtab_t *symtab)
|
||||
{
|
||||
if (KDB_DEBUG(AR))
|
||||
kdb_printf("kdbgetsymval: symname=%s, symtab=%p\n", symname,
|
||||
kdb_printf("kdbgetsymval: symname=%s, symtab=%px\n", symname,
|
||||
symtab);
|
||||
memset(symtab, 0, sizeof(*symtab));
|
||||
symtab->sym_start = kallsyms_lookup_name(symname);
|
||||
|
@ -88,7 +88,7 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab)
|
|||
char *knt1 = NULL;
|
||||
|
||||
if (KDB_DEBUG(AR))
|
||||
kdb_printf("kdbnearsym: addr=0x%lx, symtab=%p\n", addr, symtab);
|
||||
kdb_printf("kdbnearsym: addr=0x%lx, symtab=%px\n", addr, symtab);
|
||||
memset(symtab, 0, sizeof(*symtab));
|
||||
|
||||
if (addr < 4096)
|
||||
|
@ -149,7 +149,7 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab)
|
|||
symtab->mod_name = "kernel";
|
||||
if (KDB_DEBUG(AR))
|
||||
kdb_printf("kdbnearsym: returns %d symtab->sym_start=0x%lx, "
|
||||
"symtab->mod_name=%p, symtab->sym_name=%p (%s)\n", ret,
|
||||
"symtab->mod_name=%px, symtab->sym_name=%px (%s)\n", ret,
|
||||
symtab->sym_start, symtab->mod_name, symtab->sym_name,
|
||||
symtab->sym_name);
|
||||
|
||||
|
@ -221,11 +221,13 @@ int kallsyms_symbol_complete(char *prefix_name, int max_len)
|
|||
* Parameters:
|
||||
* prefix_name prefix of a symbol name to lookup
|
||||
* flag 0 means search from the head, 1 means continue search.
|
||||
* buf_size maximum length that can be written to prefix_name
|
||||
* buffer
|
||||
* Returns:
|
||||
* 1 if a symbol matches the given prefix.
|
||||
* 0 if no string found
|
||||
*/
|
||||
int kallsyms_symbol_next(char *prefix_name, int flag)
|
||||
int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size)
|
||||
{
|
||||
int prefix_len = strlen(prefix_name);
|
||||
static loff_t pos;
|
||||
|
@ -235,10 +237,8 @@ int kallsyms_symbol_next(char *prefix_name, int flag)
|
|||
pos = 0;
|
||||
|
||||
while ((name = kdb_walk_kallsyms(&pos))) {
|
||||
if (strncmp(name, prefix_name, prefix_len) == 0) {
|
||||
strncpy(prefix_name, name, strlen(name)+1);
|
||||
return 1;
|
||||
}
|
||||
if (!strncmp(name, prefix_name, prefix_len))
|
||||
return strscpy(prefix_name, name, buf_size);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ int kdb_getphysword(unsigned long *word, unsigned long addr, size_t size)
|
|||
*word = w8;
|
||||
break;
|
||||
}
|
||||
/* drop through */
|
||||
/* fall through */
|
||||
default:
|
||||
diag = KDB_BADWIDTH;
|
||||
kdb_printf("kdb_getphysword: bad width %ld\n", (long) size);
|
||||
|
@ -481,7 +481,7 @@ int kdb_getword(unsigned long *word, unsigned long addr, size_t size)
|
|||
*word = w8;
|
||||
break;
|
||||
}
|
||||
/* drop through */
|
||||
/* fall through */
|
||||
default:
|
||||
diag = KDB_BADWIDTH;
|
||||
kdb_printf("kdb_getword: bad width %ld\n", (long) size);
|
||||
|
@ -525,7 +525,7 @@ int kdb_putword(unsigned long addr, unsigned long word, size_t size)
|
|||
diag = kdb_putarea(addr, w8);
|
||||
break;
|
||||
}
|
||||
/* drop through */
|
||||
/* fall through */
|
||||
default:
|
||||
diag = KDB_BADWIDTH;
|
||||
kdb_printf("kdb_putword: bad width %ld\n", (long) size);
|
||||
|
@ -887,13 +887,13 @@ void debug_kusage(void)
|
|||
__func__, dah_first);
|
||||
if (dah_first) {
|
||||
h_used = (struct debug_alloc_header *)debug_alloc_pool;
|
||||
kdb_printf("%s: h_used %p size %d\n", __func__, h_used,
|
||||
kdb_printf("%s: h_used %px size %d\n", __func__, h_used,
|
||||
h_used->size);
|
||||
}
|
||||
do {
|
||||
h_used = (struct debug_alloc_header *)
|
||||
((char *)h_free + dah_overhead + h_free->size);
|
||||
kdb_printf("%s: h_used %p size %d caller %p\n",
|
||||
kdb_printf("%s: h_used %px size %d caller %px\n",
|
||||
__func__, h_used, h_used->size, h_used->caller);
|
||||
h_free = (struct debug_alloc_header *)
|
||||
(debug_alloc_pool + h_free->next);
|
||||
|
@ -902,7 +902,7 @@ void debug_kusage(void)
|
|||
((char *)h_free + dah_overhead + h_free->size);
|
||||
if ((char *)h_used - debug_alloc_pool !=
|
||||
sizeof(debug_alloc_pool_aligned))
|
||||
kdb_printf("%s: h_used %p size %d caller %p\n",
|
||||
kdb_printf("%s: h_used %px size %d caller %px\n",
|
||||
__func__, h_used, h_used->size, h_used->caller);
|
||||
out:
|
||||
spin_unlock(&dap_lock);
|
||||
|
|
Loading…
Reference in New Issue