Re: [PATCH v7 3/8] Use xml-syscall to compare syscall numbers in arm_linux_sigreturn_return-addr.

Antoine Tremblay
2015-12-16T16:05:19Z

On 12/16/2015 10:59 AM, Pedro Alves wrote:
> On 12/11/2015 12:29 PM, Antoine Tremblay wrote:
>>
>>
>> On 12/11/2015 06:29 AM, Yao Qi wrote:
>>> Antoine Tremblay <antoine.tremblay@ericsson.com> writes:
>>>
>>>> It also adds a new function to xml-syscall.h/c to compare syscalls numbers
>>>> called is_syscall.
>>>
>>> Why don't we use existing get_syscall_by_name in
>>> arm_linux_sigreturn_return_addr rather than adding a new function is_syscall?
>>>
>>
>> This is because it complicated the code a lot just to compare a syscall
>> I have to do what is in the is_syscall function.
>>
>> And I have to do that over and over... so might as well be in a function ?
>>
>>
>
> The issue is the having to handle the struct syscall instance, right?

Right.

> So instead of is_syscall, you could add a function that returns the
> syscall number directly, like:
>
> int
> get_syscall_number (struct gdbarch *gdbarch,
> const char *syscall_name)
> {
> init_syscalls_info (gdbarch);
>
> return xml_get_syscall_number (gdbarch, syscall_name);
> }
>
> and then users could use the more natural == comparison:
>
> /* Is this a sigreturn or rt_sigreturn syscall? */
> - if (svc_number == 119 || svc_number == 173)
> + if (get_syscall_number (gdbarch, "sigreturn") == svc_number)
> + || get_syscall_number (gdbarch, "rt_sigreturn") == svc_number))
> {
>
> and maybe other places could be simplified to use get_syscall_number
> for other purposes than direct comparison.

I like the idea. I'll redo it like that.

Thanks,
Antoine