Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: David Taylor <dtaylor@emc.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RFA/remote: compare-sections
Date: Wed, 26 Mar 2014 16:00:00 -0000	[thread overview]
Message-ID: <24262.1395849610@usendtaylorx2l> (raw)

Motivation:

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.

For gdb/ChangeLog:

2014-03-26  David Taylor  <dtaylor@emc.com>

	* remote.c (compare_sections_command): Add -r option to compare
	all loadable read-only sections.

For gdb/doc/ChangeLog:

2014-03-26  David Taylor  <dtaylor@emc.com>

	* gdb.texinfo (compare-sections): Document the new -r (read-only)
	option.

I'm not sure that this patch is big enough to require a copyright
assignment, but regardless, EMC has a copyright assignment on file for
GDB (and GCC and BINUTILS as well).

If it is approved, I will need someone else to commit it as I don't have
write access.

Patch:

Index: gdb/remote.c
===================================================================
RCS file: /home/cvsroot/GDB/gdb/remote.c,v
retrieving revision 1.8
diff -u -r1.8 remote.c
--- gdb/remote.c	26 Mar 2014 14:12:34 -0000	1.8
+++ gdb/remote.c	26 Mar 2014 15:49:40 -0000
@@ -8664,6 +8664,7 @@
   int matched = 0;
   int mismatched = 0;
   int res;
+  int read_only = 0;
 
   if (!exec_bfd)
     error (_("command cannot be used without an exec file"));
@@ -8671,11 +8672,20 @@
   /* Make sure the remote is pointing at the right process.  */
   set_general_process ();
 
+  if (args && (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.  */
@@ -12046,7 +12056,8 @@
 
   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, _("\
Index: gdb/doc/gdb.texinfo
===================================================================
RCS file: /home/cvsroot/GDB/gdb/doc/gdb.texinfo,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 gdb.texinfo
--- gdb/doc/gdb.texinfo	18 Feb 2014 15:36:03 -0000	1.1.1.2
+++ gdb/doc/gdb.texinfo	26 Mar 2014 15:49:40 -0000
@@ -8760,11 +8760,12 @@
 
 @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


             reply	other threads:[~2014-03-26 16:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-26 16:00 David Taylor [this message]
2014-03-26 17:51 ` Eli Zaretskii
2014-04-03 20:39 ` David Taylor
2014-04-04  7:54   ` Eli Zaretskii
2014-04-04 12:37     ` David Taylor
2014-04-16 16:44   ` David Taylor
2014-04-16 22:46     ` Keith Seitz
2014-05-02  0:51       ` [PATCH, doc RFA] Make compare-sections work against all targets; add, compare-sections [-r] tests Pedro Alves
2014-05-02  7:22         ` Eli Zaretskii
2014-05-20 18:17           ` Pedro Alves
2014-05-01 17:15     ` RFA/remote: compare-sections Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=24262.1395849610@usendtaylorx2l \
    --to=dtaylor@emc.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox