From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 8IpXMnTvbl+wOQAAWB0awg (envelope-from ) for ; Sat, 26 Sep 2020 03:36:20 -0400 Received: by simark.ca (Postfix, from userid 112) id C95CA1EF51; Sat, 26 Sep 2020 03:36:20 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID,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 98E2C1EF4D for ; Sat, 26 Sep 2020 03:36:17 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 374CD3857C61; Sat, 26 Sep 2020 07:36:17 +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 011233857C61 for ; Sat, 26 Sep 2020 07:36:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 011233857C61 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=1601105763; cv=none; d=zoho.com.cn; s=zohoarc; b=Ts9eVps0ah9HJ+kQ/oelrJbhLcciXKoCxIw6tZuGibFLS3/AzBDVmw0s2NqC9M/TXnYjx9yEO2r4LyvGroeu7zLGBlP2DsRkh0Qo9PXhDSqx4bSCzjviqPh10Z9gvdDHnIouFUddXZM5LOki5V28XWqBCHcsohJH5GyyNeKdkYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1601105763; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=IBK63B8rm7J6N3vNlGOJa4HpgRFsLhrJeZzNoCUaQbg=; b=fRPTkzmJhJJIcwOLMGYzMw16+AJpsanRG52fF7DettcovY4ib9Or4ybXF/AAoSEDhIIzwgbdnXutuSw0iz0xnUJpvBuBvobqU4N1k2UOnp39jXtth72UKnPOvbnj4ZElGhLKYoVwzizT3ReqxD58uYTLEDjxjXFt4i6Npw8W30M= 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=1601105763; s=zoho; d=euphon.net; i=fam@euphon.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=IBK63B8rm7J6N3vNlGOJa4HpgRFsLhrJeZzNoCUaQbg=; b=O5NZiQZ0eN7XSCw0gxVlz/sGkdg9GdggeTz9ibYb9XL2aR3ASc0oNevRs7jURThQ QmV03Ot/nDtEQsqyNCnZ4UaxzNXTNt1ZrLgU996vsTKlt3kRO71+TfYZcaMFd+MMauy TzrdicjclahTr8OJYwq7fR+pOp3f0bmTDsZI6Qcg= Received: from localhost (ec2-52-56-101-76.eu-west-2.compute.amazonaws.com [52.56.101.76]) by mx.zoho.com.cn with SMTPS id 1601105762216498.5206586508406; Sat, 26 Sep 2020 15:36:02 +0800 (CST) From: fam@euphon.net To: gdb-patches@sourceware.org Message-ID: <20200926073539.981936-2-fam@euphon.net> Subject: [PATCH v6 1/3] disass: Add /x modifier to print offsets in hex Date: Sat, 26 Sep 2020 08:35:37 +0100 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200926073539.981936-1-fam@euphon.net> References: <20200926073539.981936-1-fam@euphon.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoCNMailClient: External Content-Type: text/plain; charset=utf8 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: fam@euphon.net, Andreas Schwab , Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" From: Fam Zheng Backtrace messages printed by Linux kernel and Xen have hex offsets, e.g.: (XEN) Xen call trace: (XEN) [] R guest_walk_tables_2_levels+0x189/0x66d (XEN) [] F hap_p2m_ga_to_gfn_2_levels+0x112/0x25b (XEN) [] F hap_gva_to_gfn_2_levels+0x1c/0x1e (XEN) [] F paging_gva_to_gfn+0x14a/0x167 Having this modifier saves converting between hex values from the backtrace log and offsets in gdb disass output. gdb/ChangeLog: 2020-09-25 Fam Zheng =09* NEWS: Mention the /x modifier of disass. =09* cli/cli-cmds.c (disassemble_current_function): Add usage text =09for /x modifier. =09(disassemble_command): Parse /x modifier for disass. =09* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): =09Handle /x modifier. =09* disasm.h (enum gdb_disassembly_flag): Add a new flag for /x =09modifier. =09* record.c (get_insn_history_modifiers): Parse /x modifier. --- gdb/NEWS | 3 +++ gdb/cli/cli-cmds.c | 17 ++++++++++++----- gdb/disasm.c | 5 ++++- gdb/disasm.h | 1 + gdb/record.c | 3 +++ 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index f30d718331..ba1cf76b36 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,6 +3,9 @@ =20 *** Changes since GDB 10 =20 +* A new modifier '/x' is added to disassemble command, to print instructio= n + offsets in hex. + * MI changes =20 ** '-break-insert --qualified' and '-dprintf-insert --qualified' diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index e3965fea07..e10544a734 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -1456,12 +1456,12 @@ disassemble_current_function (gdb_disassembly_flags= flags) /* Dump a specified section of assembly code. =20 Usage: - disassemble [/mrs] + disassemble [/mrsx] - dump the assembly code for the function of the current pc - disassemble [/mrs] addr + disassemble [/mrsx] addr - dump the assembly code for the function at ADDR - disassemble [/mrs] low,high - disassemble [/mrs] low,+length + disassemble [/mrsx] low,high + disassemble [/mrsx] low,+length - dump the assembly code in the range [LOW,HIGH), or [LOW,LOW+lengt= h) =20 A /m modifier will include source code with the assembly in a @@ -1472,6 +1472,8 @@ disassemble_current_function (gdb_disassembly_flags f= lags) =20 A /r modifier will include raw instructions in hex with the assembly. =20 + A /x modifier will print offsets in hex. + A /s modifier will include source code with the assembly, like /m, with two important differences: 1) The output is still in pc address order. @@ -1510,6 +1512,9 @@ disassemble_command (const char *arg, int from_tty) =09 case 'r': =09 flags |=3D DISASSEMBLY_RAW_INSN; =09 break; +=09 case 'x': +=09 flags |=3D DISASSEMBLY_HEX_OFFSET; +=09 break; =09 case 's': =09 flags |=3D DISASSEMBLY_SOURCE; =09 break; @@ -2535,7 +2540,7 @@ can be shown using \"show listsize\".")); =20 c =3D 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|/x] 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 in hex.\n\ +\n\ With a single argument, the function surrounding that address is dumped.\n= \ Two arguments (separated by a comma) are taken as a range of memory to dum= p,\n\ in the form of \"start,end\", or \"start,+length\".\n\ diff --git a/gdb/disasm.c b/gdb/disasm.c index e45c840068..c681d8b1e9 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -250,7 +250,10 @@ gdb_pretty_print_disassembler::pretty_print_insn (cons= t struct disasm_insn *insn =09 the offset takes the place of the "+" here. */ =09if (offset >=3D 0) =09 m_uiout->text ("+"); -=09m_uiout->field_signed ("offset", offset); +=09m_uiout->field_fmt ("offset", +=09=09=09 ((flags & DISASSEMBLY_HEX_OFFSET) !=3D 0 +=09=09=09 ? "0x%x" : "%d"), +=09=09=09 offset); =09m_uiout->text (">:\t"); } else diff --git a/gdb/disasm.h b/gdb/disasm.h index b0f535eaa2..fb293650de 100644 --- a/gdb/disasm.h +++ b/gdb/disasm.h @@ -31,6 +31,7 @@ enum gdb_disassembly_flag DISASSEMBLY_OMIT_PC =3D (0x1 << 4), DISASSEMBLY_SOURCE =3D (0x1 << 5), DISASSEMBLY_SPECULATIVE =3D (0x1 << 6), + DISASSEMBLY_HEX_OFFSET =3D (0x1 << 7), }; DEF_ENUM_FLAGS_TYPE (enum gdb_disassembly_flag, gdb_disassembly_flags); =20 diff --git a/gdb/record.c b/gdb/record.c index 759395d5bc..44591e8cf0 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -494,6 +494,9 @@ get_insn_history_modifiers (const char **arg) =09 case 'r': =09 modifiers |=3D DISASSEMBLY_RAW_INSN; =09 break; +=09 case 'x': +=09 modifiers |=3D DISASSEMBLY_HEX_OFFSET; +=09 break; =09 case 'f': =09 modifiers |=3D DISASSEMBLY_OMIT_FNAME; =09 break; --=20 2.25.1