From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id wtT2NpOWP2F1LAAAWB0awg (envelope-from ) for ; Mon, 13 Sep 2021 14:21:07 -0400 Received: by simark.ca (Postfix, from userid 112) id CD0E71EE25; Mon, 13 Sep 2021 14:21:07 -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 67DE01EDDB for ; Mon, 13 Sep 2021 14:21:05 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8F8703858002 for ; Mon, 13 Sep 2021 18:21:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F8703858002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1631557264; bh=RyRnuNpZEgy9olqk9dowbC36AyIYXyAxxjonTboaRBU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hPfE9ry8PVF8UMi5bxU+Y8+EdhMsT5DbhjzpnwZZFhDEPtQ/eHSlf0rgBCTVMCa7h VnyFWTwnvzyhMS29v5ZCXOC4SnaWYNyJZVUpswlOibWuUNymSVtxQSbl00ziCjkMKr 7pYXFUBRNbnu54e+esUIKuRB4YSUD8eMJAqSSIY8= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 5448E3858C60 for ; Mon, 13 Sep 2021 18:20:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5448E3858C60 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 62AB520021; Mon, 13 Sep 2021 18:20:44 +0000 (UTC) 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 41B4313B67; Mon, 13 Sep 2021 18:20:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sPrgDnyWP2HEXwAAMHmgww (envelope-from ); Mon, 13 Sep 2021 18:20:44 +0000 Date: Mon, 13 Sep 2021 20:20:42 +0200 To: gdb-patches@sourceware.org Subject: [committed][gdb/tdep] Fix exec check in gdb_print_insn_arm Message-ID: <20210913182036.GA15450@delia.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, With a gdb build with --enable-targets=all we run into a KFAIL: ... KFAIL: gdb.gdb/unittest.exp: executable loaded: maintenance selftest, \ failed none (PRMS: gdb/27891) ... due to: ... Running selftest print_one_insn.^M Self test failed: arch armv8.1-m.main: self-test failed at \ disasm-selftests.c:165^M ... The test fails because we expect disassembling of one arm insn to consume 4 bytes and produce (using verbose = true in disasm-selftests.c): ... arm mov r0, #0 ... but instead the disassembler uses thumb mode and only consumes 2 bytes and produces: ... arm movs r0, r0 ... The failure does not show up in the "no executable loaded" variant because this code in gdb_print_insn_arm isn't triggered: ... if (current_program_space->exec_bfd () != NULL) info->flags |= USER_SPECIFIED_MACHINE_TYPE; ... and consequently we do this in print_insn: ... if ((info->flags & USER_SPECIFIED_MACHINE_TYPE) == 0) info->mach = bfd_mach_arm_unknown; ... and don't set force_thumb to true in select_arm_features. The code in gdb_print_insn_arm makes the assumption that the disassembly architecture matches the exec architecture, which in this case is incorrect, because the exec architecture is x86_64, and the disassembly architecture is armv8.1-m.main. Fix that by explicitly checking it: ... if (current_program_space->exec_bfd () != NULL && (current_program_space->exec_bfd ()->arch_info == gdbarch_bfd_arch_info (gdbarch))) ... This fixes the print_one_insn failure, so remove the KFAIL. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27891 Committed to trunk. Approved in bugzilla by Luis. Thanks, - Tom [gdb/tdep] Fix exec check in gdb_print_insn_arm --- gdb/arm-tdep.c | 4 +++- gdb/testsuite/gdb.gdb/unittest.exp | 7 ------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index e4e7aec4e1c..ab6999ae209 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -7727,7 +7727,9 @@ gdb_print_insn_arm (bfd_vma memaddr, disassemble_info *info) the assert on the mismatch of info->mach and bfd_get_mach (current_program_space->exec_bfd ()) in default_print_insn. */ - if (current_program_space->exec_bfd () != NULL) + if (current_program_space->exec_bfd () != NULL + && (current_program_space->exec_bfd ()->arch_info + == gdbarch_bfd_arch_info (gdbarch))) info->flags |= USER_SPECIFIED_MACHINE_TYPE; return default_print_insn (memaddr, info); diff --git a/gdb/testsuite/gdb.gdb/unittest.exp b/gdb/testsuite/gdb.gdb/unittest.exp index 61a6c0efb4b..3622243492c 100644 --- a/gdb/testsuite/gdb.gdb/unittest.exp +++ b/gdb/testsuite/gdb.gdb/unittest.exp @@ -51,13 +51,6 @@ proc run_selftests { binfile } { set num_ran $expect_out(1,string) set num_failed $expect_out(2,string) gdb_assert "$num_ran > 0" "$test, ran some tests" - - if { $binfile != "" } { - # There's a known issue here (see PR gdb/27891), - # however, we should not have more than 1 failure. - gdb_assert "$num_failed <= 1" "$test, failed no more than 1" - setup_kfail "gdb/27891" "*-*-*" - } gdb_assert "$num_failed == 0" "$test, failed none" } -re "Selftests have been disabled for this build.\r\n$gdb_prompt $" {