aboutsummaryrefslogtreecommitdiff
blob: b59a03667813144bd4a5acf7d5b1e953f81486c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#define SB_NO_TRACE_ARCH
#if 0 /* XXX: broken sometimes #293632 */

/* Since sparc's g0 register is hardcoded to 0 in the ISA, the kernel does not
 * bother copying it out when using the regs ptrace.  Instead it shifts things
 * by one and stores [g1..g7] in [0..6] and [o0..o7] in [7..14] (leaving the
 * last u_reg[15] unused).
 *
 * Oddly, the kernel defines are not adjusted to the values as they written in
 * the register structure -- UREG_G0 is 0, UREG_G1 is 1, etc...  So we have to
 * define our own to get correct behavior.  Also, the kernel uses UREG_I# when
 * it's easier for us to think of it in terms of UREG_O# (register windows!).
 *
 * This should work for both 32 and 64 bit Linux userland.
 */
#define U_REG_G1 0
#define U_REG_O0 7

/* Sparc systems have swapped the addr/data args. */
#undef trace_get_regs
#define trace_get_regs(regs) do_ptrace(PTRACE_GETREGS, regs, NULL)
#undef trace_set_regs
#define trace_set_regs(regs) do_ptrace(PTRACE_SETREGS, regs, NULL)

#define trace_reg_sysnum u_regs[U_REG_G1]

static long trace_raw_ret(void *vregs)
{
	trace_regs *regs = vregs;
	return regs->u_regs[U_REG_O0];
}

static void trace_set_ret(void *vregs, int err)
{
	trace_regs *regs = vregs;
	/* The carry bit is used to flag errors. */
	regs->psr |= PSR_C;
	/* Userland negates the value on sparc. */
	regs->u_regs[U_REG_O0] = err;
	trace_set_regs(regs);
}

static unsigned long trace_arg(void *vregs, int num)
{
	trace_regs *regs = vregs;
	if (num < 7)
		return regs->u_regs[U_REG_O0 + num - 1];
	else
		return -1;
}

#endif