From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2539 invoked by alias); 29 Apr 2005 14:47:10 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 2151 invoked from network); 29 Apr 2005 14:46:54 -0000 Received: from unknown (HELO sibelius.xs4all.nl) (82.92.89.47) by sourceware.org with SMTP; 29 Apr 2005 14:46:54 -0000 Received: from elgar.sibelius.xs4all.nl (root@elgar.sibelius.xs4all.nl [192.168.0.2]) by sibelius.xs4all.nl (8.13.0/8.13.0) with ESMTP id j3TEkrTo024208 for ; Fri, 29 Apr 2005 16:46:53 +0200 (CEST) Received: from elgar.sibelius.xs4all.nl (kettenis@localhost.sibelius.xs4all.nl [127.0.0.1]) by elgar.sibelius.xs4all.nl (8.13.4/8.13.3) with ESMTP id j3TEkrK0018327 for ; Fri, 29 Apr 2005 16:46:53 +0200 (CEST) Received: (from kettenis@localhost) by elgar.sibelius.xs4all.nl (8.13.4/8.13.4/Submit) id j3TEkrFc000179; Fri, 29 Apr 2005 16:46:53 +0200 (CEST) Date: Fri, 29 Apr 2005 14:47:00 -0000 Message-Id: <200504291446.j3TEkrFc000179@elgar.sibelius.xs4all.nl> From: Mark Kettenis To: gdb-patches@sourceware.org Subject: [RFA] First step towards multi-arching solib.c X-SW-Source: 2005-04/txt/msg00428.txt.bz2 This moves the structure with architecture-specific operations under a per-architecture data key. OK? Mark Index: ChangeLog from Mark Kettenis * solist.h (TARGET_SO_FREE_SO, TARGET_SO_CLEAR_SOLIB) (TARGET_SO_SOLIB_CREATE_INFERIOR_HOOK) (TARGET_SO_SPECIAL_SYMBOL_HANDLING, TARGET_SO_CURRENT_SOS) (TARGET_SO_OPEN_SYMBOL_FILE_OBJECT): Remove defines. * solib.c (solib_data): New variable. (solib_init, solib_ops): New functions. (solib_open, solib_map_sections, free_so, update_solib_list) (solib_add, clear_solib, solib_create_inferior_hook) (in_solib_dynsym_resolve_code): Call architecture-dependent code using solib_ops. (_initialize_solib): Register SOLIB_DATA. Index: solib.c =================================================================== RCS file: /cvs/src/src/gdb/solib.c,v retrieving revision 1.79 diff -u -p -r1.79 solib.c --- solib.c 24 Feb 2005 13:51:34 -0000 1.79 +++ solib.c 29 Apr 2005 14:44:42 -0000 @@ -47,6 +47,29 @@ #include "observer.h" #include "readline/readline.h" +/* Architecture-specific operations. */ + +/* Per-architecture data key. */ +static struct gdbarch_data *solib_data; + +static void * +solib_init (struct obstack *obstack) +{ + struct target_so_ops **ops; + + ops = OBSTACK_ZALLOC (obstack, struct target_so_ops *); + *ops = current_target_so_ops; + return ops; +} + +static struct target_so_ops * +solib_ops (struct gdbarch *gdbarch) +{ + struct target_so_ops **ops = gdbarch_data (gdbarch, solib_data); + return *ops; +} + + /* external data declarations */ /* FIXME: gdbarch needs to control this variable */ @@ -119,6 +142,7 @@ The search path for loading non-absolute int solib_open (char *in_pathname, char **found_pathname) { + struct target_so_ops *ops = solib_ops (current_gdbarch); int found_file = -1; char *temp_pathname = NULL; char *p = in_pathname; @@ -179,9 +203,9 @@ solib_open (char *in_pathname, char **fo &temp_pathname); /* If not found, try to use target supplied solib search method */ - if (found_file < 0 && TARGET_SO_FIND_AND_OPEN_SOLIB != NULL) - found_file = TARGET_SO_FIND_AND_OPEN_SOLIB - (in_pathname, O_RDONLY, &temp_pathname); + if (found_file < 0 && ops->find_and_open_solib) + found_file = ops->find_and_open_solib (in_pathname, O_RDONLY, + &temp_pathname); /* If not found, next search the inferior's $PATH environment variable. */ if (found_file < 0 && solib_absolute_prefix == NULL) @@ -284,10 +308,12 @@ solib_map_sections (void *arg) for (p = so->sections; p < so->sections_end; p++) { + struct target_so_ops *ops = solib_ops (current_gdbarch); + /* Relocate the section binding addresses as recorded in the shared object's file by the base address to which the object was actually mapped. */ - TARGET_SO_RELOCATE_SECTION_ADDRESSES (so, p); + ops->relocate_section_addresses (so, p); if (strcmp (p->the_bfd_section->name, ".text") == 0) { so->textsection = p; @@ -324,6 +350,7 @@ solib_map_sections (void *arg) void free_so (struct so_list *so) { + struct target_so_ops *ops = solib_ops (current_gdbarch); char *bfd_filename = 0; if (so->sections) @@ -340,7 +367,7 @@ free_so (struct so_list *so) if (bfd_filename) xfree (bfd_filename); - TARGET_SO_FREE_SO (so); + ops->free_so (so); xfree (so); } @@ -439,7 +466,8 @@ solib_read_symbols (struct so_list *so, static void update_solib_list (int from_tty, struct target_ops *target) { - struct so_list *inferior = TARGET_SO_CURRENT_SOS (); + struct target_so_ops *ops = solib_ops (current_gdbarch); + struct so_list *inferior = ops->current_sos(); struct so_list *gdb, **gdb_link; /* If we are attaching to a running process for which we @@ -447,7 +475,7 @@ update_solib_list (int from_tty, struct symbols now! */ if (attach_flag && symfile_objfile == NULL) - catch_errors (TARGET_SO_OPEN_SYMBOL_FILE_OBJECT, &from_tty, + catch_errors (ops->open_symbol_file_object, &from_tty, "Error reading attached process's symbol file.\n", RETURN_MASK_ALL); @@ -635,11 +663,13 @@ solib_add (char *pattern, int from_tty, if (loaded_any_symbols) { + struct target_so_ops *ops = solib_ops (current_gdbarch); + /* Getting new symbols may change our opinion about what is frameless. */ reinit_frame_cache (); - TARGET_SO_SPECIAL_SYMBOL_HANDLING (); + ops->special_symbol_handling (); } } } @@ -760,6 +790,8 @@ solib_address (CORE_ADDR address) void clear_solib (void) { + struct target_so_ops *ops = solib_ops (current_gdbarch); + /* This function is expected to handle ELF shared libraries. It is also used on Solaris, which can run either ELF or a.out binaries (for compatibility with SunOS 4), both of which can use shared @@ -793,7 +825,7 @@ clear_solib (void) free_so (so); } - TARGET_SO_CLEAR_SOLIB (); + ops->clear_solib (); } static void @@ -821,7 +853,8 @@ do_clear_solib (void *dummy) void solib_create_inferior_hook (void) { - TARGET_SO_SOLIB_CREATE_INFERIOR_HOOK (); + struct target_so_ops *ops = solib_ops (current_gdbarch); + ops->solib_create_inferior_hook(); } /* GLOBAL FUNCTION @@ -843,7 +876,8 @@ solib_create_inferior_hook (void) int in_solib_dynsym_resolve_code (CORE_ADDR pc) { - return TARGET_SO_IN_DYNSYM_RESOLVE_CODE (pc); + struct target_so_ops *ops = solib_ops (current_gdbarch); + return ops->in_dynsym_resolve_code (pc); } /* @@ -910,6 +944,8 @@ _initialize_solib (void) { struct cmd_list_element *c; + solib_data = gdbarch_data_register_pre_init (solib_init); + add_com ("sharedlibrary", class_files, sharedlibrary_command, _("Load shared object library symbols for files matching REGEXP.")); add_info ("sharedlibrary", info_sharedlibrary_command, Index: solist.h =================================================================== RCS file: /cvs/src/src/gdb/solist.h,v retrieving revision 1.10 diff -u -p -r1.10 solist.h --- solist.h 14 Jan 2005 04:00:06 -0000 1.10 +++ solist.h 29 Apr 2005 14:44:42 -0000 @@ -121,18 +121,9 @@ extern struct target_so_ops *current_tar #define TARGET_SO_RELOCATE_SECTION_ADDRESSES \ (current_target_so_ops->relocate_section_addresses) -#define TARGET_SO_FREE_SO (current_target_so_ops->free_so) -#define TARGET_SO_CLEAR_SOLIB (current_target_so_ops->clear_solib) -#define TARGET_SO_SOLIB_CREATE_INFERIOR_HOOK \ - (current_target_so_ops->solib_create_inferior_hook) -#define TARGET_SO_SPECIAL_SYMBOL_HANDLING \ - (current_target_so_ops->special_symbol_handling) -#define TARGET_SO_CURRENT_SOS (current_target_so_ops->current_sos) -#define TARGET_SO_OPEN_SYMBOL_FILE_OBJECT \ - (current_target_so_ops->open_symbol_file_object) -#define TARGET_SO_IN_DYNSYM_RESOLVE_CODE \ - (current_target_so_ops->in_dynsym_resolve_code) #define TARGET_SO_FIND_AND_OPEN_SOLIB \ (current_target_so_ops->find_and_open_solib) +#define TARGET_SO_IN_DYNSYM_RESOLVE_CODE \ + (current_target_so_ops->in_dynsym_resolve_code) #endif