History

kdb: print real address of pointers instead of hashed addresses

Since commit ad67b74d2469 ("printk: hash addresses printed with %p"), all pointers printed with %p are printed with hashed addresses instead of real addresses in order to avoid leaking addresses in dmesg and syslog. But this applies to kdb too, with is unfortunate: Entering kdb (current=0x(ptrval), pid 329) due to Keyboard Entry kdb> ps 15 sleeping system daemon (state M) processes suppressed, use 'ps A' to see all. Task Addr Pid Parent [*] cpu State Thread Command 0x(ptrval) 329 328 1 0 R 0x(ptrval) *sh 0x(ptrval) 1 0 0 0 S 0x(ptrval) init 0x(ptrval) 3 2 0 0 D 0x(ptrval) rcu_gp 0x(ptrval) 4 2 0 0 D 0x(ptrval) rcu_par_gp 0x(ptrval) 5 2 0 0 D 0x(ptrval) kworker/0:0 0x(ptrval) 6 2 0 0 D 0x(ptrval) kworker/0:0H 0x(ptrval) 7 2 0 0 D 0x(ptrval) kworker/u2:0 0x(ptrval) 8 2 0 0 D 0x(ptrval) mm_percpu_wq 0x(ptrval) 10 2 0 0 D 0x(ptrval) rcu_preempt The whole purpose of kdb is to debug, and for debugging real addresses need to be known. In addition, data displayed by kdb doesn't go into dmesg. This patch replaces all %p by %px in kdb in order to display real addresses.

Christophe Leroy committed 8 years ago

Commit 568fb6f1 parent dded2e12 files · +13 −13Browse files

Showing the changes to kernel/debug/kdb/kdb_support.c (1 of 2 files). Show all

Unified · Split

kernel/debug/kdb/kdb_support.c+6−6
@@ -40,7 +40,7 @@ · 39 unmodified lines
4040 int kdbgetsymval(const char *symname, kdb_symtab_t *symtab)
4141 {
4242 if (KDB_DEBUG(AR))
43− kdb_printf("kdbgetsymval: symname=%s, symtab=%p\n", symname,
43+ kdb_printf("kdbgetsymval: symname=%s, symtab=%px\n", symname,
4444 symtab);
4545 memset(symtab, 0, sizeof(*symtab));
4646 symtab->sym_start = kallsyms_lookup_name(symname);
@@ -88,7 +88,7 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab) · 41 unmodified lines
8888 char *knt1 = NULL;
8989
9090 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);
9292 memset(symtab, 0, sizeof(*symtab));
9393
9494 if (addr < 4096)
@@ -149,7 +149,7 @@ int kdbnearsym(unsigned long addr, kdb_symtab_t *symtab) · 54 unmodified lines
149149 symtab->mod_name = "kernel";
150150 if (KDB_DEBUG(AR))
151151 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,
153153 symtab->sym_start, symtab->mod_name, symtab->sym_name,
154154 symtab->sym_name);
155155
@@ -887,13 +887,13 @@ void debug_kusage(void) · 731 unmodified lines
887887 __func__, dah_first);
888888 if (dah_first) {
889889 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,
891891 h_used->size);
892892 }
893893 do {
894894 h_used = (struct debug_alloc_header *)
895895 ((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",
897897 __func__, h_used, h_used->size, h_used->caller);
898898 h_free = (struct debug_alloc_header *)
899899 (debug_alloc_pool + h_free->next);
@@ -902,7 +902,7 @@ void debug_kusage(void) · 2 unmodified lines
902902 ((char *)h_free + dah_overhead + h_free->size);
903903 if ((char *)h_used - debug_alloc_pool !=
904904 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",
906906 __func__, h_used, h_used->size, h_used->caller);
907907 out:
908908 spin_unlock(&dap_lock);