From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Jmp3CJMRbF/abgAAWB0awg (envelope-from ) for ; Wed, 23 Sep 2020 23:25:07 -0400 Received: by simark.ca (Postfix, from userid 112) id 133DC1EF4B; Wed, 23 Sep 2020 23:25: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.0 required=5.0 tests=MAILING_LIST_MULTI 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 5C9731EDF4 for ; Wed, 23 Sep 2020 23:25:06 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E1C6C3857C63; Thu, 24 Sep 2020 03:25:05 +0000 (GMT) Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id E99EF3857C63 for ; Thu, 24 Sep 2020 03:25:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E99EF3857C63 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 4FB6C1E509; Wed, 23 Sep 2020 23:25:02 -0400 (EDT) Subject: Re: [PATCH v2] disass: Add /x modifier to print offsets in hex To: fam@euphon.net, gdb-patches@sourceware.org References: <20200923101906.2897399-1-fam@euphon.net> From: Simon Marchi Message-ID: <5127be3c-ca5a-1e0f-d19a-b83d4da0ec74@simark.ca> Date: Wed, 23 Sep 2020 23:25:01 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200923101906.2897399-1-fam@euphon.net> Content-Type: text/plain; charset=utf-8 Content-Language: fr Content-Transfer-Encoding: 7bit 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hi, That looks reasonable to me. - This probably deserves a NEWS entry. - There's probably some doc to update (doc/gdb.texinfo) for the affected commands. - Could you add a test for this? You probably don't need a new file, just enhance some existing basic disasm test. > @@ -2535,7 +2540,7 @@ can be shown using \"show listsize\".")); > > c = add_com ("disassemble", class_vars, disassemble_command, _("\ > Disassemble a specified section of memory.\n\ > -Usage: disassemble[/m|/r|/s] START [, END]\n\ > +Usage: disassemble[/m|/r|/s|/r] START [, END]\n\ > Default is the function surrounding the pc of the selected frame.\n\ > \n\ > With a /s modifier, source lines are included (if available).\n\ > @@ -2551,6 +2556,8 @@ in favor of /s.\n\ > \n\ > With a /r modifier, raw instructions in hex are included.\n\ > \n\ > +With a /x modifier, offsets are printed as hex.\n\ Really a nit, but just above we say "in hex", so it would be nice to be consistent and say "in hex" here too. > @@ -250,7 +251,10 @@ gdb_pretty_print_disassembler::pretty_print_insn (const struct disasm_insn *insn > the offset takes the place of the "+" here. */ > if (offset >= 0) > m_uiout->text ("+"); > - m_uiout->field_signed ("offset", offset); > + snprintf(offset_buf, sizeof(offset_buf), > + flags & DISASSEMBLY_HEX_OFFSET ? "0x%x" : "%d", > + offset); > + m_uiout->field_string("offset", offset_buf); You could skip the temporary buffer with: m_uiout->field_fmt ("offset", ((flags & DISASSEMBLY_HEX_OFFSET) != 0 ? "0x%x" : "%d"), offset); Note that the GNU coding style requires a space before parentheses in function (and function-like) calls. Simon