Skip to content

Commit e1e22d0

Browse files
jmberg-intelrichardweinberger
authored andcommitted
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>
1 parent a15f1e4 commit e1e22d0

1 file changed

Lines changed: 53 additions & 2 deletions

File tree

‎arch/um/os-Linux/skas/process.c‎

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,54 @@ int is_skas_winch(int pid, int fd, void *data)
2828
return pid == getpgrp();
2929
}
3030

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+
3179
static int ptrace_dump_regs(int pid)
3280
{
3381
unsigned long regs[MAX_REG_NR];
@@ -37,8 +85,11 @@ static int ptrace_dump_regs(int pid)
3785
return -errno;
3886

3987
printk(UM_KERN_ERR "Stub registers -\n");
40-
for (i = 0; i < ARRAY_SIZE(regs); i++)
41-
printk(UM_KERN_ERR "\t%d - %lx\n", i, regs[i]);
88+
for (i = 0; i < ARRAY_SIZE(regs); i++) {
89+
const char *regname = ptrace_reg_name(i);
90+
91+
printk(UM_KERN_ERR "\t%s\t(%2d): %lx\n", regname, i, regs[i]);
92+
}
4293

4394
return 0;
4495
}

0 commit comments

Comments
 (0)