compare-sections: New -r option.
[deliverable/binutils-gdb.git] / gdb / remote.c
index 4177b399b34143225f15ecfddaf8bbf5d8f7b0f7..ba04d0c7cd2a387fb46b347f49afc12cd666cdc5 100644 (file)
@@ -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, _("\
This page took 0.028551 seconds and 4 git commands to generate.