From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 4B1D73858D38 for ; Fri, 12 Apr 2024 14:40:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4B1D73858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4B1D73858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712932841; cv=none; b=Ff8eKrDtT1cpNR92WsDOgKwsOlQKgzRgjLRSswl7sQmlayizbYt/K8ybFawnzYoLcSvHSjegHgeL+0KIGHpm5tJCAl6BI6SfHDq9UY/noExQtDWamHkqF+KoMU4otkSeTdtFhDbRg7BIjostHvFq2GxJ+DbyJSw46LB4CDMsl3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712932841; c=relaxed/simple; bh=Plb/A+sORA+DsyEk3a+c3NHQrKtLV7Uss3Zrr8c6xsg=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=KryvwKwQEvWTvBhR9xffLd5S3fdQ8vn2hfFFrsgKG4bTRlzxrNx2A96Kve3yoD55cyrcSb8HDJyrBMpSiYwvNgQcfoXqlvsRE/Qpz6wUNEh9WUh8VQ4ibgrUxmdatCfEsxaFSbGIsnqrxRtbGdkyX5NcJNsdK7FZsnNEJcyf5CY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712932838; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8BMqFOPgqFEROMGc8heMk56tX40IxvqZPUZ8vsHhKmo=; b=aOtw802IJERIlxJG7hdfcKLXdG+cBD+sDoZf5wzGiXUsaXWfd16Wml/rbptKps31Kv2Xc6 tR04DFBOzndS05h927nMrisHsvHS2mTrOS0UjSXaYC2Yep5l6BbIr88Xp+LZjqEig7aHnp Z8+xZ4UqbUDiH/Dwza2XzJznsw9p5wE= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-79-rLOUzqFAOpq7jvPIJ55FyQ-1; Fri, 12 Apr 2024 10:40:37 -0400 X-MC-Unique: rLOUzqFAOpq7jvPIJ55FyQ-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-6183c4a6d18so15346177b3.3 for ; Fri, 12 Apr 2024 07:40:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712932836; x=1713537636; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=8BMqFOPgqFEROMGc8heMk56tX40IxvqZPUZ8vsHhKmo=; b=ru2ZeRx+eUthfmTQOA9JHUNAUzUaCWPkXfv+tcAH0RIK9rv/bdwlJb8y4b8/28VmF3 AWs6oi+xKIj4yV8T6hhDbpvUo/B+woCjZR9oDL0GGFARwCc7GwQcBCg6N/AEzWwH5v5X hRsjH+ohRDSzKi+UyNrKswS9+Fsd0u3B2SR7FB9DoPpkvs7ci+oRGGOzlGAEraVFjNAC 8W8lqGQi/gc4pE6cG0c9Sn33nWD+4MxDI3tKX1JicxwTOXanD3+X/dljXP2tr5qTVrWq NE5GQyrJ9TtuIpjKgBsJqHNaWVHeoUApXLUYjB8gVaI8mrsR/F1PAckuqsi1deBlEOP/ 7mKw== X-Forwarded-Encrypted: i=1; AJvYcCXCEFTtlQrs+GS3+WGpd/oBfPezGj4bgQrZBO2Fh9KYpoypXi1Q8ni3A15O9np0eeFQuN5mvyLdPKSSbQeQ4NamoUybLHHgr5tFDw== X-Gm-Message-State: AOJu0Yx1NOmZQdDkfJSnkwWPR+p71gNjI6NAjtPbW/UzRsgnrgMeEhft RjIlw3SdG5W0SDjzd9fg/JNX/uvgwRL4PeJFM24LCq/DW054HxOVC+8qMIBchnKBvFx2aInoI1m ajbmUTF7zDpmPLUzDdeQ29DPAsh7iCjrwpnUEYmotd9Bo+EdLZfY3toY0IQrRJ+EJK246YQ== X-Received: by 2002:a81:6d8f:0:b0:618:485f:747f with SMTP id i137-20020a816d8f000000b00618485f747fmr2894773ywc.8.1712932836359; Fri, 12 Apr 2024 07:40:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkzfEHdHIe5zQok25zqLSNcnCpR1WvFXPE1tS88Rhc/C64uY8P5NfaUxSd84JRxvZd1z08hg== X-Received: by 2002:a81:6d8f:0:b0:618:485f:747f with SMTP id i137-20020a816d8f000000b00618485f747fmr2894754ywc.8.1712932835771; Fri, 12 Apr 2024 07:40:35 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:92c5::1001? ([2804:14d:8084:92c5::1001]) by smtp.gmail.com with ESMTPSA id ej6-20020ad45a46000000b00696b1050be8sm2404525qvb.133.2024.04.12.07.40.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Apr 2024 07:40:35 -0700 (PDT) Message-ID: <89a78bd0-504b-4fd5-a085-066c2efe492b@redhat.com> Date: Fri, 12 Apr 2024 11:40:31 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/5] gdb: Migrate frame unwinders to use C++ classes To: Guinevere Larsen , "gdb-patches@sourceware.org" References: <20240408201915.1482831-1-blarsen@redhat.com> <20240408201915.1482831-4-blarsen@redhat.com> From: Guinevere Larsen In-Reply-To: <20240408201915.1482831-4-blarsen@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="------------b9MFY9eYVkru2OqcNsd0mfOf" Content-Language: en-US X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is a multi-part message in MIME format. --------------b9MFY9eYVkru2OqcNsd0mfOf Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit I mentioned as a reply to the cover letter that this patch series had a crash in arm32 bit. This patch had the problem and a quick fix I inlined. Trimming the diff for readability. On 4/8/24 17:19, Guinevere Larsen wrote: > diff --git a/gdb/tramp-frame.c b/gdb/tramp-frame.c > index 2fcc3814e59..7fee4d5c71d 100644 > --- a/gdb/tramp-frame.c > +++ b/gdb/tramp-frame.c > @@ -123,7 +123,7 @@ tramp_frame_sniffer (const struct frame_unwind *self, > const frame_info_ptr &this_frame, > void **this_cache) > { > - const struct tramp_frame *tramp = self->unwind_data->tramp_frame; > + const struct tramp_frame *tramp = self->unwind_data ()->tramp_frame; > CORE_ADDR pc = get_frame_pc (this_frame); > CORE_ADDR func; > struct tramp_frame_cache *tramp_cache; > @@ -142,6 +142,46 @@ tramp_frame_sniffer (const struct frame_unwind *self, > return 1; > } > > +class frame_unwind_trampoline : public frame_unwind > +{ > +private: > + frame_prev_arch_ftype *prev_arch_p; > +public: > + frame_unwind_trampoline (enum frame_type t, const struct frame_data *d, > + frame_prev_arch_ftype *pa) > + : frame_unwind ("trampoline", t, FRAME_UNWIND_GDB, d), prev_arch_p (pa) > + { } > + > + int sniffer(const frame_unwind *self, const frame_info_ptr &this_frame, > + void **this_prologue_cache) const override > + { > + return tramp_frame_sniffer (self, this_frame, this_prologue_cache); > + } > + void this_id (const frame_info_ptr &this_frame, void **this_prologue_cache, > + struct frame_id *id) const override > + { > + tramp_frame_this_id (this_frame, this_prologue_cache, id); > + } > + struct value *prev_register (const frame_info_ptr &this_frame, > + void **this_prologue_cache, > + int regnum) const override > + { > + return tramp_frame_prev_register (this_frame, this_prologue_cache, regnum); > + } > + > + struct gdbarch *prev_arch (const frame_info_ptr &this_frame, > + void **this_prologue_cache) const override > + { This place should have:     if (prev_arch_p == nullptr)       error (_("No prev_arch callback installed")); I've fixed this locally, but since this patch is over 100Kb, I would prefer to not spam the list :) -- Cheers, Guinevere Larsen She/Her/Hers > + return prev_arch_p (this_frame, this_prologue_cache); > + } > + > + /* FIXME: This should have a proper algorithm to deallocate the cache, > + otherwise memory is leaked. This method is empty here just so the > + migration to c++ classes doesn't add regressions. */ > + void dealloc_cache (frame_info *self, void *this_cache) const override > + { } > +}; > + > void > tramp_frame_prepend_unwinder (struct gdbarch *gdbarch, > const struct tramp_frame *tramp_frame) > @@ -160,16 +200,11 @@ tramp_frame_prepend_unwinder (struct gdbarch *gdbarch, > gdb_assert (tramp_frame->insn_size <= sizeof (tramp_frame->insn[0].bytes)); > > data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_data); > - unwinder = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_unwind); > - > data->tramp_frame = tramp_frame; > - unwinder->type = tramp_frame->frame_type; > - unwinder->unwind_data = data; > - unwinder->unwinder_class = FRAME_UNWIND_GDB; > - unwinder->sniffer = tramp_frame_sniffer; > - unwinder->stop_reason = default_frame_unwind_stop_reason; > - unwinder->this_id = tramp_frame_this_id; > - unwinder->prev_register = tramp_frame_prev_register; > - unwinder->prev_arch = tramp_frame->prev_arch; > + > + unwinder = obstack_new (gdbarch_obstack (gdbarch), > + tramp_frame->frame_type, > + data, > + tramp_frame->prev_arch); > frame_unwind_prepend_unwinder (gdbarch, unwinder); > } --------------b9MFY9eYVkru2OqcNsd0mfOf--