Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

um: print register names in wait_for_stub

Since we're basically debugging the userspace (it runs in ptrace)
it's useful to dump out the registers - but they're not readable,
so if something goes wrong it's hard to say what. Print the names
of registers in the register dump so it's easier to look at.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Johannes Berg and committed by
Richard Weinberger
e1e22d0d a15f1e41

+53 -2
+53 -2
arch/um/os-Linux/skas/process.c
··· 28 28 return pid == getpgrp(); 29 29 } 30 30 31 + static const char *ptrace_reg_name(int idx) 32 + { 33 + #define R(n) case HOST_##n: return #n 34 + 35 + switch (idx) { 36 + #ifdef __x86_64__ 37 + R(BX); 38 + R(CX); 39 + R(DI); 40 + R(SI); 41 + R(DX); 42 + R(BP); 43 + R(AX); 44 + R(R8); 45 + R(R9); 46 + R(R10); 47 + R(R11); 48 + R(R12); 49 + R(R13); 50 + R(R14); 51 + R(R15); 52 + R(ORIG_AX); 53 + R(CS); 54 + R(SS); 55 + R(EFLAGS); 56 + #elif defined(__i386__) 57 + R(IP); 58 + R(SP); 59 + R(EFLAGS); 60 + R(AX); 61 + R(BX); 62 + R(CX); 63 + R(DX); 64 + R(SI); 65 + R(DI); 66 + R(BP); 67 + R(CS); 68 + R(SS); 69 + R(DS); 70 + R(FS); 71 + R(ES); 72 + R(GS); 73 + R(ORIG_AX); 74 + #endif 75 + } 76 + return ""; 77 + } 78 + 31 79 static int ptrace_dump_regs(int pid) 32 80 { 33 81 unsigned long regs[MAX_REG_NR]; ··· 85 37 return -errno; 86 38 87 39 printk(UM_KERN_ERR "Stub registers -\n"); 88 - for (i = 0; i < ARRAY_SIZE(regs); i++) 89 - printk(UM_KERN_ERR "\t%d - %lx\n", i, regs[i]); 40 + for (i = 0; i < ARRAY_SIZE(regs); i++) { 41 + const char *regname = ptrace_reg_name(i); 42 + 43 + printk(UM_KERN_ERR "\t%s\t(%2d): %lx\n", regname, i, regs[i]); 44 + } 90 45 91 46 return 0; 92 47 }