This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2] Add an optional "alias" attribute to syscall entries.


Hi John,

On Wed,  3 Oct 2018 10:30:04 -0700
John Baldwin <jhb@FreeBSD.org> wrote:

> When setting a syscall catchpoint by name, catch syscalls whose name
> or alias matches the requested string.
> 
> When the ABI of a system call is changed in the FreeBSD kernel, this
> is implemented by leaving a compatability system call using the old
> ABI at the existing "slot" and allocating a new system call for the
> version using the new ABI.  For example, new fields were added to the
> 'struct kevent' used by the kevent() system call in FreeBSD 12.  The
> previous kevent() system call in FreeBSD 12 kernels is now called
> freebsd11_kevent() and is still used by older binaries compiled
> against the older ABI.  The freebsd11_kevent() system call can be
> tagged with an "alias" attribute of "kevent" permitting 'catch syscall
> kevent' to catch both system calls and providing the expected user
> behavior for both old and new binaries.  It also provides the expected
> behavior if GDB is compiled on an older host (such as a FreeBSD 11
> host).

Very nice.

I read through your patch.  The only problem I found was this
use of a GNU extension involving the use of the ternary ?: operator
without the middle operand.

>  			     char *groups)
>  {
> -  syscall_desc *sysdesc = new syscall_desc (number, name);
> +  syscall_desc *sysdesc = new syscall_desc (number, name, alias ?: "");
>  
>    syscalls_info->syscalls.emplace_back (sysdesc);
>  

In addition, the GDB coding standard specifies that pointer variables
should have explicit comparisons against NULL or nullptr.  So, even if
it weren't a GNU extension, GDB's coding standard would force you to
write that expression using an explicit comparison - which in turn would
necessitate adding the middle argument.  (Which is kind of
unfortunate, because I like the compactness of that expression.)

Anyway, here's a link to the relevant section of the GDB coding standard:

https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Comparison_With_NULL_And_Zero

Kevin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]