From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26394 invoked by alias); 7 Dec 2015 14:48:58 -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 26246 invoked by uid 89); 7 Dec 2015 14:48:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: usplmg21.ericsson.net Received: from usplmg21.ericsson.net (HELO usplmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 07 Dec 2015 14:48:57 +0000 Received: from EUSAAHC008.ericsson.se (Unknown_Domain [147.117.188.96]) by usplmg21.ericsson.net (Symantec Mail Security) with SMTP id 58.65.32102.25C95665; Mon, 7 Dec 2015 15:48:50 +0100 (CET) Received: from [142.133.110.95] (147.117.188.8) by smtp-am.internal.ericsson.com (147.117.188.98) with Microsoft SMTP Server id 14.3.248.2; Mon, 7 Dec 2015 09:48:54 -0500 Subject: Re: [PATCH v6 3/7] Refactor arm_software_single_step to use regcache. To: Yao Qi References: <1449254773-19019-1-git-send-email-antoine.tremblay@ericsson.com> <1449254773-19019-4-git-send-email-antoine.tremblay@ericsson.com> <86fuzes51n.fsf@gmail.com> CC: From: Antoine Tremblay Message-ID: <56659C55.7040205@ericsson.com> Date: Mon, 07 Dec 2015 14:48:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <86fuzes51n.fsf@gmail.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg00132.txt.bz2 On 12/07/2015 09:32 AM, Yao Qi wrote: > Antoine Tremblay writes: > >> +/* Calculate the offset from stack pointer of the pc register on the stack >> + in the case of a sigreturn or sigreturn_rt syscall. */ >> +static int >> +arm_linux_sigreturn_next_pc_offset (unsigned long sp, >> + unsigned long sp_data, >> + unsigned long svc_number) >> +{ >> + /* Offset of R0 register. */ >> + int r0_offset = 0; >> + /* Offset of PC register. */ >> + int pc_offset = 0; >> + >> + gdb_assert (svc_number == 119 || svc_number == 173); >> + >> + /* sigreturn. */ >> + if (svc_number == 119) > > Can we get rid of these magic numbers? > Yes I can find a place to put a define, good idea. >> + { >> + if (sp_data == ARM_NEW_SIGFRAME_MAGIC) >> + r0_offset = ARM_UCONTEXT_SIGCONTEXT + ARM_SIGCONTEXT_R0; >> + else >> + r0_offset = ARM_SIGCONTEXT_R0; >> + } >> + /* rt_sigreturn. */ >> + else if (svc_number == 173) >> + { >> + if (sp_data == sp + ARM_OLD_RT_SIGFRAME_SIGINFO) >> + r0_offset = ARM_OLD_RT_SIGFRAME_UCONTEXT + ARM_UCONTEXT_SIGCONTEXT >> + + ARM_SIGCONTEXT_R0; >> + else >> + r0_offset = ARM_NEW_RT_SIGFRAME_UCONTEXT + ARM_UCONTEXT_SIGCONTEXT >> + + ARM_SIGCONTEXT_R0; >> + } >> + >> + pc_offset = r0_offset + 4 * 15; >> + >> + return pc_offset; >> +} >> + > >> + >> /* At a ptrace syscall-stop, return the syscall number. This either >> comes from the SWI instruction (OABI) or from r7 (EABI). >> >> @@ -862,21 +924,21 @@ arm_linux_get_syscall_number (struct gdbarch *gdbarch, >> instruction to be executed. */ >> >> static CORE_ADDR >> -arm_linux_syscall_next_pc (struct frame_info *frame) >> +arm_linux_syscall_next_pc (struct regcache *regcache) >> { >> - CORE_ADDR pc = get_frame_pc (frame); >> - CORE_ADDR return_addr = 0; >> - int is_thumb = arm_frame_is_thumb (frame); >> + CORE_ADDR pc = regcache_read_pc (regcache); >> + CORE_ADDR next_pc = 0; >> + int is_thumb = arm_is_thumb (regcache); > > Nit: looks you rename return_addr to next_pc. If you don't that, the patch > can be shorter. On the other hand, return_addr sounds a good variable > name to me, which means the address after syscall returns. > Yes, I do since the function is called arm_linux_syscall*_next_pc* and that is called from the get_next_pcs context. It seems more consistent to me to refer to this address as the next program counter in that context. Also I wanted to mark the difference between arm_linux_sigreturn_return_addr and arm_linux_sigreturn_next_pc. Calling return_addr = arm_linux_sigreturn_next_pc seemed weird when there was return_addr = arm_linux_sigreturn_return_addr before. In short I prefer to keep the function name consistent with the return value name. Regards, Antoine