From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10039 invoked by alias); 15 Nov 2004 23:35:30 -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 9935 invoked from network); 15 Nov 2004 23:35:14 -0000 Received: from unknown (HELO walton.sibelius.xs4all.nl) (82.92.89.47) by sourceware.org with SMTP; 15 Nov 2004 23:35:14 -0000 Received: from elgar.sibelius.xs4all.nl (elgar.sibelius.xs4all.nl [192.168.0.2]) by walton.sibelius.xs4all.nl (8.13.0/8.13.0) with ESMTP id iAFNZ14R000303; Tue, 16 Nov 2004 00:35:01 +0100 (CET) Received: from elgar.sibelius.xs4all.nl (localhost [127.0.0.1]) by elgar.sibelius.xs4all.nl (8.12.6p3/8.12.6) with ESMTP id iAFNZ0LY000792; Tue, 16 Nov 2004 00:35:00 +0100 (CET) (envelope-from kettenis@elgar.sibelius.xs4all.nl) Received: (from kettenis@localhost) by elgar.sibelius.xs4all.nl (8.12.6p3/8.12.6/Submit) id iAFNZ088000788; Tue, 16 Nov 2004 00:35:00 +0100 (CET) Date: Mon, 15 Nov 2004 23:35:00 -0000 Message-Id: <200411152335.iAFNZ088000788@elgar.sibelius.xs4all.nl> From: Mark Kettenis To: kevinb@redhat.com CC: gdb-patches@sources.redhat.com In-reply-to: <20041115143217.20c9a6a2@saguaro> (message from Kevin Buettner on Mon, 15 Nov 2004 14:32:17 -0700) Subject: Re: Assume solib.h References: <4193BFA0.3060607@gnu.org> <200411112005.iABK5FrV098628@elgar.sibelius.xs4all.nl> <4193DDCE.7060205@gnu.org> <200411112224.iABMODmo099121@elgar.sibelius.xs4all.nl> <4194DBEB.6010304@gnu.org> <01c4c8db$Blat.v2.2.2$377f5020@zahav.net.il> <20041115143217.20c9a6a2@saguaro> X-SW-Source: 2004-11/txt/msg00318.txt.bz2 Date: Mon, 15 Nov 2004 14:32:17 -0700 From: Kevin Buettner This is a multi-part message in MIME format. --Multipart=_Mon__15_Nov_2004_14_32_17_-0700_xcMRgDYW/T7vXH4. Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 12 Nov 2004 19:14:30 +0200 "Eli Zaretskii" wrote: > I'm with Mark on this one: a patch that potentially breaks a supported > platform doesn't get my vote. If a platform is supported, it deserves > that we don't break it, and calling it ``marginal'' doesn't change > anything. Mark, Eli, Would the addition of the attached file (solib-null.c) to Andrew's patch address your concerns? (Makefile.in has to change too; basically solib-null.o is unconditionally built and linked into gdb. I can post a patch if desired...) I think it would, although I've been working on a slightly more complicated solution that's a bit more multi-arch. I've attached an initial patch, but this really needs a bit more work. I've not been able to test it as thoroughly as I'd like, but it does seem to get me past some solib related problems on remote targets which lack shared library support. It looks good to me. It can't really hurt things, and it'll serve as a stopgap while I'm finishing up my multi-arch patch. Mark Index: ChangeLog from Mark Kettenis * solib.c: Update copyright year. Include "gdbarch.h". (solib_data): New variable. (solib_init): New function. (solib_open, solib_map_sections, free_so, update_solib_list) (solib_add, clear_solib, solib_create_inferior_hook): Get shared library architecture operations from architecture; allow them to be unimplemented. * solist.h (TARGET_SO_RELOCATE_SECTION_ADDRESS) (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) (TARGET_SO_IN_DYNSYM_RESOLVE_CODE) (TARGET_SO_FIND_AND_OPEN_SOLIB): Remove. Index: solib.c =================================================================== RCS file: /cvs/src/src/gdb/solib.c,v retrieving revision 1.68 diff -u -p -r1.68 solib.c --- solib.c 11 Sep 2004 10:24:50 -0000 1.68 +++ solib.c 15 Nov 2004 23:26:54 -0000 @@ -1,7 +1,7 @@ /* Handle shared libraries for GDB, the GNU Debugger. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GDB. @@ -21,6 +21,7 @@ Boston, MA 02111-1307, USA. */ #include "defs.h" +#include "gdbarch.h" #include #include @@ -68,6 +69,29 @@ static char *solib_absolute_prefix = NUL symbol files. This takes precedence over the environment variables PATH and LD_LIBRARY_PATH. */ static char *solib_search_path = NULL; + + +/* Architecture-specific operations. */ + +/* Per-architecture data key. */ +static struct gdbarch_data *solib_data; + +/* Return a default for the architecture-specific operations. */ + +static void * +solib_init (struct obstack *obstack) +{ + struct target_so_ops *ops; + + ops = OBSTACK_ZALLOC (obstack, struct target_so_ops); + + /* FIXME: kettenis/20041112: This should be removed. */ + if (current_target_so_ops) + memcpy (ops, current_target_so_ops, sizeof (struct target_so_ops)); + + return ops; +} + /* @@ -109,6 +133,7 @@ static char *solib_search_path = NULL; int solib_open (char *in_pathname, char **found_pathname) { + struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data); int found_file = -1; char *temp_pathname = NULL; char *p = in_pathname; @@ -169,9 +194,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) @@ -224,6 +249,7 @@ solib_open (char *in_pathname, char **fo static int solib_map_sections (void *arg) { + struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data); struct so_list *so = (struct so_list *) arg; /* catch_errors bogon */ char *filename; char *scratch_pathname; @@ -274,14 +300,13 @@ solib_map_sections (void *arg) for (p = so->sections; p < so->sections_end; p++) { - /* 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); + /* Relocate the section binding addresses as recorded in the + shared object's file by the base address to which the object + was actually mapped. */ + if (ops->relocate_section_addresses) + ops->relocate_section_addresses (so, p); if (strcmp (p->the_bfd_section->name, ".text") == 0) - { - so->textsection = p; - } + so->textsection = p; } /* Free the file names, close the file now. */ @@ -314,6 +339,7 @@ solib_map_sections (void *arg) void free_so (struct so_list *so) { + struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data); char *bfd_filename = 0; if (so->sections) @@ -330,7 +356,8 @@ free_so (struct so_list *so) if (bfd_filename) xfree (bfd_filename); - TARGET_SO_FREE_SO (so); + if (ops->free_so) + ops->free_so (so); xfree (so); } @@ -402,15 +429,18 @@ symbol_add_stub (void *arg) 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 = gdbarch_data (current_gdbarch, solib_data); + struct so_list *inferior = NULL; struct so_list *gdb, **gdb_link; + if (ops->current_sos) + inferior = ops->current_sos (); + /* If we are attaching to a running process for which we have not opened a symbol file, we may be able to get its symbols now! */ - if (attach_flag && - symfile_objfile == NULL) - catch_errors (TARGET_SO_OPEN_SYMBOL_FILE_OBJECT, &from_tty, + if (attach_flag && symfile_objfile == NULL && ops->open_symbol_file_object) + catch_errors (ops->open_symbol_file_object, &from_tty, "Error reading attached process's symbol file.\n", RETURN_MASK_ALL); @@ -561,6 +591,7 @@ update_solib_list (int from_tty, struct void solib_add (char *pattern, int from_tty, struct target_ops *target, int readsyms) { + struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data); struct so_list *gdb; if (pattern) @@ -617,7 +648,8 @@ solib_add (char *pattern, int from_tty, frameless. */ reinit_frame_cache (); - TARGET_SO_SPECIAL_SYMBOL_HANDLING (); + if (ops->special_symbol_handling) + ops->special_symbol_handling (); } } } @@ -738,6 +770,8 @@ solib_address (CORE_ADDR address) void clear_solib (void) { + struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data); + /* 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 @@ -771,7 +805,8 @@ clear_solib (void) free_so (so); } - TARGET_SO_CLEAR_SOLIB (); + if (ops->clear_solib) + ops->clear_solib (); } static void @@ -799,7 +834,10 @@ do_clear_solib (void *dummy) void solib_create_inferior_hook (void) { - TARGET_SO_SOLIB_CREATE_INFERIOR_HOOK (); + struct target_so_ops *ops = gdbarch_data (current_gdbarch, solib_data); + + if (ops->solib_create_inferior_hook) + ops->solib_create_inferior_hook (); } /* GLOBAL FUNCTION @@ -821,7 +859,12 @@ 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 = gdbarch_data (current_gdbarch, solib_data); + + if (ops->in_dynsym_resolve_code) + return ops->in_dynsym_resolve_code (pc); + + return 0; } /* @@ -878,6 +921,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.9 diff -u -p -r1.9 solist.h --- solist.h 11 Mar 2004 17:04:40 -0000 1.9 +++ solist.h 15 Nov 2004 23:26:54 -0000 @@ -119,20 +119,4 @@ extern int solib_open (char *in_pathname /* FIXME: gdbarch needs to control this variable */ extern struct target_so_ops *current_target_so_ops; -#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) - #endif