From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id EJWQGL1r3mrDGhoAWB0awg (envelope-from ) for ; Sun, 25 Oct 2026 16:51:09 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XTXDD6kI; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4A56D378003; Sun, 25 Oct 2026 16:51:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 82E46378002 for ; Sun, 25 Oct 2026 16:51:08 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9FAF04BA2E2A for ; Sun, 25 Oct 2026 20:51:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9FAF04BA2E2A Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XTXDD6kI Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 936BF4BA2E09 for ; Sun, 25 Oct 2026 20:50:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 936BF4BA2E09 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 936BF4BA2E09 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792961442; cv=none; b=mSOL0OoQ3inxsgTgttDWXiHj1LD7pd51eT2IDW84cRDN9YHBgof6OwPWI5I36dZWYwd1e/9uARG4s9pO0vcb6yGCdLNoOhATTO005EJT96EfVEKCDYA9lDBoW9EcjVFaVzyyTA0YEff52RpbcN2uoyK6/ZWQr4gnqOOFFWnZgZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792961442; c=relaxed/simple; bh=P25VmjBqyPaEbxrEwIrYKrvQHlG/yk4UNlcxM+UbqAA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=w9PtiIqWouQIEr/A1UUqUyQXOT235TyDt3oz9qK/DBtOErjfIS25GyDR1srt1FV4M5U4lD2iI9zmYAzshP8XaxwwRstg/hVTzuuDNmwZZmJSM6xMaaO2kzTuK7GuEBFgQPfGPW1Juq+2vRufVgt2cmBc3qg7vLYl7/qgBMqEFDU= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XTXDD6kI DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 936BF4BA2E09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1792961442; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JoynklWzS58M188oKHBsDhmfMpqnbWdfcepx7Ow5D70=; b=XTXDD6kIupZ6d6nE4yBQ8OkMDfT/iU+0b8aWQWxKyTtMhBd7ftV92Lm5qPWJAjTbnmRbgC rlZUYYhhf8XdoyvTBeQ79zyt4WdKllN/KTHyaK6RrgDNkzXocUoIhobD1eOKXBC3Fd0p5x FsJXduZVDpBIlLxCdk3nu0cQWNK6lxo= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-nRCTwiTCMNOyuhgfwdT5yg-1; Sun, 25 Oct 2026 16:50:23 -0400 X-MC-Unique: nRCTwiTCMNOyuhgfwdT5yg-1 X-Mimecast-MFC-AGG-ID: nRCTwiTCMNOyuhgfwdT5yg_1792961422 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E02E41800760; Sun, 25 Oct 2026 20:50:21 +0000 (UTC) Received: from [100.90.172.125] (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 20B0818002B7; Sun, 25 Oct 2026 20:50:20 +0000 (UTC) Message-ID: Date: Sun, 25 Oct 2026 13:50:18 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/4] gdb/riscv: disassemble an attribute-less object by the description ISA To: Farid Khaidari , gdb-patches@sourceware.org References: <20261022154417.235510-1-khaidari.fg@gmail.com> <20261022154417.235510-5-khaidari.fg@gmail.com> From: Kevin Buettner In-Reply-To: <20261022154417.235510-5-khaidari.fg@gmail.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: nGE4cuTOODcbarUQjfMD1hyoszPuB-Fdttqz6II9BS0_1792961422 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Hi Farid, A nit... On 10/22/26 8:44 AM, Farid Khaidari wrote: > static int > @@ -4212,6 +4251,37 @@ riscv_print_insn (bfd_vma addr, struct disassemble_info *info) > if (s != nullptr) > info->section = s->the_bfd_section; > > + /* An object that records its own ISA is disassembled according to > + that ISA. One that does not, such as a core file loaded without an > + executable, is disassembled according to the target description; > + libopcodes would otherwise fall back to plain rv64gc. ARCH_OPTION > + must outlive the default_print_insn call below, which parses it. > + > + The user options are read from the gdbarch and appended here. > + libopcodes clears INFO->DISASSEMBLER_OPTIONS once it has parsed > + them, so the string has to be supplied again for the next > + instruction; each parse first resets every option it does not see > + back to its default, which is why the user ones have to be > + repeated rather than parsed once. They come last and so take > + precedence. */ > + std::string arch_option; > + auto *di = static_cast (info->application_data); > + if (di != nullptr && !riscv_disasm_bfd_has_isa_attribute (info)) > + { > + gdbarch *arch = di->arch (); > + riscv_gdbarch_tdep *tdep = gdbarch_tdep (arch); > + > + arch_option = tdep->disassembler_options_arch; > + > + const char *user_options = get_disassembler_options (arch); > + if (user_options != nullptr && *user_options != '\0') > + { > + arch_option += ','; > + arch_option += user_options; > + } > + info->disassembler_options = arch_option.c_str (); This points info->disassembler_options at storage owned by a local std::string, which is destroyed when riscv_print_insn returns. It only works because print_insn_riscv() sets disassembler_options to NULL after parsing them. (There is an early return before that, when riscv_init_disasm_info fails, but that function currently always returns true.) Relying on that libopcodes behaviour seems fragile: if print_insn_riscv ever stops clearing the field, or returns early before doing so, the next instruction will see a dangling pointer. Kevin