From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52716 invoked by alias); 1 Aug 2018 02:08:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 52702 invoked by uid 89); 1 Aug 2018 02:08:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.2 spammy= X-HELO: sessmg22.ericsson.net Received: from sessmg22.ericsson.net (HELO sessmg22.ericsson.net) (193.180.251.58) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 01 Aug 2018 02:08:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1533089327; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dxrHUG+H3uFJCRcKQ++W46SlcS7duG1svtpN5R764wI=; b=D811uM+KueVRSHVnG1yGrDW2zt1NMWr8zTNCdUfUp0DBsqmWeoX2wO0eyhZegz6u /cWiTu7XVI9ws3pfPGZBfLZLnmtNBieZQxaI020m9gCrKCEH1a3zTMOZ0Fl9t5oK w6XgTar7+IYdGxwbVU9i6vEUMJDdJxy+D0nEE/0MDOE=; Received: from ESESSMB502.ericsson.se (Unknown_Domain [153.88.183.120]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id B2.D4.31169.F26116B5; Wed, 1 Aug 2018 04:08:47 +0200 (CEST) Received: from ESESSMR505.ericsson.se (153.88.183.127) by ESESSMB502.ericsson.se (153.88.183.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 1 Aug 2018 04:08:47 +0200 Received: from ESESSMB501.ericsson.se (153.88.183.162) by ESESSMR505.ericsson.se (153.88.183.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 1 Aug 2018 04:08:47 +0200 Received: from NAM05-BY2-obe.outbound.protection.outlook.com (153.88.183.157) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Wed, 1 Aug 2018 04:08:46 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=irObgNlDOllZADVxo8DM+HR6ti3iR317JDxB5szac1E=; b=J31mhuNlibBh06Ojq+ffZ1JB/LKHFL1YPLdqvxKwDNIFr+vaEr1EvuTJmLQ5ybSNM+A9fSsLJKlWZnZ3wftdKK1GpKJk6hwCSi2lwlKUsSs8mnKkKfZMMeiDlnLNJFBo8ISYvKoo3qZF+IbXu0YEWv0snA2NyVecB7DGRhmsf84= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from [10.0.0.110] (192.222.164.54) by DM6PR15MB2396.namprd15.prod.outlook.com (2603:10b6:5:8d::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.21; Wed, 1 Aug 2018 02:08:43 +0000 Subject: Re: [PATCH 4/8] Disassemble blocks with non-contiguous ranges To: Kevin Buettner , References: <20180625233239.49dc52ea@pinnacle.lan> <20180625234911.6096446e@pinnacle.lan> From: Simon Marchi Message-ID: <207c61c2-4116-7721-11ad-1a648bb16ec4@ericsson.com> Date: Wed, 01 Aug 2018 02:08:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180625234911.6096446e@pinnacle.lan> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-Path: simon.marchi@ericsson.com Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00005.txt.bz2 On 2018-06-26 02:49 AM, Kevin Buettner wrote: > This patch adds support for disassembly of blocks with non-contiguous > ranges. These blocks are printed as follows: > > (gdb) disassemble foo > Dump of assembler code for function foo: > Address range 0x401136 to 0x401151: > 0x0000000000401136 <+0>: push %rbp > 0x0000000000401137 <+1>: mov %rsp,%rbp > 0x000000000040113a <+4>: callq 0x401134 > 0x000000000040113f <+9>: mov 0x2eef(%rip),%eax # 0x404034 > 0x0000000000401145 <+15>: test %eax,%eax > 0x0000000000401147 <+17>: je 0x40114e > 0x0000000000401149 <+19>: callq 0x401128 > 0x000000000040114e <+24>: nop > 0x000000000040114f <+25>: pop %rbp > 0x0000000000401150 <+26>: retq > Address range 0x401128 to 0x401134: > 0x0000000000401128 <+-14>: push %rbp > 0x0000000000401129 <+-13>: mov %rsp,%rbp > 0x000000000040112c <+-10>: callq 0x401126 > 0x0000000000401131 <+-5>: nop > 0x0000000000401132 <+-4>: pop %rbp > 0x0000000000401133 <+-3>: retq > End of assembler dump. > > This is an actual dump from the test case that I constructed for > this work. The ranges are printed in the order encountered in the > debug info. For the above example, note that the second range occupies > lower addresses than the first range. > > Functions with contiguous ranges are still printed as follows: > > (gdb) disassemble main > Dump of assembler code for function main: > 0x0000000000401151 <+0>: push %rbp > 0x0000000000401152 <+1>: mov %rsp,%rbp > 0x0000000000401155 <+4>: callq 0x401136 > 0x000000000040115a <+9>: mov $0x0,%eax > 0x000000000040115f <+14>: pop %rbp > 0x0000000000401160 <+15>: retq > End of assembler dump. > > gdb/ChangeLog: > > * cli/cli-cmds.c (block.h): Include. > (print_disassembly): Handle printing of non-contiguous blocks. > (disassemble_current_function): Likewise. > (disassemble_command): Likewise. > --- > gdb/cli/cli-cmds.c | 40 +++++++++++++++++++++++++++++----------- > 1 file changed, 29 insertions(+), 11 deletions(-) > > diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c > index 5c5d6dc..171936c 100644 > --- a/gdb/cli/cli-cmds.c > +++ b/gdb/cli/cli-cmds.c > @@ -38,6 +38,7 @@ > #include "tracepoint.h" > #include "filestuff.h" > #include "location.h" > +#include "block.h" > > #include "ui-out.h" > > @@ -1096,6 +1097,7 @@ list_command (const char *arg, int from_tty) > static void > print_disassembly (struct gdbarch *gdbarch, const char *name, > CORE_ADDR low, CORE_ADDR high, > + const struct block *b, > gdb_disassembly_flags flags) Could you document the new parameter? > { > #if defined(TUI) > @@ -1104,14 +1106,28 @@ print_disassembly (struct gdbarch *gdbarch, const char *name, > { > printf_filtered ("Dump of assembler code "); > if (name != NULL) > - printf_filtered ("for function %s:\n", name); > - else > - printf_filtered ("from %s to %s:\n", > - paddress (gdbarch, low), paddress (gdbarch, high)); > - > - /* Dump the specified range. */ > - gdb_disassembly (gdbarch, current_uiout, flags, -1, low, high); > + printf_filtered ("for function %s:\n", name); > + if (!b || BLOCK_CONTIGUOUS_P (b)) b == nullptr > + { > + if (name == NULL) > + printf_filtered ("from %s to %s:\n", > + paddress (gdbarch, low), paddress (gdbarch, high)); > > + /* Dump the specified range. */ > + gdb_disassembly (gdbarch, current_uiout, flags, -1, low, high); > + } > + else > + { > + for (int i = 0; i < BLOCK_NRANGES (b); i++) > + { > + CORE_ADDR low = BLOCK_RANGE_START (b, i); > + CORE_ADDR high = BLOCK_RANGE_END (b, i); > + printf_filtered ("Address range %s to %s:\n", > + paddress (gdbarch, low), > + paddress (gdbarch, high)); Use _() for user-visible strings. You can add it to pre-existing printfs that your patch touches, if you want. Otherwise, LGTM. Simon