From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +BH0GnNKbF8fdQAAWB0awg (envelope-from ) for ; Thu, 24 Sep 2020 03:27:47 -0400 Received: by simark.ca (Postfix, from userid 112) id 6C2011EE05; Thu, 24 Sep 2020 03:27:47 -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=unavailable 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 335621E509 for ; Thu, 24 Sep 2020 03:27:46 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B6A32385700A; Thu, 24 Sep 2020 07:27:45 +0000 (GMT) Received: from sender2-op-o12.zoho.com.cn (sender2-op-o12.zoho.com.cn [163.53.93.243]) by sourceware.org (Postfix) with ESMTPS id 7EFC3385700A for ; Thu, 24 Sep 2020 07:27:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7EFC3385700A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=euphon.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=fam@euphon.net ARC-Seal: i=1; a=rsa-sha256; t=1600932447; cv=none; d=zoho.com.cn; s=zohoarc; b=cW70x+Fy69wkjmxEG1U/jD5lH5uSCqermURw1H6sdWlb9K/rgYQf87MTXdwkZ0bjaTNYd4CXXZ/u09pjRY97vK5lkbdDXLbXGOYAopx3v63r+YBuckDua89jGq00GFxH5/BjhacJRxLbgfTNZQ3gIIREaWCcot3iw4c/HcBf4Dc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1600932447; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=vu1Tzke80tzgRh7gDWtif173L+akJutTee+Ys8aGkT4=; b=AFT+YrTfQJYk5iXxU9bgXWvfjDFHQw7C9BjfIdEFEbkGMUk7N9/A6ghiG/lN5QzBN4jaH/1NxoY22GTUiVeqCbQ/2N9kV5d2MwbMbXuUvdhM5g3OspGK64bALKd7Fy4xWxJHeyPnBea2cEKk+anr8N6MLEFS59fnsCp+CHfnVLw= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=euphon.net; spf=pass smtp.mailfrom=fam@euphon.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1600932447; s=zoho; d=euphon.net; i=fam@euphon.net; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Content-Type; bh=vu1Tzke80tzgRh7gDWtif173L+akJutTee+Ys8aGkT4=; b=FYrQvb7c7Y+oYK3UD1l5pE3WuXKY4DHXLAwvpHHSDAXgJ2Ldtq8ftCOHPRjtOkis y2+ACbBtJxp6oPJKKKhVkhjvK5bN3m+f9ho1t9azwXKdMhqQhUmCrwCUL1aIeUXso9V Y5BoNb+u1F+lbatxBrifhulHbw6Mu7SHfo6/Yqog= Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by mx.zoho.com.cn with SMTPS id 1600932444950581.4841492861818; Thu, 24 Sep 2020 15:27:24 +0800 (CST) Received: by mail-lf1-f54.google.com with SMTP id b22so2696730lfs.13 for ; Thu, 24 Sep 2020 00:27:23 -0700 (PDT) X-Gm-Message-State: AOAM532arGnOgG3i9D635a+q9cG4vBrU/et5ef3JJmIs+R3KhK7YtAqN gVp/qnw5shD38bIRlJuYK8VrrZ3u1+MRTu38v8Y= X-Google-Smtp-Source: ABdhPJyy/ZQQ5kJL8gYlNA6vDYYkpK7y6aJIbIVeR8Tp6KWQ6Us77jgj7vD0PXzaohaY7yset0zt+rXnoh9dlXX8EcI= X-Received: by 2002:a19:4a8a:: with SMTP id x132mr1063402lfa.423.1600932439021; Thu, 24 Sep 2020 00:27:19 -0700 (PDT) MIME-Version: 1.0 References: <20200923101906.2897399-1-fam@euphon.net> <5127be3c-ca5a-1e0f-d19a-b83d4da0ec74@simark.ca> In-Reply-To: <5127be3c-ca5a-1e0f-d19a-b83d4da0ec74@simark.ca> From: Fam Zheng Date: Thu, 24 Sep 2020 07:26:43 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] disass: Add /x modifier to print offsets in hex To: Simon Marchi Content-Type: text/plain; charset="UTF-8" X-ZohoCNMailClient: External 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: , Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On Thu, Sep 24, 2020 at 3:25 AM Simon Marchi wrote: > > > Hi, Hi Simon, > > 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. All make sense! > > > @@ -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. Okay, will change. > > > @@ -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. Thanks, will send v3 later addressing above. Fam > > Simon