From 2e73927ca515996146d2b20d8e6f0b39c0a51b29 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 17 Dec 2013 21:35:39 -0700 Subject: [PATCH] Add target_ops argument to to_find_memory_regions 2014-02-19 Tom Tromey * target.h (struct target_ops) : Add argument. (target_find_memory_regions): Add argument. * target.c (dummy_find_memory_regions): Add 'self' argument. * procfs.c (proc_find_memory_regions): Add 'self' argument. * gnu-nat.c (gnu_find_memory_regions): Add 'self' argument. * fbsd-nat.h (fbsd_find_memory_regions): Add 'self' argument. * fbsd-nat.c (fbsd_find_memory_regions): Add 'self' argument. * exec. (exec_do_find_memory_regions): New global. (exec_set_find_memory_regions): Rewrite. (exec_find_memory_regions): New function. (init_exec_ops): Use exec_find_memory_regions. --- gdb/ChangeLog | 15 +++++++++++++++ gdb/exec.c | 14 +++++++++++++- gdb/fbsd-nat.c | 3 ++- gdb/fbsd-nat.h | 3 ++- gdb/gnu-nat.c | 3 ++- gdb/procfs.c | 6 ++++-- gdb/target.c | 3 ++- gdb/target.h | 5 +++-- 8 files changed, 43 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 327e68c8bc..7cade09543 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,18 @@ +2014-02-19 Tom Tromey + + * target.h (struct target_ops) : Add + argument. + (target_find_memory_regions): Add argument. + * target.c (dummy_find_memory_regions): Add 'self' argument. + * procfs.c (proc_find_memory_regions): Add 'self' argument. + * gnu-nat.c (gnu_find_memory_regions): Add 'self' argument. + * fbsd-nat.h (fbsd_find_memory_regions): Add 'self' argument. + * fbsd-nat.c (fbsd_find_memory_regions): Add 'self' argument. + * exec. (exec_do_find_memory_regions): New global. + (exec_set_find_memory_regions): Rewrite. + (exec_find_memory_regions): New function. + (init_exec_ops): Use exec_find_memory_regions. + 2014-02-19 Tom Tromey * target.h (struct target_ops) : Add diff --git a/gdb/exec.c b/gdb/exec.c index 1885afd74e..f3df4b1b29 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -62,6 +62,10 @@ 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; @@ -835,7 +839,14 @@ exec_has_memory (struct target_ops *ops) extern void exec_set_find_memory_regions (int (*func) (find_memory_region_ftype, void *)) { - exec_ops.to_find_memory_regions = func; + 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 (bfd *, int *); @@ -862,6 +873,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_magic = OPS_MAGIC; } diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 43ee605cee..dc6d76d753 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -91,7 +91,8 @@ fbsd_read_mapping (FILE *mapfile, unsigned long *start, unsigned long *end, argument to FUNC. */ int -fbsd_find_memory_regions (find_memory_region_ftype func, void *obfd) +fbsd_find_memory_regions (struct target_ops *self, + find_memory_region_ftype func, void *obfd) { pid_t pid = ptid_get_pid (inferior_ptid); char *mapfilename; diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h index a048733da4..7ed89464e2 100644 --- a/gdb/fbsd-nat.h +++ b/gdb/fbsd-nat.h @@ -29,7 +29,8 @@ extern char *fbsd_pid_to_exec_file (struct target_ops *self, int pid); calling FUNC for each memory region. OBFD is passed as the last argument to FUNC. */ -extern int fbsd_find_memory_regions (find_memory_region_ftype func, void *obfd); +extern int fbsd_find_memory_regions (struct target_ops *self, + find_memory_region_ftype func, void *obfd); /* Create appropriate note sections for a corefile, returning them in allocated memory. */ diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index b226498196..296c162e03 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -2545,7 +2545,8 @@ gnu_xfer_partial (struct target_ops *ops, enum target_object object, /* Call FUNC on each memory region in the task. */ static int -gnu_find_memory_regions (find_memory_region_ftype func, void *data) +gnu_find_memory_regions (struct target_ops *self, + find_memory_region_ftype func, void *data) { error_t err; task_t task; diff --git a/gdb/procfs.c b/gdb/procfs.c index 575984cce7..360a5155a3 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -137,7 +137,8 @@ static int procfs_thread_alive (struct target_ops *ops, ptid_t); static void procfs_find_new_threads (struct target_ops *ops); static char *procfs_pid_to_str (struct target_ops *, ptid_t); -static int proc_find_memory_regions (find_memory_region_ftype, void *); +static int proc_find_memory_regions (struct target_ops *self, + find_memory_region_ftype, void *); static char * procfs_make_note_section (bfd *, int *); @@ -5058,7 +5059,8 @@ find_memory_regions_callback (struct prmap *map, the callback. */ static int -proc_find_memory_regions (find_memory_region_ftype func, void *data) +proc_find_memory_regions (struct target_ops *self, + find_memory_region_ftype func, void *data) { procinfo *pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0); diff --git a/gdb/target.c b/gdb/target.c index 0fc4e869a1..fd4f62d815 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3770,7 +3770,8 @@ dummy_pid_to_str (struct target_ops *ops, ptid_t ptid) /* Error-catcher for target_find_memory_regions. */ static int -dummy_find_memory_regions (find_memory_region_ftype ignore1, void *ignore2) +dummy_find_memory_regions (struct target_ops *self, + find_memory_region_ftype ignore1, void *ignore2) { error (_("Command not implemented for this target.")); return 0; diff --git a/gdb/target.h b/gdb/target.h index c3c117a907..8f7d38c940 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -547,7 +547,8 @@ struct target_ops TARGET_DEFAULT_NORETURN (tcomplain ()); int (*to_supports_non_stop) (struct target_ops *); /* find_memory_regions support method for gcore */ - int (*to_find_memory_regions) (find_memory_region_ftype func, void *data); + int (*to_find_memory_regions) (struct target_ops *, + find_memory_region_ftype func, void *data); /* make_corefile_notes support method for gcore */ char * (*to_make_corefile_notes) (bfd *, int *); /* get_bookmark support method for bookmarks */ @@ -1560,7 +1561,7 @@ extern char *target_thread_name (struct thread_info *); */ #define target_find_memory_regions(FUNC, DATA) \ - (current_target.to_find_memory_regions) (FUNC, DATA) + (current_target.to_find_memory_regions) (¤t_target, FUNC, DATA) /* * Compose corefile .note section. -- 2.34.1