From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14737 invoked by alias); 16 Dec 2015 15:59:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 14726 invoked by uid 89); 16 Dec 2015 15:59:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 16 Dec 2015 15:59:20 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 9F3142DC379; Wed, 16 Dec 2015 15:59:19 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBGFxIAb031804; Wed, 16 Dec 2015 10:59:18 -0500 Message-ID: <56718A56.8000304@redhat.com> Date: Wed, 16 Dec 2015 15:59:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Antoine Tremblay , Yao Qi CC: gdb-patches@sourceware.org Subject: Re: [PATCH v7 3/8] Use xml-syscall to compare syscall numbers in arm_linux_sigreturn_return-addr. References: <1449583641-18156-1-git-send-email-antoine.tremblay@ericsson.com> <1449583641-18156-4-git-send-email-antoine.tremblay@ericsson.com> <86io45ql3x.fsf@gmail.com> <566AC1AA.3030007@ericsson.com> In-Reply-To: <566AC1AA.3030007@ericsson.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-12/txt/msg00300.txt.bz2 On 12/11/2015 12:29 PM, Antoine Tremblay wrote: > > > On 12/11/2015 06:29 AM, Yao Qi wrote: >> Antoine Tremblay 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? 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. Thanks, Pedro Alves