Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 05 Dec 2016 16:42:15 -0800
From:      John Baldwin <jhb@freebsd.org>
To:        src-committers@freebsd.org
Cc:        svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r309589 - head/usr.bin/truss
Message-ID:  <18568727.ZCvfzOzSEO@ralph.baldwin.cx>
In-Reply-To: <201612060039.uB60d0eE075130@repo.freebsd.org>
References:  <201612060039.uB60d0eE075130@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday, December 06, 2016 12:39:00 AM John Baldwin wrote:
> Author: jhb
> Date: Tue Dec  6 00:39:00 2016
> New Revision: 309589
> URL: https://svnweb.freebsd.org/changeset/base/309589
> 
> Log:
>   Rework syscall structure lookups.
>   
>   Avoid always using an O(n^2) loop over known syscall structures with
>   strcmp() on each system call.  Instead, use a per-ABI cache indexed by
>   the system call number. The first 1024 system calls (which should cover
>   all of the normal system calls in currently-supported ABIs) use a flat array
>   indexed by the system call number to find system call structure.  For other
>   system calls, a linked list of structures storing an integer to structure
>   mapping is stored in the ABI.  The linked list isn't very smart, but it
>   should only be used by buggy applications invoking unknown system calls.
>   
>   This also fixes handling of unknown system calls which currently trigger
>   a NULL pointer dereference.
>   
>   Reviewed by:	kib
>   MFC after:	2 weeks

I of course forgot:

Differential Revision: https://reviews.freebsd.org/D8639

The table + linked-list could perhaps be replaced by a hash table, but
I don't quite feel like writing a new hash table from scratch.  One
option would be to make truss a C++ program and use unordered_map<>.

We could then turn the procabi thing into a class which might look a bit
nicer (and use constructors to initialize the hash table instead of
the inline STAILQ_HEAD_INITIALIZER).

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?18568727.ZCvfzOzSEO>