File: get_scno.c

package info (click to toggle)
strace 4.15-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 22,752 kB
  • ctags: 9,462
  • sloc: ansic: 62,976; sh: 7,256; makefile: 3,551; perl: 352; awk: 343; lisp: 44; sed: 6
file content (27 lines) | stat: -rw-r--r-- 690 bytes parent folder | download
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
/* Return codes: 1 - ok, 0 - ignore, other - error. */
static int
arch_get_scno(struct tcb *tcp)
{
	long scno = 0;

	/*
	 * In the new syscall ABI, the system call number is in R3.
	 */
	if (upeek(tcp->pid, 4*(REG_REG0+3), &scno) < 0)
		return -1;

	if (scno < 0) {
		/* Odd as it may seem, a glibc bug has been known to cause
		   glibc to issue bogus negative syscall numbers.  So for
		   our purposes, make strace print what it *should* have been */
		long correct_scno = (scno & 0xff);
		if (debug_flag)
			error_msg("Detected glibc bug: bogus system call"
				  " number = %ld, correcting to %ld",
				  scno, correct_scno);
		scno = correct_scno;
	}

	tcp->scno = scno;
	return 1;
}