procfs.c: iterate_over_mappings callback has wrong profile.

The function proc_find_memory_regions calls iterate_over_mappings as
follow:

> return iterate_over_mappings (pi, func, data,
>                               find_memory_regions_callback);

The problem is that both func and find_memory_regions_callback
do not match the profile expected by iterate_over_mappings:

> iterate_over_mappings (procinfo *pi, int (*child_func) (), void *data,
>                        int (*func) (struct prmap *map,
>                                     int (*child_func) (),
>                                     void *data))

We cannot change proc_find_memory_regions such that FUNC is a pointer
to a function that takes no argument (in place of the 6 that it has).
This is because proc_find_memory_regions is used as a target_ops method.
However, it turns out that changing iterate_over_mappings to conform
to the profile imposed by the target_ops vector is possible without
much effort.

gdb/ChangeLog:

        * procfs.c (iterate_over_mappings_cb_ftype): New typedef.
        (iterate_over_mappings): Adjust function profile. Add declaration.
        (insert_dbx_link_bpt_in_region, info_mappings_callback):
        Adjust accordingly.
This commit is contained in:
Joel Brobecker
2010-04-20 22:35:58 +00:00
parent e294797a88
commit e9ef4f394d
2 changed files with 28 additions and 4 deletions

View File

@@ -1,3 +1,10 @@
2010-04-20 Joel Brobecker <brobecker@adacore.com>
* procfs.c (iterate_over_mappings_cb_ftype): New typedef.
(iterate_over_mappings): Adjust function profile. Add declaration.
(insert_dbx_link_bpt_in_region, info_mappings_callback):
Adjust accordingly.
2010-04-20 Joel Brobecker <brobecker@adacore.com>
* procfs.c (solib_mappings_callback): Move function up to avoid

View File

@@ -445,6 +445,19 @@ static void free_syscalls (procinfo *pi);
static int find_syscall (procinfo *pi, char *name);
#endif /* DYNAMIC_SYSCALLS */
/* A function type used as a callback back iterate_over_mappings. */
typedef int (iterate_over_mappings_cb_ftype)
(CORE_ADDR vaddr, unsigned long size, int read, int write, int execute,
void *data);
static int iterate_over_mappings
(procinfo *pi,
iterate_over_mappings_cb_ftype *child_func,
void *data,
int (*func) (struct prmap *map,
iterate_over_mappings_cb_ftype *child_func,
void *data));
/* The head of the procinfo list: */
static procinfo * procinfo_list;
@@ -4096,7 +4109,7 @@ solib_mappings_callback (struct prmap *map, int (*func) (int, CORE_ADDR),
static int
insert_dbx_link_bpt_in_region (struct prmap *map,
int (*child_func) (),
iterate_over_mappings_cb_ftype *child_func,
void *data)
{
procinfo *pi = (procinfo *) data;
@@ -5617,9 +5630,11 @@ procfs_use_watchpoints (struct target_ops *t)
*/
static int
iterate_over_mappings (procinfo *pi, int (*child_func) (), void *data,
iterate_over_mappings (procinfo *pi,
iterate_over_mappings_cb_ftype *child_func,
void *data,
int (*func) (struct prmap *map,
int (*child_func) (),
iterate_over_mappings_cb_ftype *child_func,
void *data))
{
char pathname[MAX_PROC_NAME_SIZE];
@@ -5767,7 +5782,9 @@ mappingflags (long flags)
*/
static int
info_mappings_callback (struct prmap *map, int (*ignore) (), void *unused)
info_mappings_callback (struct prmap *map,
iterate_over_mappings_cb_ftype *ignore,
void *unused)
{
unsigned int pr_off;