From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id BC09A3858D28 for ; Fri, 10 Feb 2023 12:56:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BC09A3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 04D0A674CC for ; Fri, 10 Feb 2023 12:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1676033763; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=WAb2RtIvjDbQV2cc94NqKvl1s77+8zPzYQvUqtIouis=; b=ceAlJJn6O2HKkXUIsMvnThpO2Gmvm7N33ElALCISqewYQ6cM3l7J6mv8AE17FhoLz/a+O1 Dkhry27nWn9fhVDUH+bGf65Qj5Sex6lmEuPjbao+wBwRsg4zV35tK9UoaPOJbYGb5eBtt8 PSdLoB7uc++onU9k6MYAojZr3vv9tF0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1676033763; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=WAb2RtIvjDbQV2cc94NqKvl1s77+8zPzYQvUqtIouis=; b=xn9qtMTvIeZ1JE8KxDzoRXDwro+iRkkbZkkpB+SzUPwnWFeMcFK0j1JGGU0g+0xLMBwp85 ZVv8cYnEZ42JAmBw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E69F51325E for ; Fri, 10 Feb 2023 12:56:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qzb4NuI+5mMeGgAAMHmgww (envelope-from ) for ; Fri, 10 Feb 2023 12:56:02 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/tdep] Don't use i386 unwinder for amd64 Date: Fri, 10 Feb 2023 13:56:02 +0100 Message-Id: <20230210125602.20437-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,SPF_HELO_NONE,SPF_PASS,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: For i386 we have these unwinders: ... $ gdb -q -batch -ex "set arch i386" -ex "maint info frame-unwinders" The target architecture is set to "i386". dummy DUMMY_FRAME dwarf2 tailcall TAILCALL_FRAME inline INLINE_FRAME i386 epilogue NORMAL_FRAME dwarf2 NORMAL_FRAME dwarf2 signal SIGTRAMP_FRAME i386 stack tramp NORMAL_FRAME i386 sigtramp SIGTRAMP_FRAME i386 prologue NORMAL_FRAME ... and for amd64: ... $ gdb -q -batch -ex "set arch i386:x86-64" -ex "maint info frame-unwinders" The target architecture is set to "i386:x86-64". dummy DUMMY_FRAME dwarf2 tailcall TAILCALL_FRAME inline INLINE_FRAME python NORMAL_FRAME amd64 epilogue NORMAL_FRAME i386 epilogue NORMAL_FRAME dwarf2 NORMAL_FRAME dwarf2 signal SIGTRAMP_FRAME amd64 sigtramp SIGTRAMP_FRAME amd64 prologue NORMAL_FRAME i386 stack tramp NORMAL_FRAME i386 sigtramp SIGTRAMP_FRAME i386 prologue NORMAL_FRAME ... ISTM me there's no reason for the i386 unwinders to be there for amd64. Furthermore, there's a generic need to play around with enabling and disabling unwinders, see PR8434. Currently, that's only available for both the dwarf2 unwinders at once using "maint set dwarf unwinders on/off". If I manually disable the "amd64 epilogue" unwinder, the "i386 epilogue" unwinder becomes active and gives the wrong answer, while I'm actually interested in the result of the dwarf2 unwinder. Of course I can also manually disable the "i386 epilogue", but I take the fact that I have to do that as evidence that on amd64, the "i386 epilogue" is not only unnecessary, but in the way. Fix this by only adding the i386 unwinders only if "info.bfd_arch_info->bits_per_word == 32". Note that for the x32 abi (x86_64/-mx32) the unwinder list is the same as for amd64 (x86_64/-m64), without and with this commit. Tested on x86_64-linux, -m64 and -m32. Not tested with -mx32. PR tdep/30102 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30102 --- gdb/i386-tdep.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 580664d2ce5..8dccae633f7 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -8613,7 +8613,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) appended to the list first, so that it supercedes the DWARF unwinder in function epilogues (where the DWARF unwinder currently fails). */ - frame_unwind_append_unwinder (gdbarch, &i386_epilogue_frame_unwind); + if (info.bfd_arch_info->bits_per_word == 32) + frame_unwind_append_unwinder (gdbarch, &i386_epilogue_frame_unwind); /* Hook in the DWARF CFI frame unwinder. This unwinder is appended to the list before the prologue-based unwinders, so that DWARF @@ -8792,9 +8793,12 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep-> bnd0_regnum = -1; /* Hook in the legacy prologue-based unwinders last (fallback). */ - frame_unwind_append_unwinder (gdbarch, &i386_stack_tramp_frame_unwind); - frame_unwind_append_unwinder (gdbarch, &i386_sigtramp_frame_unwind); - frame_unwind_append_unwinder (gdbarch, &i386_frame_unwind); + if (info.bfd_arch_info->bits_per_word == 32) + { + frame_unwind_append_unwinder (gdbarch, &i386_stack_tramp_frame_unwind); + frame_unwind_append_unwinder (gdbarch, &i386_sigtramp_frame_unwind); + frame_unwind_append_unwinder (gdbarch, &i386_frame_unwind); + } /* If we have a register mapping, enable the generic core file support, unless it has already been enabled. */ base-commit: be01687991aa6c8517b3e635b8f13b0bac6a851a -- 2.35.3