From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by sourceware.org (Postfix) with ESMTPS id 65F2D3857823 for ; Thu, 27 May 2021 11:32:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 65F2D3857823 Received: by mail-qv1-xf33.google.com with SMTP id k2so647375qvc.5 for ; Thu, 27 May 2021 04:32:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=2OQMmRG3F37IuA6jE5ZBsgymISKAJiOl/aMXBoHX1t4=; b=XdJ8KRY93Q6b/54lk7VdCkBRdiEsULwLBZ3DYA4Mm+yYw3LtuLAlH/c+KPA/EL7QMV JqL0ENuAei65yjjwjLRyvMpGkzH0q4Os5r3BGClB1O0XrGd1lASBabBC43xpdKp2/JvS z8ypO9tCDTD2t3sU3DR9DDTM2R66FQvu3g6EicTmPDNSB417LKsM5ohkq1bzpRlmoePb lu1qoCMzd+zwYB6xzi2aUH/wt/HexT0ZbsW/C4uMxq+QHq67LD0kZy9QxxnFJO09XXCD B+t3zpcLTMGsUBnICnkLvKbOSqPvc2t9g5rYnWkPp/bFNdi/utNmIy+/MMIGcMFBOf5L 16Ng== X-Gm-Message-State: AOAM531oZbtD9Tg3bxtbRCK4J69/CBXaB65BXR8As9DyTmZ+ulFCBstJ FbY+xZ+tLkXasNPlcrYoO/p5vvNSSsNIhQ== X-Google-Smtp-Source: ABdhPJzWxz2Cx64S1QzGJmUhCfXFx9hbsl6WWzKyJ0kbcO+d9Qw8jx6yzfC3Fs8+OhnQUW2EsUDpow== X-Received: by 2002:ad4:5a46:: with SMTP id ej6mr1914106qvb.57.1622115132929; Thu, 27 May 2021 04:32:12 -0700 (PDT) Received: from ?IPv6:2804:7f0:4841:5c9d:8973:dfa9:5713:eb5c? ([2804:7f0:4841:5c9d:8973:dfa9:5713:eb5c]) by smtp.gmail.com with ESMTPSA id j28sm1155671qkl.35.2021.05.27.04.32.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 May 2021 04:32:12 -0700 (PDT) Subject: [PING] [PATCH] Update the core file architecture if a target description is present From: Luis Machado To: gdb-patches@sourceware.org References: <20210518202015.3492089-1-luis.machado@linaro.org> Message-ID: Date: Thu, 27 May 2021 08:32:10 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210518202015.3492089-1-luis.machado@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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: Thu, 27 May 2021 11:32:14 -0000 On 5/18/21 5:20 PM, Luis Machado wrote: > At the moment, the core target has its own gdbarch (m_core_gdbarch), and that > gets set from the core_bfd on the core target's constructor. > > That gdbarch doesn't contain a target description because it is constructed > before we get a chance to fetch the target description. > > As a result, some hooks that depend on the target description being set are > not set, and that leads to problems. One of the examples is > gdbarch_report_signal_info, which is used to show AArch64 tag violation > information. > > Fix this by updating the core file gdbarch after fetching the target > description. > > gdb/ChangeLog: > > YYYY-MM-DD Luis Machado > > * corelow.c: Include "observable.h". > (class core_target) : New method. > (core_on_new_gdbarch): New function. > (_initialize_corelow): Register with observer "architecture_changed". > --- > gdb/corelow.c | 35 +++++++++++++++++++++++++++++++++++ > 1 file changed, 35 insertions(+) > > diff --git a/gdb/corelow.c b/gdb/corelow.c > index a1943ab2ea6..452b4dd4f9a 100644 > --- a/gdb/corelow.c > +++ b/gdb/corelow.c > @@ -50,6 +50,7 @@ > #include > #include "gdbcmd.h" > #include "xml-tdesc.h" > +#include "observable.h" > > #ifndef O_LARGEFILE > #define O_LARGEFILE 0 > @@ -107,6 +108,12 @@ class core_target final : public process_stratum_target > return m_core_gdbarch; > } > > + /* Setter, see variable definition. */ > + void set_core_gdbarch (gdbarch *arch) > + { > + m_core_gdbarch = arch; > + } > + > /* See definition. */ > void get_core_register_section (struct regcache *regcache, > const struct regset *regset, > @@ -1185,6 +1192,30 @@ maintenance_print_core_file_backed_mappings (const char *args, int from_tty) > targ->info_proc_mappings (targ->core_gdbarch ()); > } > > +static void > +core_on_new_gdbarch (struct gdbarch *newarch) > +{ > + /* The target architecture has changed. Attempt to update the core > + target's architecture with NEWARCH's target description. */ > + struct gdbarch_info info; > + > + gdbarch_info_init (&info); > + info.abfd = core_bfd; > + info.target_desc = gdbarch_target_desc (newarch); > + > + struct gdbarch *new_core_arch = gdbarch_find_by_info (info); > + > + /* If we've found a valid architecture, update the core target. */ > + if (new_core_arch != nullptr) > + { > + /* Update the core file architecture. */ > + struct core_target *target = get_current_core_target (); > + > + if (target != nullptr) > + target->set_core_gdbarch (new_core_arch); > + } > +} > + > void _initialize_corelow (); > void > _initialize_corelow () > @@ -1194,4 +1225,8 @@ _initialize_corelow () > maintenance_print_core_file_backed_mappings, > _("Print core file's file-backed mappings."), > &maintenanceprintlist); > + > + /* Register observer to listen to architecture changes. */ > + gdb::observers::architecture_changed.attach (core_on_new_gdbarch, > + "py-unwind"); > } >