2007-05-28 22:59:46

by Trent Waddington

[permalink] [raw]
Subject: Portable syscall inspection

Someone finally noticed that my program that uses ptrace only works on i386..
and, by the looks of it, there is no portable way to refer to the
registers of a
user_regs_struct when inspecting a system call.

I will probably end up making a header file for each architecture that
defines where
in the user_regs_struct things like the syscall number, the return
value and the first 3 parameters are..

has anyone done this already? or can otherwise save me a lot of time?

Thanks,

Trent


2007-05-31 10:20:19

by Ralf Baechle

[permalink] [raw]
Subject: Re: Portable syscall inspection

On Tue, May 29, 2007 at 08:59:37AM +1000, Trent Waddington wrote:

> Someone finally noticed that my program that uses ptrace only works on
> i386..
> and, by the looks of it, there is no portable way to refer to the
> registers of a
> user_regs_struct when inspecting a system call.

Correct.

> I will probably end up making a header file for each architecture that
> defines where
> in the user_regs_struct things like the syscall number, the return
> value and the first 3 parameters are..

Also consider that some architectures pass parts of the arguments in
registers which on yet others are passed in memory. Sometimes padding
arguments are needed and many more oddities. Similar for results.
Inescapably such a program is a perment maintenance nightmare.

> has anyone done this already? or can otherwise save me a lot of time?

Similar things have been tried before but nothing that would be remotely
sane.

Ralf

2007-05-31 10:27:22

by Trent Waddington

[permalink] [raw]
Subject: Re: Portable syscall inspection

On 5/29/07, Ralf Baechle <[email protected]> wrote:
> Also consider that some architectures pass parts of the arguments in
> registers which on yet others are passed in memory. Sometimes padding
> arguments are needed and many more oddities. Similar for results.
> Inescapably such a program is a perment maintenance nightmare.

Yes, I see. This nightmare appears to be the burden of the strace
people, god bless them. I'm looking at moving their plethora of
#ifdefs into a library so others can be spared the nightmare.

Thanks,

Trent