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_main.c (1 of 2 files). Show all

Unified · Split

kernel/debug/kdb/kdb_main.c+7−7
@@ -1192,7 +1192,7 @@ static int kdb_local(kdb_reason_t reason, int error, struct pt_regs *regs, · 1191 unmodified lines
11921192 if (reason == KDB_REASON_DEBUG) {
11931193 /* special case below */
11941194 } else {
1195− kdb_printf("\nEntering kdb (current=0x%p, pid %d) ",
1195+ kdb_printf("\nEntering kdb (current=0x%px, pid %d) ",
11961196 kdb_current, kdb_current ? kdb_current->pid : 0);
11971197 #if defined(CONFIG_SMP)
11981198 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, · 9 unmodified lines
12081208 */
12091209 switch (db_result) {
12101210 case KDB_DB_BPT:
1211− kdb_printf("\nEntering kdb (0x%p, pid %d) ",
1211+ kdb_printf("\nEntering kdb (0x%px, pid %d) ",
12121212 kdb_current, kdb_current->pid);
12131213 #if defined(CONFIG_SMP)
12141214 kdb_printf("on processor %d ", raw_smp_processor_id());
@@ -2048,7 +2048,7 @@ static int kdb_lsmod(int argc, const char **argv) · 833 unmodified lines
20482048 if (mod->state == MODULE_STATE_UNFORMED)
20492049 continue;
20502050
2051− kdb_printf("%-20s%8u 0x%p ", mod->name,
2051+ kdb_printf("%-20s%8u 0x%px ", mod->name,
20522052 mod->core_layout.size, (void *)mod);
20532053 #ifdef CONFIG_MODULE_UNLOAD
20542054 kdb_printf("%4d ", module_refcount(mod));
@@ -2059,7 +2059,7 @@ static int kdb_lsmod(int argc, const char **argv) · 4 unmodified lines
20592059 kdb_printf(" (Loading)");
20602060 else
20612061 kdb_printf(" (Live)");
2062− kdb_printf(" 0x%p", mod->core_layout.base);
2062+ kdb_printf(" 0x%px", mod->core_layout.base);
20632063
20642064 #ifdef CONFIG_MODULE_UNLOAD
20652065 {
@@ -2341,7 +2341,7 @@ void kdb_ps1(const struct task_struct *p) · 275 unmodified lines
23412341 return;
23422342
23432343 cpu = kdb_process_cpu(p);
2344− kdb_printf("0x%p %8d %8d %d %4d %c 0x%p %c%s\n",
2344+ kdb_printf("0x%px %8d %8d %d %4d %c 0x%px %c%s\n",
23452345 (void *)p, p->pid, p->parent->pid,
23462346 kdb_task_has_cpu(p), kdb_process_cpu(p),
23472347 kdb_task_state_char(p),
@@ -2354,7 +2354,7 @@ void kdb_ps1(const struct task_struct *p) · 6 unmodified lines
23542354 } else {
23552355 if (KDB_TSK(cpu) != p)
23562356 kdb_printf(" Error: does not match running "
2357− "process table (0x%p)\n", KDB_TSK(cpu));
2357+ "process table (0x%px)\n", KDB_TSK(cpu));
23582358 }
23592359 }
23602360 }
@@ -2687,7 +2687,7 @@ int kdb_register_flags(char *cmd, · 326 unmodified lines
26872687 for_each_kdbcmd(kp, i) {
26882688 if (kp->cmd_name && (strcmp(kp->cmd_name, cmd) == 0)) {
26892689 kdb_printf("Duplicate kdb command registered: "
2690− "%s, func %p help %s\n", cmd, func, help);
2690+ "%s, func %px help %s\n", cmd, func, help);
26912691 return 1;
26922692 }
26932693 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t