# arch-specific requests of ptrace ___________________________
#
%{
#ifndef PPC_PTRACE_GETHWDBGINFO
# define PPC_PTRACE_GETHWDBGINFO 0x89
#endif
#ifndef PPC_PTRACE_SETHWDEBUG
# define PPC_PTRACE_SETHWDEBUG 0x88
#endif
#ifndef PPC_PTRACE_DELHWDEBUG
# define PPC_PTRACE_DELHWDEBUG 0x87
#endif
#ifndef PTRACE_GETVSRREGS
# define PTRACE_GETVSRREGS 27
#endif
#ifndef PTRACE_SETVSRREGS
# define PTRACE_SETVSRREGS 28
#endif
#ifndef PTRACE_GETREGS
# define PTRACE_GETREGS 12
#endif
#ifndef PTRACE_SETREGS
# define PTRACE_SETREGS 13
#endif
#ifndef PTRACE_GETFPREGS
# define PTRACE_GETFPREGS 14
#endif
#ifndef PTRACE_SETFPREGS
# define PTRACE_SETFPREGS 15
#endif
#ifndef PTRACE_GETEVRREGS
# define PTRACE_GETEVRREGS 20
#endif
#ifndef PTRACE_SETEVRREGS
# define PTRACE_SETEVRREGS 21
#endif
#ifndef PTRACE_GETREGS64
# define PTRACE_GETREGS64 22
#endif
#ifndef PTRACE_SETREGS64
# define PTRACE_SETREGS64 23
#endif
#ifndef PTRACE_GET_DEBUGREG
# define PTRACE_GET_DEBUGREG 25
#endif
#ifndef PTRACE_SET_DEBUGREG
# define PTRACE_SET_DEBUGREG 26
#endif
#ifndef PTRACE_SINGLEBLOCK
# define PTRACE_SINGLEBLOCK 0x100
#endif

/* (old) PTRACE requests with inverted arguments */
#ifndef PPC_PTRACE_GETREGS
#define PPC_PTRACE_GETREGS 0x99
#endif
#ifndef PPC_PTRACE_SETREGS
#define PPC_PTRACE_SETREGS 0x98
#endif
#ifndef PPC_PTRACE_GETFPREGS
#define PPC_PTRACE_GETFPREGS 0x97
#endif
#ifndef PPC_PTRACE_SETFPREGS
#define PPC_PTRACE_SETFPREGS 0x96
#endif
%}
function _arch_ptrace_argstr(request, pid, addr, data)
{
	if (request == %{ PTRACE_GETVRREGS %})
		// TODO: Retrieve *data in .return
		return sprintf ("PTRACE_GETVRREGS, %d, data=%p", pid, data)
	if (request == %{ PTRACE_SETVRREGS %})
		// TODO: Retrieve *data here
		return sprintf ("PTRACE_SETVRREGS, %d, data=%p", pid, data)
	if (request == %{ PTRACE_GETEVRREGS %})
		// TODO: Retrieve *data in .return
		return sprintf ("PTRACE_GETEVRREGS, %d, data=%p", pid, data)
	if (request == %{ PTRACE_SETEVRREGS %})
		// TODO: Retrieve *data here
		return sprintf ("PTRACE_SETEVRREGS, %d, data=%p", pid, data)
	if (request == %{ PTRACE_GETVSRREGS %})
		// TODO: Retrieve *data in .return
		return sprintf ("PTRACE_GETVSRREGS, %d, data=%p", pid, data)
	if (request == %{ PTRACE_SETVSRREGS %})
		// TODO: Retrieve *data here
		return sprintf ("PTRACE_SETVSRREGS, %d, data=%p", pid, data)
	if (request == %{ PTRACE_GET_DEBUGREG %})
		// ADDR is now required by kernel to be 0.
		return sprintf ("PTRACE_GET_DEBUGREG, %d, (addr=%p), data=%p", pid, addr, data)
	if (request == %{ PTRACE_SET_DEBUGREG %})
		// ADDR is now required by kernel to be 0.
		return sprintf ("PTRACE_SET_DEBUGREG, %d, (addr=%p), data=%p", pid, addr, data)
	if (request == %{ PTRACE_GETREGS %})
		// TODO: Retrieve *data in .return
		return sprintf ("PTRACE_GETREGS, %d, data=%p", pid, data)
	if (request == %{ PTRACE_SETREGS %})
		// TODO: Retrieve *data here
		return sprintf ("PTRACE_SETREGS, %d, data=%p", pid, data)
	if (request == %{ PTRACE_GETFPREGS %})
		// TODO: Retrieve *data in .return
		return sprintf ("PTRACE_GETFPREGS, %d, data=%p", pid, data)
	if (request == %{ PTRACE_SETFPREGS %})
		// TODO: Retrieve *data here
		return sprintf ("PTRACE_SETFPREGS, %d, data=%p", pid, data)
	if (request == %{ PTRACE_GETREGS64 %})
		// TODO: Retrieve *data in .return
		return sprintf ("PTRACE_GETREGS64, %d, data=%p", pid, data)
	if (request == %{ PTRACE_SETREGS64 %})
		// TODO: Retrieve *data here
		return sprintf ("PTRACE_SETREGS64, %d, data=%p", pid, data)
	if (request == %{ PPC_PTRACE_GETREGS %})
		// TODO: Retrieve *data in .return
		return sprintf ("PPC_PTRACE_GETREGS, %d, data=%p", pid, data)
	if (request == %{ PPC_PTRACE_SETREGS %})
		// TODO: Retrieve *data here
		return sprintf ("PPC_PTRACE_SETREGS, %d, data=%p", pid, data)
	if (request == %{ PPC_PTRACE_GETFPREGS %})
		// TODO: Retrieve *data in .return
		return sprintf ("PPC_PTRACE_GETFPREGS, %d, data=%p", pid, data)
	if (request == %{ PPC_PTRACE_SETFPREGS %})
		// TODO: Retrieve *data here
		return sprintf ("PPC_PTRACE_SETFPREGS, %d, data=%p", pid, data)
	if (request == %{ PPC_PTRACE_PEEKTEXT_3264 %})
		// TODO: Retrieve *data in .return
		return sprintf ("PPC_PTRACE_PEEKTEXT_3264, %d, *addr=%p, data=%p", pid, user_long(addr), data)
	if (request == %{ PPC_PTRACE_PEEKDATA_3264 %})
		// TODO: Retrieve *data in .return
		return sprintf ("PPC_PTRACE_PEEKDATA_3264, %d, *addr=%p, data=%p", pid, user_long(addr), data)
	if (request == %{ PPC_PTRACE_POKETEXT_3264 %})
		return sprintf ("PPC_PTRACE_POKETEXT_3264, %d, *addr=%p, data=%p", pid, user_long(addr), data)
	if (request == %{ PPC_PTRACE_POKEDATA_3264 %})
		return sprintf ("PPC_PTRACE_POKEDATA_3264, %d, *addr=%p, data=%p", pid, user_long(addr), data)
	if (request == %{ PPC_PTRACE_PEEKUSR_3264 %})
		return sprintf ("PPC_PTRACE_PEEKUSR_3264, %d, addr=%p, data=%p", pid, addr, data)
	if (request == %{ PPC_PTRACE_POKEUSR_3264 %})
		return sprintf ("PPC_PTRACE_POKEUSR_3264, %d, addr=%p, data=%p", pid, addr, data)
	if (request == %{ PTRACE_SINGLEBLOCK %})
		return sprintf ("PTRACE_SINGLEBLOCK, %d, %s", pid, _signal_name (data))
	if (request == %{ PPC_PTRACE_GETHWDBGINFO %})
		// TODO: Retrieve *data in .return
		return sprintf ("PPC_PTRACE_GETHWDBGINFO, %d, data=%p", pid, data)
	if (request == %{ PPC_PTRACE_SETHWDEBUG %})
		// TODO: Retrieve *data here
		return sprintf ("PPC_PTRACE_SETHWDEBUG, %d, data=%p", pid, data)
	if (request == %{ PPC_PTRACE_DELHWDEBUG %})
		return sprintf ("PPC_PTRACE_DELHWDEBUG, %d, data=%d", pid, data)
}

function _ptrace_return_arch_prctl_addr:long(request:long, addr:long, data:long)
{
	return 0
}
