remove exec_set_find_memory_regions
authorTom Tromey <tromey@redhat.com>
Wed, 15 Jan 2014 16:40:13 +0000 (09:40 -0700)
committerTom Tromey <tromey@redhat.com>
Wed, 19 Feb 2014 14:48:45 +0000 (07:48 -0700)
exec_set_find_memory_regions is used to modify the exec target.
However, it only has a single caller, and so it is much clearer to
simply set the appropriate field directly.  It's also better for the
coming multi-target world to avoid this kind of global state change
anyway.

2014-02-19  Tom Tromey  <tromey@redhat.com>

* gcore.h (objfile_find_memory_regions): Declare.
* gcore.c (objfile_find_memory_regions): No longer static.  Add
"self" argument.
(_initialize_gcore): Don't call exec_set_find_memory_regions.
* exec.c: Include gcore.h.
(exec_set_find_memory_regions): Remove.
(exec_find_memory_regions): Remove.
(exec_do_find_memory_regions): Remove.
(init_exec_ops): Update.
* defs.h (exec_set_find_memory_regions): Remove.

gdb/ChangeLog
gdb/defs.h
gdb/exec.c
gdb/gcore.c
gdb/gcore.h

index 7496e3b..d7275aa 100644 (file)
@@ -1,5 +1,18 @@
 2014-02-19  Tom Tromey  <tromey@redhat.com>
 
+       * gcore.h (objfile_find_memory_regions): Declare.
+       * gcore.c (objfile_find_memory_regions): No longer static.  Add
+       "self" argument.
+       (_initialize_gcore): Don't call exec_set_find_memory_regions.
+       * exec.c: Include gcore.h.
+       (exec_set_find_memory_regions): Remove.
+       (exec_find_memory_regions): Remove.
+       (exec_do_find_memory_regions): Remove.
+       (init_exec_ops): Update.
+       * defs.h (exec_set_find_memory_regions): Remove.
+
+2014-02-19  Tom Tromey  <tromey@redhat.com>
+
        * target-delegates.c: Rebuild.
        * target.h (struct target_ops) <to_extra_thread_info,
        to_thread_name, to_pid_to_exec_file, to_get_section_table,
index a9669cf..1753dfa 100644 (file)
@@ -368,10 +368,6 @@ typedef int (*find_memory_region_ftype) (CORE_ADDR addr, unsigned long size,
                                         int read, int write, int exec,
                                         int modified, void *data);
 
-/* Take over the 'find_mapped_memory' vector from exec.c.  */
-extern void exec_set_find_memory_regions
-  (int (*func) (find_memory_region_ftype func, void *data));
-
 /* Possible lvalue types.  Like enum language, this should be in
    value.h, but needs to be here for the same reason.  */
 
index 61dea49..7f53a50 100644 (file)
@@ -34,6 +34,7 @@
 #include "gdbthread.h"
 #include "progspace.h"
 #include "gdb_bfd.h"
+#include "gcore.h"
 
 #include <fcntl.h>
 #include "readline/readline.h"
@@ -62,10 +63,6 @@ void _initialize_exec (void);
 
 struct target_ops exec_ops;
 
-/* Function used to implement to_find_memory_regions.  */
-
-static int (*exec_do_find_memory_regions) (find_memory_region_ftype, void *);
-
 /* True if the exec target is pushed on the stack.  */
 static int using_exec_ops;
 
@@ -834,21 +831,6 @@ exec_has_memory (struct target_ops *ops)
          != current_target_sections->sections_end);
 }
 
-/* Find mapped memory.  */
-
-extern void
-exec_set_find_memory_regions (int (*func) (find_memory_region_ftype, void *))
-{
-  exec_do_find_memory_regions = func;
-}
-
-static int
-exec_find_memory_regions (struct target_ops *self,
-                         find_memory_region_ftype func, void *data)
-{
-  return exec_do_find_memory_regions (func, data);
-}
-
 static char *exec_make_note_section (struct target_ops *self, bfd *, int *);
 
 /* Fill in the exec file target vector.  Very few entries need to be
@@ -873,7 +855,7 @@ Specify the filename of the executable file.";
   exec_ops.to_stratum = file_stratum;
   exec_ops.to_has_memory = exec_has_memory;
   exec_ops.to_make_corefile_notes = exec_make_note_section;
-  exec_ops.to_find_memory_regions = exec_find_memory_regions;
+  exec_ops.to_find_memory_regions = objfile_find_memory_regions;
   exec_ops.to_magic = OPS_MAGIC;
 }
 
index 67fbf30..b80a97b 100644 (file)
@@ -471,8 +471,9 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read,
   return 0;
 }
 
-static int
-objfile_find_memory_regions (find_memory_region_ftype func, void *obfd)
+int
+objfile_find_memory_regions (struct target_ops *self,
+                            find_memory_region_ftype func, void *obfd)
 {
   /* Use objfile data to create memory sections.  */
   struct objfile *objfile;
@@ -607,5 +608,4 @@ Save a core file with the current state of the debugged process.\n\
 Argument is optional filename.  Default filename is 'core.<process_id>'."));
 
   add_com_alias ("gcore", "generate-core-file", class_files, 1);
-  exec_set_find_memory_regions (objfile_find_memory_regions);
 }
index fa64211..7a6271b 100644 (file)
@@ -23,5 +23,8 @@
 extern bfd *create_gcore_bfd (const char *filename);
 extern void write_gcore_file (bfd *obfd);
 extern bfd *load_corefile (char *filename, int from_tty);
+extern int objfile_find_memory_regions (struct target_ops *self,
+                                       find_memory_region_ftype func,
+                                       void *obfd);
 
 #endif /* GCORE_H */