diff options
Diffstat (limited to 'kernel/debug')
-rw-r--r-- | kernel/debug/kdb/kdb_bt.c | 4 | ||||
-rw-r--r-- | kernel/debug/kdb/kdb_io.c | 15 | ||||
-rw-r--r-- | kernel/debug/kdb/kdb_keyboard.c | 4 | ||||
-rw-r--r-- | kernel/debug/kdb/kdb_main.c | 35 | ||||
-rw-r--r-- | kernel/debug/kdb/kdb_private.h | 2 | ||||
-rw-r--r-- | kernel/debug/kdb/kdb_support.c | 28 |
6 files changed, 38 insertions, 50 deletions
diff --git a/kernel/debug/kdb/kdb_bt.c b/kernel/debug/kdb/kdb_bt.c index 6ad4a9fcbd6f..7921ae4fca8d 100644 --- a/kernel/debug/kdb/kdb_bt.c +++ b/kernel/debug/kdb/kdb_bt.c | |||
@@ -179,14 +179,14 @@ kdb_bt(int argc, const char **argv) | |||
179 | kdb_printf("no process for cpu %ld\n", cpu); | 179 | kdb_printf("no process for cpu %ld\n", cpu); |
180 | return 0; | 180 | return 0; |
181 | } | 181 | } |
182 | sprintf(buf, "btt 0x%p\n", KDB_TSK(cpu)); | 182 | sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu)); |
183 | kdb_parse(buf); | 183 | kdb_parse(buf); |
184 | return 0; | 184 | return 0; |
185 | } | 185 | } |
186 | kdb_printf("btc: cpu status: "); | 186 | kdb_printf("btc: cpu status: "); |
187 | kdb_parse("cpu\n"); | 187 | kdb_parse("cpu\n"); |
188 | for_each_online_cpu(cpu) { | 188 | for_each_online_cpu(cpu) { |
189 | sprintf(buf, "btt 0x%p\n", KDB_TSK(cpu)); | 189 | sprintf(buf, "btt 0x%px\n", KDB_TSK(cpu)); |
190 | kdb_parse(buf); | 190 | kdb_parse(buf); |
191 | touch_nmi_watchdog(); | 191 | touch_nmi_watchdog(); |
192 | } | 192 | } |
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index ed5d34925ad0..6a4b41484afe 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c | |||
@@ -216,7 +216,7 @@ static char *kdb_read(char *buffer, size_t bufsize) | |||
216 | int count; | 216 | int count; |
217 | int i; | 217 | int i; |
218 | int diag, dtab_count; | 218 | int diag, dtab_count; |
219 | int key; | 219 | int key, buf_size, ret; |
220 | 220 | ||
221 | 221 | ||
222 | diag = kdbgetintenv("DTABCOUNT", &dtab_count); | 222 | diag = kdbgetintenv("DTABCOUNT", &dtab_count); |
@@ -336,9 +336,8 @@ poll_again: | |||
336 | else | 336 | else |
337 | p_tmp = tmpbuffer; | 337 | p_tmp = tmpbuffer; |
338 | len = strlen(p_tmp); | 338 | len = strlen(p_tmp); |
339 | count = kallsyms_symbol_complete(p_tmp, | 339 | buf_size = sizeof(tmpbuffer) - (p_tmp - tmpbuffer); |
340 | sizeof(tmpbuffer) - | 340 | count = kallsyms_symbol_complete(p_tmp, buf_size); |
341 | (p_tmp - tmpbuffer)); | ||
342 | if (tab == 2 && count > 0) { | 341 | if (tab == 2 && count > 0) { |
343 | kdb_printf("\n%d symbols are found.", count); | 342 | kdb_printf("\n%d symbols are found.", count); |
344 | if (count > dtab_count) { | 343 | if (count > dtab_count) { |
@@ -350,9 +349,13 @@ poll_again: | |||
350 | } | 349 | } |
351 | kdb_printf("\n"); | 350 | kdb_printf("\n"); |
352 | for (i = 0; i < count; i++) { | 351 | for (i = 0; i < count; i++) { |
353 | if (WARN_ON(!kallsyms_symbol_next(p_tmp, i))) | 352 | ret = kallsyms_symbol_next(p_tmp, i, buf_size); |
353 | if (WARN_ON(!ret)) | ||
354 | break; | 354 | break; |
355 | kdb_printf("%s ", p_tmp); | 355 | if (ret != -E2BIG) |
356 | kdb_printf("%s ", p_tmp); | ||
357 | else | ||
358 | kdb_printf("%s... ", p_tmp); | ||
356 | *(p_tmp + len) = '\0'; | 359 | *(p_tmp + len) = '\0'; |
357 | } | 360 | } |
358 | if (i >= dtab_count) | 361 | if (i >= dtab_count) |
diff --git a/kernel/debug/kdb/kdb_keyboard.c b/kernel/debug/kdb/kdb_keyboard.c index 118527aa60ea..750497b0003a 100644 --- a/kernel/debug/kdb/kdb_keyboard.c +++ b/kernel/debug/kdb/kdb_keyboard.c | |||
@@ -173,11 +173,11 @@ int kdb_get_kbd_char(void) | |||
173 | case KT_LATIN: | 173 | case KT_LATIN: |
174 | if (isprint(keychar)) | 174 | if (isprint(keychar)) |
175 | break; /* printable characters */ | 175 | break; /* printable characters */ |
176 | /* drop through */ | 176 | /* fall through */ |
177 | case KT_SPEC: | 177 | case KT_SPEC: |
178 | if (keychar == K_ENTER) | 178 | if (keychar == K_ENTER) |
179 | break; | 179 | break; |
180 | /* drop through */ | 180 | /* fall through */ |
181 | default: | 181 | default: |
182 | return -1; /* ignore unprintables */ | 182 | return -1; /* ignore unprintables */ |
183 | } | 183 | } |
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index bb4fe4e1a601..d72b32c66f7d 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c | |||
@@ -1192,7 +1192,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, | |||
1192 | if (reason == KDB_REASON_DEBUG) { | 1192 | if (reason == KDB_REASON_DEBUG) { |
1193 | /* special case below */ | 1193 | /* special case below */ |
1194 | } else { | 1194 | } else { |
1195 | kdb_printf("\nEntering kdb (current=0x%p, pid %d) ", | 1195 | kdb_printf("\nEntering kdb (current=0x%px, pid %d) ", |
1196 | kdb_current, kdb_current ? kdb_current->pid : 0); | 1196 | kdb_current, kdb_current ? kdb_current->pid : 0); |
1197 | #if defined(CONFIG_SMP) | 1197 | #if defined(CONFIG_SMP) |
1198 | kdb_printf("on processor %d ", raw_smp_processor_id()); | 1198 | 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, | |||
1208 | */ | 1208 | */ |
1209 | switch (db_result) { | 1209 | switch (db_result) { |
1210 | case KDB_DB_BPT: | 1210 | case KDB_DB_BPT: |
1211 | kdb_printf("\nEntering kdb (0x%p, pid %d) ", | 1211 | kdb_printf("\nEntering kdb (0x%px, pid %d) ", |
1212 | kdb_current, kdb_current->pid); | 1212 | kdb_current, kdb_current->pid); |
1213 | #if defined(CONFIG_SMP) | 1213 | #if defined(CONFIG_SMP) |
1214 | kdb_printf("on processor %d ", raw_smp_processor_id()); | 1214 | kdb_printf("on processor %d ", raw_smp_processor_id()); |
@@ -1493,6 +1493,7 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr, | |||
1493 | char cbuf[32]; | 1493 | char cbuf[32]; |
1494 | char *c = cbuf; | 1494 | char *c = cbuf; |
1495 | int i; | 1495 | int i; |
1496 | int j; | ||
1496 | unsigned long word; | 1497 | unsigned long word; |
1497 | 1498 | ||
1498 | memset(cbuf, '\0', sizeof(cbuf)); | 1499 | memset(cbuf, '\0', sizeof(cbuf)); |
@@ -1538,25 +1539,9 @@ static void kdb_md_line(const char *fmtstr, unsigned long addr, | |||
1538 | wc.word = word; | 1539 | wc.word = word; |
1539 | #define printable_char(c) \ | 1540 | #define printable_char(c) \ |
1540 | ({unsigned char __c = c; isascii(__c) && isprint(__c) ? __c : '.'; }) | 1541 | ({unsigned char __c = c; isascii(__c) && isprint(__c) ? __c : '.'; }) |
1541 | switch (bytesperword) { | 1542 | for (j = 0; j < bytesperword; j++) |
1542 | case 8: | ||
1543 | *c++ = printable_char(*cp++); | 1543 | *c++ = printable_char(*cp++); |
1544 | *c++ = printable_char(*cp++); | 1544 | addr += bytesperword; |
1545 | *c++ = printable_char(*cp++); | ||
1546 | *c++ = printable_char(*cp++); | ||
1547 | addr += 4; | ||
1548 | case 4: | ||
1549 | *c++ = printable_char(*cp++); | ||
1550 | *c++ = printable_char(*cp++); | ||
1551 | addr += 2; | ||
1552 | case 2: | ||
1553 | *c++ = printable_char(*cp++); | ||
1554 | addr++; | ||
1555 | case 1: | ||
1556 | *c++ = printable_char(*cp++); | ||
1557 | addr++; | ||
1558 | break; | ||
1559 | } | ||
1560 | #undef printable_char | 1545 | #undef printable_char |
1561 | } | 1546 | } |
1562 | } | 1547 | } |
@@ -2048,7 +2033,7 @@ static int kdb_lsmod(int argc, const char **argv) | |||
2048 | if (mod->state == MODULE_STATE_UNFORMED) | 2033 | if (mod->state == MODULE_STATE_UNFORMED) |
2049 | continue; | 2034 | continue; |
2050 | 2035 | ||
2051 | kdb_printf("%-20s%8u 0x%p ", mod->name, | 2036 | kdb_printf("%-20s%8u 0x%px ", mod->name, |
2052 | mod->core_layout.size, (void *)mod); | 2037 | mod->core_layout.size, (void *)mod); |
2053 | #ifdef CONFIG_MODULE_UNLOAD | 2038 | #ifdef CONFIG_MODULE_UNLOAD |
2054 | kdb_printf("%4d ", module_refcount(mod)); | 2039 | kdb_printf("%4d ", module_refcount(mod)); |
@@ -2059,7 +2044,7 @@ static int kdb_lsmod(int argc, const char **argv) | |||
2059 | kdb_printf(" (Loading)"); | 2044 | kdb_printf(" (Loading)"); |
2060 | else | 2045 | else |
2061 | kdb_printf(" (Live)"); | 2046 | kdb_printf(" (Live)"); |
2062 | kdb_printf(" 0x%p", mod->core_layout.base); | 2047 | kdb_printf(" 0x%px", mod->core_layout.base); |
2063 | 2048 | ||
2064 | #ifdef CONFIG_MODULE_UNLOAD | 2049 | #ifdef CONFIG_MODULE_UNLOAD |
2065 | { | 2050 | { |
@@ -2341,7 +2326,7 @@ void kdb_ps1(const struct task_struct *p) | |||
2341 | return; | 2326 | return; |
2342 | 2327 | ||
2343 | cpu = kdb_process_cpu(p); | 2328 | cpu = kdb_process_cpu(p); |
2344 | kdb_printf("0x%p %8d %8d %d %4d %c 0x%p %c%s\n", | 2329 | kdb_printf("0x%px %8d %8d %d %4d %c 0x%px %c%s\n", |
2345 | (void *)p, p->pid, p->parent->pid, | 2330 | (void *)p, p->pid, p->parent->pid, |
2346 | kdb_task_has_cpu(p), kdb_process_cpu(p), | 2331 | kdb_task_has_cpu(p), kdb_process_cpu(p), |
2347 | kdb_task_state_char(p), | 2332 | kdb_task_state_char(p), |
@@ -2354,7 +2339,7 @@ void kdb_ps1(const struct task_struct *p) | |||
2354 | } else { | 2339 | } else { |
2355 | if (KDB_TSK(cpu) != p) | 2340 | if (KDB_TSK(cpu) != p) |
2356 | kdb_printf(" Error: does not match running " | 2341 | kdb_printf(" Error: does not match running " |
2357 | "process table (0x%p)\n", KDB_TSK(cpu)); | 2342 | "process table (0x%px)\n", KDB_TSK(cpu)); |
2358 | } | 2343 | } |
2359 | } | 2344 | } |
2360 | } | 2345 | } |
@@ -2687,7 +2672,7 @@ int kdb_register_flags(char *cmd, | |||
2687 | for_each_kdbcmd(kp, i) { | 2672 | for_each_kdbcmd(kp, i) { |
2688 | if (kp->cmd_name && (strcmp(kp->cmd_name, cmd) == 0)) { | 2673 | if (kp->cmd_name && (strcmp(kp->cmd_name, cmd) == 0)) { |
2689 | kdb_printf("Duplicate kdb command registered: " | 2674 | kdb_printf("Duplicate kdb command registered: " |
2690 | "%s, func %p help %s\n", cmd, func, help); | 2675 | "%s, func %px help %s\n", cmd, func, help); |
2691 | return 1; | 2676 | return 1; |
2692 | } | 2677 | } |
2693 | } | 2678 | } |
diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h index 1e5a502ba4a7..2118d8258b7c 100644 --- a/kernel/debug/kdb/kdb_private.h +++ b/kernel/debug/kdb/kdb_private.h | |||
@@ -83,7 +83,7 @@ typedef struct __ksymtab { | |||
83 | unsigned long sym_start; | 83 | unsigned long sym_start; |
84 | unsigned long sym_end; | 84 | unsigned long sym_end; |
85 | } kdb_symtab_t; | 85 | } kdb_symtab_t; |
86 | extern int kallsyms_symbol_next(char *prefix_name, int flag); | 86 | extern int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size); |
87 | extern int kallsyms_symbol_complete(char *prefix_name, int max_len); | 87 | extern int kallsyms_symbol_complete(char *prefix_name, int max_len); |
88 | 88 | ||
89 | /* Exported Symbols for kernel loadable modules to use. */ | 89 | /* Exported Symbols for kernel loadable modules to use. */ |
diff --git a/kernel/debug/kdb/kdb_support.c b/kernel/debug/kdb/kdb_support.c index 990b3cc526c8..50bf9b119bad 100644 --- a/kernel/debug/kdb/kdb_support.c +++ b/kernel/debug/kdb/kdb_support.c | |||
@@ -40,7 +40,7 @@ | |||
40 | int kdbgetsymval(const char *symname, kdb_symtab_t *symtab) | 40 | int kdbgetsymval(const char *symname, kdb_symtab_t *symtab) |
41 | { | 41 | { |
42 | if (KDB_DEBUG(AR)) | 42 | if (KDB_DEBUG(AR)) |
43 | kdb_printf("kdbgetsymval: symname=%s, symtab=%p\n", symname, | 43 | kdb_printf("kdbgetsymval: symname=%s, symtab=%px\n", symname, |
44 | symtab); | 44 | symtab); |
45 | memset(symtab, 0, sizeof(*symtab)); | 45 | memset(symtab, 0, sizeof(*symtab)); |
46 | symtab->sym_start = kallsyms_lookup_name(symname); | 46 | symtab->sym_start = kallsyms_lookup_name(symname); |
@@ -88,7 +88,7 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab) | |||
88 | char *knt1 = NULL; | 88 | char *knt1 = NULL; |
89 | 89 | ||
90 | if (KDB_DEBUG(AR)) | 90 | if (KDB_DEBUG(AR)) |
91 | kdb_printf("kdbnearsym: addr=0x%lx, symtab=%p\n", addr, symtab); | 91 | kdb_printf("kdbnearsym: addr=0x%lx, symtab=%px\n", addr, symtab); |
92 | memset(symtab, 0, sizeof(*symtab)); | 92 | memset(symtab, 0, sizeof(*symtab)); |
93 | 93 | ||
94 | if (addr < 4096) | 94 | if (addr < 4096) |
@@ -149,7 +149,7 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab) | |||
149 | symtab->mod_name = "kernel"; | 149 | symtab->mod_name = "kernel"; |
150 | if (KDB_DEBUG(AR)) | 150 | if (KDB_DEBUG(AR)) |
151 | kdb_printf("kdbnearsym: returns %d symtab->sym_start=0x%lx, " | 151 | kdb_printf("kdbnearsym: returns %d symtab->sym_start=0x%lx, " |
152 | "symtab->mod_name=%p, symtab->sym_name=%p (%s)\n", ret, | 152 | "symtab->mod_name=%px, symtab->sym_name=%px (%s)\n", ret, |
153 | symtab->sym_start, symtab->mod_name, symtab->sym_name, | 153 | symtab->sym_start, symtab->mod_name, symtab->sym_name, |
154 | symtab->sym_name); | 154 | symtab->sym_name); |
155 | 155 | ||
@@ -221,11 +221,13 @@ int kallsyms_symbol_complete(char *prefix_name, int max_len) | |||
221 | * Parameters: | 221 | * Parameters: |
222 | * prefix_name prefix of a symbol name to lookup | 222 | * prefix_name prefix of a symbol name to lookup |
223 | * flag 0 means search from the head, 1 means continue search. | 223 | * flag 0 means search from the head, 1 means continue search. |
224 | * buf_size maximum length that can be written to prefix_name | ||
225 | * buffer | ||
224 | * Returns: | 226 | * Returns: |
225 | * 1 if a symbol matches the given prefix. | 227 | * 1 if a symbol matches the given prefix. |
226 | * 0 if no string found | 228 | * 0 if no string found |
227 | */ | 229 | */ |
228 | int kallsyms_symbol_next(char *prefix_name, int flag) | 230 | int kallsyms_symbol_next(char *prefix_name, int flag, int buf_size) |
229 | { | 231 | { |
230 | int prefix_len = strlen(prefix_name); | 232 | int prefix_len = strlen(prefix_name); |
231 | static loff_t pos; | 233 | static loff_t pos; |
@@ -235,10 +237,8 @@ int kallsyms_symbol_next(char *prefix_name, int flag) | |||
235 | pos = 0; | 237 | pos = 0; |
236 | 238 | ||
237 | while ((name = kdb_walk_kallsyms(&pos))) { | 239 | while ((name = kdb_walk_kallsyms(&pos))) { |
238 | if (strncmp(name, prefix_name, prefix_len) == 0) { | 240 | if (!strncmp(name, prefix_name, prefix_len)) |
239 | strncpy(prefix_name, name, strlen(name)+1); | 241 | return strscpy(prefix_name, name, buf_size); |
240 | return 1; | ||
241 | } | ||
242 | } | 242 | } |
243 | return 0; | 243 | return 0; |
244 | } | 244 | } |
@@ -432,7 +432,7 @@ int kdb_getphysword(unsigned long *word, unsigned long addr, size_t size) | |||
432 | *word = w8; | 432 | *word = w8; |
433 | break; | 433 | break; |
434 | } | 434 | } |
435 | /* drop through */ | 435 | /* fall through */ |
436 | default: | 436 | default: |
437 | diag = KDB_BADWIDTH; | 437 | diag = KDB_BADWIDTH; |
438 | kdb_printf("kdb_getphysword: bad width %ld\n", (long) size); | 438 | 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) | |||
481 | *word = w8; | 481 | *word = w8; |
482 | break; | 482 | break; |
483 | } | 483 | } |
484 | /* drop through */ | 484 | /* fall through */ |
485 | default: | 485 | default: |
486 | diag = KDB_BADWIDTH; | 486 | diag = KDB_BADWIDTH; |
487 | kdb_printf("kdb_getword: bad width %ld\n", (long) size); | 487 | 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) | |||
525 | diag = kdb_putarea(addr, w8); | 525 | diag = kdb_putarea(addr, w8); |
526 | break; | 526 | break; |
527 | } | 527 | } |
528 | /* drop through */ | 528 | /* fall through */ |
529 | default: | 529 | default: |
530 | diag = KDB_BADWIDTH; | 530 | diag = KDB_BADWIDTH; |
531 | kdb_printf("kdb_putword: bad width %ld\n", (long) size); | 531 | kdb_printf("kdb_putword: bad width %ld\n", (long) size); |
@@ -887,13 +887,13 @@ void debug_kusage(void) | |||
887 | __func__, dah_first); | 887 | __func__, dah_first); |
888 | if (dah_first) { | 888 | if (dah_first) { |
889 | h_used = (struct debug_alloc_header *)debug_alloc_pool; | 889 | h_used = (struct debug_alloc_header *)debug_alloc_pool; |
890 | kdb_printf("%s: h_used %p size %d\n", __func__, h_used, | 890 | kdb_printf("%s: h_used %px size %d\n", __func__, h_used, |
891 | h_used->size); | 891 | h_used->size); |
892 | } | 892 | } |
893 | do { | 893 | do { |
894 | h_used = (struct debug_alloc_header *) | 894 | h_used = (struct debug_alloc_header *) |
895 | ((char *)h_free + dah_overhead + h_free->size); | 895 | ((char *)h_free + dah_overhead + h_free->size); |
896 | kdb_printf("%s: h_used %p size %d caller %p\n", | 896 | kdb_printf("%s: h_used %px size %d caller %px\n", |
897 | __func__, h_used, h_used->size, h_used->caller); | 897 | __func__, h_used, h_used->size, h_used->caller); |
898 | h_free = (struct debug_alloc_header *) | 898 | h_free = (struct debug_alloc_header *) |
899 | (debug_alloc_pool + h_free->next); | 899 | (debug_alloc_pool + h_free->next); |
@@ -902,7 +902,7 @@ void debug_kusage(void) | |||
902 | ((char *)h_free + dah_overhead + h_free->size); | 902 | ((char *)h_free + dah_overhead + h_free->size); |
903 | if ((char *)h_used - debug_alloc_pool != | 903 | if ((char *)h_used - debug_alloc_pool != |
904 | sizeof(debug_alloc_pool_aligned)) | 904 | sizeof(debug_alloc_pool_aligned)) |
905 | kdb_printf("%s: h_used %p size %d caller %p\n", | 905 | kdb_printf("%s: h_used %px size %d caller %px\n", |
906 | __func__, h_used, h_used->size, h_used->caller); | 906 | __func__, h_used, h_used->size, h_used->caller); |
907 | out: | 907 | out: |
908 | spin_unlock(&dap_lock); | 908 | spin_unlock(&dap_lock); |