1 /*
2 * Copyright (c) 2015-2021 The strace developers.
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7
8 /* Return codes: 1 - ok, 0 - ignore, other - error. */
9 static int
10 arch_get_scno(struct tcb *tcp)
11 {
12 /* Retrieve the syscall trap instruction. */
13 unsigned long trap;
14 errno = 0;
15 trap = ptrace(PTRACE_PEEKTEXT, tcp->pid, (void *) sparc_regs.tpc, 0);
16 if (errno == 0) {
17 trap >>= 32;
18 switch (trap) {
19 case 0x91d02010:
20 /* Linux/SPARC syscall trap. */
21 update_personality(tcp, 1);
22 break;
23 case 0x91d0206d:
24 /* Linux/SPARC64 syscall trap. */
25 update_personality(tcp, 0);
26 break;
27 }
28 }
29
30 tcp->scno = sparc_regs.u_regs[U_REG_G1];
31 return 1;
32 }