[PATCH] Add support for catching system calls to native FreeBSD targets.
John Baldwin
jhb@freebsd.org
Fri Jun 24 00:24:00 GMT 2016
On Monday, June 20, 2016 11:56:40 PM Pedro Alves wrote:
> Hi John,
>
> This looks good to me. Just some minor nits below.
>
> On 06/14/2016 09:57 PM, John Baldwin wrote:
> > versions of FreeBSD include the identifier of the current
> > system call when reporting a system call entry or exit event in the
> > ptrace_lwpinfo structure obtained via PT_LWPINFO in fbsd_wait. As
> > such, FreeBSD native targets do not use the gdbarch method to fetch
> > the system call code. In addition, FreeBSD register sets fetched via
> > ptrace do not include an equivalent of 'orig_rax' (on amd64 for
> > example), so the system call code cannot be extracted from the
> > available registers during a system call exit. However, GDB assumes
> > that system call catch points are not supported if the gdbarch method
> > is not present. As a workaround, FreeBSD ABIs install a dummy gdbarch
> > method that throws an internal_error if it is ever invoked.
> >
>
> We should probably get rid of this gdbarch method, by making linux-nat.c
> (the only caller) call an arch-specific target_ops override instead of
> a gdbarch method, like gdbserver's equivalent code does.
>
> To replace the break-catch-syscall.c error, I think that it'd be reasonable
> to remove it altogether, and for Linux targets that don't implement
> the gdbarch hook yet, instead just always intercept all syscalls, reporting
> an <unknown> syscall number.
>
> But what you did seems like a reasonable thing to do as long as do
> have the gdbarch hook.
So I'm not quite sure how to implement an arch-specific target_op.
There are various linux_nat_set_* functions that accept a function pointer
but then just set a global variable. The amd64 version might have to copy
with different ABIs rather than depending on teh i386 gdbarch method, etc.
One option that is a bit smaller in scale would be to move the error
in break-catch-syscall.c into linux_child_set_syscall_catchpoint in
linux-nat.c. It could return 1 to fail the request if the gdbarch
method wasn't present.
--
John Baldwin
More information about the Gdb-patches
mailing list