xref: /aosp_15_r20/external/strace/linux/aarch64/set_scno.c (revision cf84ac9a129d8ea9952db616b4e9b904c4bdde56)
1*cf84ac9aSAndroid Build Coastguard Worker #ifndef NT_ARM_SYSTEM_CALL
2*cf84ac9aSAndroid Build Coastguard Worker # define NT_ARM_SYSTEM_CALL 0x404
3*cf84ac9aSAndroid Build Coastguard Worker #endif
4*cf84ac9aSAndroid Build Coastguard Worker /*
5*cf84ac9aSAndroid Build Coastguard Worker  * NT_ARM_SYSTEM_CALL regset is supported by linux kernel
6*cf84ac9aSAndroid Build Coastguard Worker  * starting with commit v3.19-rc1~59^2~16.
7*cf84ac9aSAndroid Build Coastguard Worker  */
8*cf84ac9aSAndroid Build Coastguard Worker 
9*cf84ac9aSAndroid Build Coastguard Worker static int
arch_set_scno(struct tcb * tcp,kernel_ulong_t scno)10*cf84ac9aSAndroid Build Coastguard Worker arch_set_scno(struct tcb *tcp, kernel_ulong_t scno)
11*cf84ac9aSAndroid Build Coastguard Worker {
12*cf84ac9aSAndroid Build Coastguard Worker 	unsigned int n = (uint16_t) scno;
13*cf84ac9aSAndroid Build Coastguard Worker 	const struct iovec io = {
14*cf84ac9aSAndroid Build Coastguard Worker 		.iov_base = &n,
15*cf84ac9aSAndroid Build Coastguard Worker 		.iov_len = sizeof(n)
16*cf84ac9aSAndroid Build Coastguard Worker 	};
17*cf84ac9aSAndroid Build Coastguard Worker 	int rc = ptrace(PTRACE_SETREGSET, tcp->pid, NT_ARM_SYSTEM_CALL, &io);
18*cf84ac9aSAndroid Build Coastguard Worker 	if (rc && errno != ESRCH)
19*cf84ac9aSAndroid Build Coastguard Worker 		perror_msg("arch_set_scno: NT_ARM_SYSTEM_CALL pid:%d scno:%#x",
20*cf84ac9aSAndroid Build Coastguard Worker 			   tcp->pid, n);
21*cf84ac9aSAndroid Build Coastguard Worker 	return rc;
22*cf84ac9aSAndroid Build Coastguard Worker }
23