From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kBDJDn/Hd1+WPAAAWB0awg (envelope-from ) for ; Fri, 02 Oct 2020 20:36:15 -0400 Received: by simark.ca (Postfix, from userid 112) id 39FE01EF44; Fri, 2 Oct 2020 20:36:15 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E6EE81E4B5 for ; Fri, 2 Oct 2020 20:36:13 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 92597393C85F; Sat, 3 Oct 2020 00:36:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92597393C85F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1601685373; bh=sp0zQugZxAfYXIuEAfxBRbAZ0oIq/vU54WJjrTDK4xo=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=fRVQDlPl6EBOgwesxcSgtk8XGKtfudQ7L/8LNV+6sUs/Jw/1Zcs95OEDOJc4+u8zT owIpD2pOq+UT/EULFA2GaumGF5adJKzJ0KuxtQDLq6zuRBKhh1NSee/Mtu7O51LFDu vbs3naIYu+hCC0gX77J+mjWz7iJ8ynHHX6ft0PPI= Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by sourceware.org (Postfix) with ESMTPS id D07403894C24 for ; Sat, 3 Oct 2020 00:36:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D07403894C24 Received: by mail-il1-x143.google.com with SMTP id l16so2820964ilt.13 for ; Fri, 02 Oct 2020 17:36:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KGYLIfSXYQZ0+hIQ+mjheH74csIUmPxeZ4Knzsr/fJY=; b=dYNYzOFJfNyW2eKpkmMc74v6nWfGQ7gX3PRT2FHzuSxwYjt+aAvanr4Tlk4zKpiSFX qB8PgJC+E/NIIQ9emgX5sMNxDzFjstfUate3788vwwP+2zC0C7tqhQ0lMx3L3X0W/Ifw ZKyEOPIDTL8aPlN0UoFz7yLZNtteRDuweRVuQawBLFI5awQnQ3yt+VakFkhyInlem5Ct 2ozPQ+b+naOzadqwKrZk0uaGdJTo8qrApmj1pCRi4Y5lJIXrqWB5vRIvwHpCdAmwxkO6 k1ore9UD6sN/rFlalDp1N4mmC++Zp54LFDJqNl636ivsR+MBG7ksqZd7ahklT9ADLQUd yiYA== X-Gm-Message-State: AOAM532hFZbQxuvSLq1yuO3Kv2vLaLi8/ctippOd4cb303uVpxRte+TM 1FW9PbFoeJOHPm+kn3dwad1wA7A8jl5jwutLKldN/O+yo+k= X-Google-Smtp-Source: ABdhPJxvATNYOt1AmbphFP4CdAsStQMARnRY0s9KSort3ct8cA58seqhf5ARUFCr0JKvuGXgy4Ce7qNRGFVSPEFwEF8= X-Received: by 2002:a92:c301:: with SMTP id n1mr3490748ilg.247.1601685369111; Fri, 02 Oct 2020 17:36:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 2 Oct 2020 17:35:57 -0700 Message-ID: Subject: Re: [PATCH] gdb: add support for handling core dumps on arm-none-eabi To: Simon Marchi Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: , From: Paul Mathieu via Gdb-patches Reply-To: Paul Mathieu Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Thanks for the feedback Simon! I did send a new version of that patch as a reply to Luis' feedback, you seem to have commented on the first one. Should I have sent that patch in a different thread? Some quick comments, just skimming the patch. I won't comment about > indentation issue, because I don't know if it has been modified by the > email client. > > I support what Luis has already said, it needs to be documented what > this format is, where it is defined/specified, who produces it, etc. > I'm not sure how (and where) this could be documented, are there examples of such documentation? Since I couldn't find any prior art for bare metal targets, I went for something that I assumed was a standard core file format. > gdb/ChangeLog: > > 2018-09-29 Robin Haberkorn > > 2020-10-02 Paul Mathieu > > > > * arm-none-tdep.c: Added. Provide CPU registers from a core file > > * floating point registers not yet supported (FIXME) > > > > > > --- > > gdb/Makefile.in | 2 + > > gdb/arm-none-tdep.c | 140 ++++++++++++++++++++++++++++++++++++++++++++ > > gdb/configure.tgt | 2 +- > > 3 files changed, 143 insertions(+), 1 deletion(-) > > create mode 100644 gdb/arm-none-tdep.c > > > > diff --git a/gdb/Makefile.in b/gdb/Makefile.in > > index dbede7a9cf..7f0e3ea0b0 100644 > > --- a/gdb/Makefile.in > > +++ b/gdb/Makefile.in > > @@ -720,6 +720,7 @@ ALL_TARGET_OBS = \ > > arm-obsd-tdep.o \ > > arm-pikeos-tdep.o \ > > arm-symbian-tdep.o \ > > + arm-none-tdep.o \ > > arm-tdep.o \ > > arm-wince-tdep.o \ > > avr-tdep.o \ > > @@ -2150,6 +2151,7 @@ ALLDEPFILES = \ > > arm-nbsd-tdep.c \ > > arm-obsd-tdep.c \ > > arm-symbian-tdep.c \ > > + arm-none-tdep.c \ > > arm-tdep.c \ > > avr-tdep.c \ > > bfin-linux-tdep.c \ > > diff --git a/gdb/arm-none-tdep.c b/gdb/arm-none-tdep.c > > new file mode 100644 > > index 0000000000..7641a9f7f0 > > --- /dev/null > > +++ b/gdb/arm-none-tdep.c > > @@ -0,0 +1,140 @@ > > +/* Native-dependent code for GDB targetting embedded ARM. > > Maybe "bare-metal ARM" would be more precise? Embedded doesn't mean "no > OS", which I think is what you want to mean here. > Sure, bare-metal ARM works. > > > + > > + Copyright (C) 2020 Free Software Foundation, Inc. > > + > > + This file is part of GDB. > > + > > + This program is free software; you can redistribute it and/or modify > > + it under the terms of the GNU General Public License as published by > > + the Free Software Foundation; either version 3 of the License, or > > + (at your option) any later version. > > + > > + This program is distributed in the hope that it will be useful, > > + but WITHOUT ANY WARRANTY; without even the implied warranty of > > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > + GNU General Public License for more details. > > + > > + You should have received a copy of the GNU General Public License > > + along with this program. If not, see >. > > */ > > + > > +#include "defs.h" > > +#include "command.h" > > +#include "gdbarch.h" > > +#include "gdbcore.h" > > +#include "inferior.h" > > +#include "target.h" > > +#include "regcache.h" > > + > > +#include "arch/arm.h" > > + > > +#if 0 > > +#include > > +#include > > +#ifdef HAVE_SYS_PROCFS_H > > +#include > > +#endif > > +#endif > > + > > +typedef struct { > > + uint32_t reg[18]; > > +} gdb_gregset_t; > > Use: > > struct gdb_gregset_t > { > ... > }; > > We are in C++, so when you use it you can still omit the "struct" keyword. > Done in the patch I sent after Luis' review. > > > + > > +#define ARM_CPSR_GREGNUM 16 > > + > > +extern int arm_apcs_32; > > Don't declare this here, there's a suitable declaration in arm-tdep.h. > Done. > > > + > > +static void > > +arm_supply_gregset (struct regcache *regcache, const gdb_gregset_t > *gregs) > > +{ > > + struct gdbarch *gdbarch = regcache->arch (); > > + enum bfd_endian byte_order = type_byte_order (register_type(gdbarch, > 0)); > > + int regno; > > + CORE_ADDR reg_pc; > > + gdb_byte pc_buf[ARM_INT_REGISTER_SIZE]; > > + > > + for (regno = ARM_A1_REGNUM; regno < ARM_PC_REGNUM; regno++) > > + regcache->raw_supply (regno, gregs->reg + regno); > > + > > + if (arm_apcs_32) > > + regcache->raw_supply (ARM_PS_REGNUM, gregs->reg + ARM_CPSR_GREGNUM); > > + else > > + regcache->raw_supply (ARM_PS_REGNUM, gregs->reg + ARM_PC_REGNUM); > > + > > + reg_pc = extract_unsigned_integer ((const gdb_byte*)(gregs->reg + > > ARM_PC_REGNUM), > > Space before *, and after the cast: > > (const gdb_byte *) (gregs...) > Done. > > Simon >