From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 3C1FE386F447 for ; Tue, 16 Jun 2020 00:58:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3C1FE386F447 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 0EF231E5F9; Mon, 15 Jun 2020 20:58:38 -0400 (EDT) Subject: Re: [PATCH v2 3/4] arc: Add GNU/Linux support for ARC To: Shahab Vahedi Cc: gdb-patches@sourceware.org, Shahab Vahedi , Anton Kolesov , Tom Tromey , Francois Bedard References: <20200326125206.13120-1-shahab.vahedi@gmail.com> <20200428160437.1585-1-shahab.vahedi@gmail.com> <20200428160437.1585-4-shahab.vahedi@gmail.com> <6f07f665-a003-5dad-bace-bfdcbd77a906@simark.ca> <20200615231349.GB1816@gmail.com> From: Simon Marchi Message-ID: <16890cdb-a1da-a149-7797-df197da4c720@simark.ca> Date: Mon, 15 Jun 2020 20:58:38 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200615231349.GB1816@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jun 2020 00:58:41 -0000 On 2020-06-15 7:13 p.m., Shahab Vahedi wrote: > On Thu, May 14, 2020 at 11:09:08AM -0400, Simon Marchi wrote: >> On 2020-04-28 12:04 p.m., Shahab Vahedi via Gdb-patches wrote: >>> +/* Initialization specific to Linux environment. */ >>> + >>> +static void >>> +arc_linux_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch) >>> +{ >>> + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); >>> + >>> + if (arc_debug) >>> + debug_printf ("arc-linux: GNU/Linux OS/ABI initialization.\n"); >>> + >>> + /* If we are using Linux, we have in uClibc >>> + (libc/sysdeps/linux/arc/bits/setjmp.h): >>> + >>> + typedef int __jmp_buf[13+1+1+1]; //r13-r25, fp, sp, blink >>> + >>> + Where "blink" is a stored PC of a caller function. >>> + */ >>> + tdep->jb_pc = 15; >> >> I don't really understand this, could you dumb it down a bit for me? > > In advance, I appologize if my explanation is not right on the spot > or is too verbose. I am not 100% sure what is not clear, so I try to > explain as much as I can. > > If you mean why "tdep->jb_pc" is 15 and what the comments mean, then: > > fp -> Frame Pointer register > sp -> Stack Pointer register > blink -> Branch and LINK register (acts like a "return" register) > > blink register is set (implicitly) when "bl @name_of_fuction" instruction > is used. It will point to the instruction that comes after "bl" (branch > and link). e.g.: > > 0x100: add r0, r1, r2 > 0x104: bl @galaxy_far_away # pc=@galaxy_far_away; blink=0x108 > 0x108: add r3, r4, r5 > > a simple "j(ump) blink" will return from the function. > > ----- > > The layout of "__jump_buf" looks like: > 0..12: stored registers r13, r14, ..., r25 > 13: stored fp > 14: stored sp > 15: stored blink > > This is how the "calling" convention in ARC saves the > registers before switching the frame to another function. > > I hope it is clear now. Ah ok, and that value is the offset of the PC in the buffer. I see that the comment above the definition of the jb_pc explains that, I might have missed it the first time. Thanks, Simon