From patchwork Thu May 1 17:15:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 779 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id D5A37360068 for ; Thu, 1 May 2014 10:15:55 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id 7D63A415F3961; Thu, 1 May 2014 10:15:55 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id 5A3CD415EB288 for ; Thu, 1 May 2014 10:15:55 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=BcJph1HFyFdPT/0z s8SWEXru+N7Nu9oOhjE7y1keIHKxi0pW0bTi5VkFYXnn3LyRCRC+75mpWku6uUKf 460N2FNRExpL53Wo2lSWCHqTP3FXI+qw7KYtY5Pes7PDFAOoXiYw59WJIghmLsey b/6Rx9ltaUAsNzTYxZdr7GNEEeU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:message-id:date:from:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; s=default; bh=A9naOn8WdlIv3eiq3Jkrbi nzIK0=; b=Zpw95jvi2F7yEf3kOiv/E4f9uhlAZfQ2XfCBmhsb0yGdKQ5s6zY/UL hPmMZwUTDPO5rsxmsxvh+yNOOKULnPF9ilYKZ283n9nBMiDl2+wHK8tmHdeLHUag LoQar1kVVfnXTVqydmLooG5QoTlJK4K7wudxIDzSBGdTrkJp5yyqM= Received: (qmail 32016 invoked by alias); 1 May 2014 17:15:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 32003 invoked by uid 89); 1 May 2014 17:15:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 01 May 2014 17:15:51 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s41HFl1v015243 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 1 May 2014 13:15:47 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s41HFjN5005432; Thu, 1 May 2014 13:15:46 -0400 Message-ID: <53628140.2090102@redhat.com> Date: Thu, 01 May 2014 18:15:44 +0100 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: David Taylor CC: "gdb-patches@sourceware.org" Subject: Re: RFA/remote: compare-sections References: <24262.1395849610@usendtaylorx2l> <29572.1396557529@usendtaylorx2l> <18733.1397666636@usendtaylorx2l> In-Reply-To: <18733.1397666636@usendtaylorx2l> X-DH-Original-To: gdb@patchwork.siddhesh.in On 04/16/2014 05:43 PM, David Taylor wrote: > Final ping. I initially posted this three weeks ago. Eli Zaretskii > immediately approved the doc part. The remainder has been ignored. > I pinged two weeks ago. The remainder continues to be unreviewed. As Keith said. Please don't take it personally. In his quick reply, Eli also mentioned that this warrants a NEWS entry. I agree. But, I didn't see an updated patch. Would you like to contribute one? >>> 2014-03-26 David Taylor >>> >>> * remote.c (compare_sections_command): Add -r option to compare >>> all loadable read-only sections. This is OK. I've pushed it in, as below. I took the liberty of using an explicit NULL check, and removed the redundant parens. Thank you. ---------- >From 95cf3b38cd2fae4a53c8ff12bef21b2ae3fdd0cb Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 1 May 2014 18:09:43 +0100 Subject: [PATCH] compare-sections: New -r option. When connecting to a remote system, we use the compare-sections command to verify that the box is running the code that we think it is running. Since the system is up and running and *NOT* 'freshly downloaded without yet executing anything', read-write sections, of course, differ from what they were in the executable file. Comparing read-write sections takes time and more importantly the MIS-MATCHED output is confusing to some users. The compare-sections command compares all loadable sections including read-write sections. This patch gives the user the option to compare just the loadable read-only sections. gdb/ 2014-05-01 David Taylor * remote.c (compare_sections_command): Add -r option to compare all loadable read-only sections. gdb/doc/ 2014-05-01 David Taylor * gdb.texinfo (compare-sections): Document the new -r (read-only) option. --- gdb/ChangeLog | 5 +++++ gdb/doc/ChangeLog | 5 +++++ gdb/doc/gdb.texinfo | 5 +++-- gdb/remote.c | 13 ++++++++++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7e5b290..eac6037 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-05-01 David Taylor + + * remote.c (compare_sections_command): Add -r option to compare + all loadable read-only sections. + 2014-04-30 Siva Chandra Reddy * dwarf2loc.c (dwarf2_locexpr_baton_eval, diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 2b0f686..1e60575 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2014-05-01 David Taylor + + * gdb.texinfo (compare-sections): Document the new -r (read-only) + option. + 2014-04-24 Michael Sturm Walfred Tedeschi diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 9d91075..7f7650d 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -8772,11 +8772,12 @@ situations. @table @code @kindex compare-sections -@item compare-sections @r{[}@var{section-name}@r{]} +@item compare-sections @r{[}@var{section-name}@r{|}@code{-r}@r{]} Compare the data of a loadable section @var{section-name} in the executable file of the program being debugged with the same section in the remote machine's memory, and report any mismatches. With no -arguments, compares all loadable sections. This command's +arguments, compares all loadable sections. With an argument of +@code{-r}, compares all loadable read-only sections. This command's availability depends on the target's support for the @code{"qCRC"} remote request. @end table diff --git a/gdb/remote.c b/gdb/remote.c index 4177b39..ba04d0c 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -8484,6 +8484,7 @@ compare_sections_command (char *args, int from_tty) int matched = 0; int mismatched = 0; int res; + int read_only = 0; if (!exec_bfd) error (_("command cannot be used without an exec file")); @@ -8491,11 +8492,20 @@ compare_sections_command (char *args, int from_tty) /* Make sure the remote is pointing at the right process. */ set_general_process (); + if (args != NULL && strcmp (args, "-r") == 0) + { + read_only = 1; + args = NULL; + } + for (s = exec_bfd->sections; s; s = s->next) { if (!(s->flags & SEC_LOAD)) continue; /* Skip non-loadable section. */ + if (read_only && (s->flags & SEC_READONLY) == 0) + continue; /* Skip writeable sections */ + size = bfd_get_section_size (s); if (size == 0) continue; /* Skip zero-length section. */ @@ -11771,7 +11781,8 @@ the packets being used"), add_cmd ("compare-sections", class_obscure, compare_sections_command, _("\ Compare section data on target to the exec file.\n\ -Argument is a single section name (default: all loaded sections)."), +Argument is a single section name (default: all loaded sections).\n\ +To compare only read-only loaded sections, specify the -r option."), &cmdlist); add_cmd ("packet", class_maintenance, packet_command, _("\