From 1c7724581e56a7cda4dd412b88eabe51e33b0507 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Fri, 11 May 2007 19:57:17 +0000 Subject: [PATCH] * gdbarch.sh (overlay_update): New gdbarch function. (struct obj_section): Add forward declaration. * gdbarch.c, gdbarch.h: Regenerate. * symfile.c (simple_overlay_update): Make global. (target_overlay_update): Remove variable. (overlay_is_mapped): Call gdbarch_overlay_update instead of target_overlay_update. (overlay_load_command): Likewise. * symfile.h (struct obj_section): Add forward declaration. (simple_overlay_update): Add prototype. * m32r-tdep.c (m32r_gdbarch_init): Install simple_overlay_update. --- gdb/ChangeLog | 16 ++++++++++++++++ gdb/gdbarch.c | 33 +++++++++++++++++++++++++++++++++ gdb/gdbarch.h | 9 +++++++++ gdb/gdbarch.sh | 4 ++++ gdb/m32r-tdep.c | 3 +++ gdb/symfile.c | 18 +++++++----------- gdb/symfile.h | 4 ++++ 7 files changed, 76 insertions(+), 11 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 77a3c64f5c..9ddbf86c8d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,19 @@ +2007-05-11 Ulrich Weigand + + * gdbarch.sh (overlay_update): New gdbarch function. + (struct obj_section): Add forward declaration. + * gdbarch.c, gdbarch.h: Regenerate. + + * symfile.c (simple_overlay_update): Make global. + (target_overlay_update): Remove variable. + (overlay_is_mapped): Call gdbarch_overlay_update instead of + target_overlay_update. + (overlay_load_command): Likewise. + * symfile.h (struct obj_section): Add forward declaration. + (simple_overlay_update): Add prototype. + + * m32r-tdep.c (m32r_gdbarch_init): Install simple_overlay_update. + 2007-05-11 Ulrich Weigand * observer.sh: Add "struct objfile" forward declaration. diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 7e8c697278..8c19f9150c 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -236,6 +236,7 @@ struct gdbarch int vtable_function_descriptors; int vbit_in_delta; gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint; + gdbarch_overlay_update_ftype *overlay_update; }; @@ -362,6 +363,7 @@ struct gdbarch startup_gdbarch = 0, /* vtable_function_descriptors */ 0, /* vbit_in_delta */ 0, /* skip_permanent_breakpoint */ + 0, /* overlay_update */ /* startup_gdbarch() */ }; @@ -614,6 +616,7 @@ verify_gdbarch (struct gdbarch *current_gdbarch) /* Skip verify of vtable_function_descriptors, invalid_p == 0 */ /* Skip verify of vbit_in_delta, invalid_p == 0 */ /* Skip verify of skip_permanent_breakpoint, has predicate */ + /* Skip verify of overlay_update, has predicate */ buf = ui_file_xstrdup (log, &dummy); make_cleanup (xfree, buf); if (strlen (buf) > 0) @@ -1224,6 +1227,12 @@ gdbarch_dump (struct gdbarch *current_gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: osabi = %s\n", paddr_d (current_gdbarch->osabi)); + fprintf_unfiltered (file, + "gdbarch_dump: gdbarch_overlay_update_p() = %d\n", + gdbarch_overlay_update_p (current_gdbarch)); + fprintf_unfiltered (file, + "gdbarch_dump: overlay_update = <0x%lx>\n", + (long) current_gdbarch->overlay_update); #ifdef PC_REGNUM fprintf_unfiltered (file, "gdbarch_dump: PC_REGNUM # %s\n", @@ -3605,6 +3614,30 @@ set_gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch, gdbarch->skip_permanent_breakpoint = skip_permanent_breakpoint; } +int +gdbarch_overlay_update_p (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + return gdbarch->overlay_update != NULL; +} + +void +gdbarch_overlay_update (struct gdbarch *gdbarch, struct obj_section *osect) +{ + gdb_assert (gdbarch != NULL); + gdb_assert (gdbarch->overlay_update != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_overlay_update called\n"); + gdbarch->overlay_update (osect); +} + +void +set_gdbarch_overlay_update (struct gdbarch *gdbarch, + gdbarch_overlay_update_ftype overlay_update) +{ + gdbarch->overlay_update = overlay_update; +} + /* Keep a registry of per-architecture data-pointers required by GDB modules. */ diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index a2aa83ae33..7efcabc2cf 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -42,6 +42,7 @@ struct ui_file; struct frame_info; struct value; struct objfile; +struct obj_section; struct minimal_symbol; struct regcache; struct reggroup; @@ -1345,6 +1346,14 @@ typedef void (gdbarch_skip_permanent_breakpoint_ftype) (struct regcache *regcach extern void gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch, struct regcache *regcache); extern void set_gdbarch_skip_permanent_breakpoint (struct gdbarch *gdbarch, gdbarch_skip_permanent_breakpoint_ftype *skip_permanent_breakpoint); +/* Refresh overlay mapped state for section OSECT. */ + +extern int gdbarch_overlay_update_p (struct gdbarch *gdbarch); + +typedef void (gdbarch_overlay_update_ftype) (struct obj_section *osect); +extern void gdbarch_overlay_update (struct gdbarch *gdbarch, struct obj_section *osect); +extern void set_gdbarch_overlay_update (struct gdbarch *gdbarch, gdbarch_overlay_update_ftype *overlay_update); + extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 349e181f0e..b7720443c6 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -680,6 +680,9 @@ v::int:vbit_in_delta:::0:0::0 # Advance PC to next instruction in order to skip a permanent breakpoint. F::void:skip_permanent_breakpoint:struct regcache *regcache:regcache + +# Refresh overlay mapped state for section OSECT. +F::void:overlay_update:struct obj_section *osect:osect EOF } @@ -782,6 +785,7 @@ struct ui_file; struct frame_info; struct value; struct objfile; +struct obj_section; struct minimal_symbol; struct regcache; struct reggroup; diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c index fa40064f07..45b72dbd33 100644 --- a/gdb/m32r-tdep.c +++ b/gdb/m32r-tdep.c @@ -963,6 +963,9 @@ m32r_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Hook in the default unwinders. */ frame_unwind_append_sniffer (gdbarch, m32r_frame_sniffer); + /* Support simple overlay manager. */ + set_gdbarch_overlay_update (gdbarch, simple_overlay_update); + return gdbarch; } diff --git a/gdb/symfile.c b/gdb/symfile.c index c5de30df68..8e204e15be 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3042,10 +3042,6 @@ init_psymbol_list (struct objfile *objfile, int total_symbols) enum overlay_debugging_state overlay_debugging = ovly_off; int overlay_cache_invalid = 0; /* True if need to refresh mapped state */ -/* Target vector for refreshing overlay mapped state */ -static void simple_overlay_update (struct obj_section *); -void (*target_overlay_update) (struct obj_section *) = simple_overlay_update; - /* Function: section_is_overlay (SECTION) Returns true if SECTION has VMA not equal to LMA, ie. SECTION is loaded at an address different from where it will "run". */ @@ -3099,9 +3095,9 @@ overlay_is_mapped (struct obj_section *osect) case ovly_off: return 0; /* overlay debugging off */ case ovly_auto: /* overlay debugging automatic */ - /* Unles there is a target_overlay_update function, + /* Unles there is a gdbarch_overlay_update function, there's really nothing useful to do here (can't really go auto) */ - if (target_overlay_update) + if (gdbarch_overlay_update_p (current_gdbarch)) { if (overlay_cache_invalid) { @@ -3109,7 +3105,7 @@ overlay_is_mapped (struct obj_section *osect) overlay_cache_invalid = 0; } if (osect->ovly_mapped == -1) - (*target_overlay_update) (osect); + gdbarch_overlay_update (current_gdbarch, osect); } /* fall thru to manual case */ case ovly_on: /* overlay debugging manual */ @@ -3462,8 +3458,8 @@ overlay_off_command (char *args, int from_tty) static void overlay_load_command (char *args, int from_tty) { - if (target_overlay_update) - (*target_overlay_update) (NULL); + if (gdbarch_overlay_update_p (current_gdbarch)) + gdbarch_overlay_update (current_gdbarch, NULL); else error (_("This target does not know how to read its overlay state.")); } @@ -3487,7 +3483,7 @@ overlay_command (char *args, int from_tty) This is GDB's default target overlay layer. It works with the minimal overlay manager supplied as an example by Cygnus. The - entry point is via a function pointer "target_overlay_update", + entry point is via a function pointer "gdbarch_overlay_update", so targets that use a different runtime overlay manager can substitute their own overlay_update function and take over the function pointer. @@ -3690,7 +3686,7 @@ simple_overlay_update_1 (struct obj_section *osect) If a cached entry can't be found or the cache isn't valid, then re-read the entire cache, and go ahead and update all sections. */ -static void +void simple_overlay_update (struct obj_section *osect) { struct objfile *objfile; diff --git a/gdb/symfile.h b/gdb/symfile.h index e28b75b9c7..b24acc1c93 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -29,6 +29,7 @@ /* Opaque declarations. */ struct section_table; struct objfile; +struct obj_section; struct obstack; struct block; @@ -306,6 +307,9 @@ extern void symbol_file_add_main (char *args, int from_tty); /* Clear GDB symbol tables. */ extern void symbol_file_clear (int from_tty); +/* Default overlay update function. */ +extern void simple_overlay_update (struct obj_section *); + extern bfd_byte *symfile_relocate_debug_section (bfd *abfd, asection *sectp, bfd_byte * buf); -- 2.34.1