Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: Pedro Alves <palves@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 2/3] Add an optional "alias" attribute to syscall entries.
Date: Fri, 09 Nov 2018 16:52:00 -0000	[thread overview]
Message-ID: <55380054-16e3-ef67-c105-beea11766860@FreeBSD.org> (raw)
In-Reply-To: <2ab3f4b5-cc23-8b3d-dd55-66646cdffff1@redhat.com>

On 11/9/18 8:31 AM, Pedro Alves wrote:
> Hi,
> 
> On 11/06/2018 05:54 PM, John Baldwin wrote:
> 
>> --- a/gdb/syscalls/gdb-syscalls.dtd
>> +++ b/gdb/syscalls/gdb-syscalls.dtd
>> @@ -12,4 +12,5 @@
>>  <!ATTLIST syscall
>>  	name			CDATA	#REQUIRED
>>  	number			CDATA	#REQUIRED
>> +	alias			CDATA	#IMPLIED
>>  	groups			CDATA	#IMPLIED>
> 
> I think there should be a NEWS entry for this.

Ok.

> I'd think there should be a docs update as well, but it
> looks like this dtd isn't documented in the manual.  :-/
> 
> 
>> +	  /* We have a name.  Let's check if it's valid and fetch a
>> +	     list of matching numbers.  */
>> +	  std::vector<int> numbers = get_syscalls_by_name (gdbarch, cur_name);
>>  
>> -	  if (s.number == UNKNOWN_SYSCALL)
>> +	  if (numbers.empty ())
>>  	    /* Here we have to issue an error instead of a warning,
>>  	       because GDB cannot do anything useful if there's no
>>  	       syscall number to be caught.  */
>>  	    error (_("Unknown syscall name '%s'."), cur_name);
>>  
>>  	  /* Ok, it's valid.  */
>> -	  result.push_back (s.number);
>> +	  for (int number : numbers)
>> +	    result.push_back (number);
> 
> Nit: this return-vector interface seems like leads to a bit of unnecessary
> work, and double the number of necessary vector/heap allocations -- if
> get_syscalls_by_name were passed RESULT instead of returning a new vector,
> it could add to RESULT directly?  The code above would like something like this
> instead with get_syscalls_by_name returning true/false to indicate
> whether something was added:
> 
> 	  /* We have a name.  Let's check if it's valid and fetch a
> 	     list of matching numbers.  */
> 	  if (!get_syscalls_by_name (gdbarch, cur_name, result))
>  	    /* Here we have to issue an error instead of a warning,
> 	       because GDB cannot do anything useful if there's no
> 	       syscall number to be caught.  */
>   	    error (_("Unknown syscall name '%s'."), cur_name);
> 
> That means there's no need to copy numbers between the vectors
> (since there's only one vector).
> 
> Same for get_syscalls_by_group.

Oh, yes, that is a much better idea.  I will adopt that change in both
patches.

> Note that instead of:
> 
>> +	  for (int number : numbers)
>> +	    result.push_back (number);
> 
> You could write:
> 
>   result.insert (result.end (), numbers.begin (), numbers.end ());
> 
> which may be more efficient assuming insert is smart enough
> to call std::vector::reserve to allocate space in one go.

Ok.  I wasn't quite sure if there was a more efficient idiom to use.  It's
a bit of a shame std::vector<> doesn't have an explicit append/join method
similar to list.append() in Python.

-- 
John Baldwin

                                                                            


  reply	other threads:[~2018-11-09 16:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06 17:56 [PATCH v2 0/3] Update FreeBSD's syscall table John Baldwin
2018-11-06 17:56 ` [PATCH v2 2/3] Add an optional "alias" attribute to syscall entries John Baldwin
2018-11-09  4:34   ` Kevin Buettner
2018-11-09 15:28   ` Simon Marchi
2018-11-09 15:36     ` Simon Marchi
2018-11-09 16:31   ` Pedro Alves
2018-11-09 16:52     ` John Baldwin [this message]
2018-11-06 17:56 ` [PATCH v2 1/3] Return a vector of integers from get_syscalls_by_group John Baldwin
2018-11-09  4:27   ` Kevin Buettner
2018-11-09 17:55     ` John Baldwin
2018-11-06 17:56 ` [PATCH v2 3/3] Update the FreeBSD system call table to match FreeBSD 12.0 John Baldwin
2018-11-09  4:38   ` Kevin Buettner
2018-11-09 16:34   ` Pedro Alves
2018-11-09 17:36     ` John Baldwin
2018-11-06 18:49 ` [PATCH v2 0/3] Update FreeBSD's syscall table Sergio Durigan Junior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55380054-16e3-ef67-c105-beea11766860@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox