From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14810 invoked by alias); 21 Feb 2003 20:27:30 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 14796 invoked from network); 21 Feb 2003 20:27:29 -0000 Received: from unknown (HELO hub.ott.qnx.com) (209.226.137.76) by 172.16.49.205 with SMTP; 21 Feb 2003 20:27:29 -0000 Received: from smtp.ott.qnx.com (smtp.ott.qnx.com [10.0.2.158]) by hub.ott.qnx.com (8.9.3/8.9.3) with ESMTP id PAA21619; Fri, 21 Feb 2003 15:15:39 -0500 Received: from catdog ([10.4.2.2]) by smtp.ott.qnx.com (8.8.8/8.6.12) with SMTP id PAA31559; Fri, 21 Feb 2003 15:27:28 -0500 Message-ID: <030b01c2d9e7$a34d4c60$0202040a@catdog> From: "Kris Warkentin" To: "Kevin Buettner" , "Daniel Jacobowitz" , "Paul Koning" Cc: , , "Colin Burgess" References: <0db801c2d914$78f80a50$0202040a@catdog> <1030220193301.ZM10611@localhost.localdomain> <20030220194049.GA19653@nevyn.them.org> <001301c2d918$894ef1d0$0202040a@catdog> <20030220194852.GA20424@nevyn.them.org> <002701c2d919$d07edce0$0202040a@catdog> <1030220195833.ZM10783@localhost.localdomain> <15957.17196.501000.893848@gargle.gargle.HOWL> <20030220201032.GA21694@nevyn.them.org> <00e001c2d9be$616ca940$0202040a@catdog> <023401c2d9d7$5441ce30$0202040a@catdog> <1030221191915.ZM15926@localhost.localdomain> <02e001c2d9e3$3ca030d0$0202040a@catdog> Subject: Re: [Proposal] GDB honouring RPATH in binaries. Date: Fri, 21 Feb 2003 20:27:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-SW-Source: 2003-02/txt/msg00483.txt.bz2 Okay, there's a patch down below. The nice thing is it lets me create the following function and then assign it to TARGET_SO_FIND_AND_OPEN_SOLIB in my initialization code. I've tested it and it removes my requirements to monkey with solib-search-path. cheers, Kris /* example of finding our solibs */ int nto_find_and_open_solib (char *solib, unsigned o_flag, char **temp_pathname) { char *buf, arch_path[PATH_MAX], *nto_root, *endian; const char *arch; char *path_fmt = "%s/lib:%s/usr/lib:%s/usr/photon/lib\ :%s/usr/photon/dll:%s/lib/dll"; nto_root = nto_target (); if (strcmp (TARGET_ARCHITECTURE->arch_name, "i386") == 0) { arch = "x86"; endian = ""; } else if (strcmp (TARGET_ARCHITECTURE->arch_name, "rs6000") == 0) { arch = "ppc"; endian = "be"; } else { arch = TARGET_ARCHITECTURE->arch_name; endian = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? "be" : "le"; } sprintf (arch_path, "%s/%s%s", nto_root, arch, endian); buf = alloca (strlen(path_fmt) + arch_path * 5 + 1); sprintf (buf, path_fmt, arch_path, arch_path, arch_path, arch_path, arch_path); return openp(buf, 1, solib, o_flags, 0, temp_pathname); } Index: solib.c =================================================================== RCS file: /cvs/src/src/gdb/solib.c,v retrieving revision 1.53 diff -c -r1.53 solib.c *** solib.c 18 Jan 2003 15:55:52 -0000 1.53 --- solib.c 21 Feb 2003 20:23:43 -0000 *************** *** 160,165 **** --- 160,169 ---- 1, lbasename (in_pathname), O_RDONLY, 0, &temp_pathname); + /* If not found, next use target supplied solib search method (if existing) */ + if (found_file < 0 && TARGET_SO_FIND_AND_OPEN_SOLIB) + found_file = TARGET_SO_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_search_path != NULL) found_file = openp (get_in_environ (inferior_environ, "PATH"), *************** *** 844,849 **** --- 848,860 ---- do_clear_solib (NULL); } + static void + reload_shared_libraries (char *ignored, int from_tty) + { + no_shared_libraries (NULL, from_tty); + solib_add (NULL, from_tty, NULL, auto_solib_add); + } + void _initialize_solib (void) { *************** *** 873,878 **** --- 884,890 ---- For other (relative) files, you can add values using `set solib-search-path'.", &setlist); add_show_from_set (c, &showlist); + set_cmd_cfunc (c, reload_shared_libraries); set_cmd_completer (c, filename_completer); /* Set the default value of "solib-absolute-prefix" from the sysroot, if *************** *** 885,889 **** --- 897,902 ---- This takes precedence over the environment variables PATH and LD_LIBRARY_PATH.", &setlist); add_show_from_set (c, &showlist); + set_cmd_cfunc (c, reload_shared_libraries); set_cmd_completer (c, filename_completer); } Index: solist.h =================================================================== RCS file: /cvs/src/src/gdb/solist.h,v retrieving revision 1.7 diff -c -r1.7 solist.h *** solist.h 21 Oct 2001 19:20:30 -0000 1.7 --- solist.h 21 Feb 2003 20:23:44 -0000 *************** *** 99,104 **** --- 99,109 ---- /* Determine if PC lies in the dynamic symbol resolution code of the run time loader */ int (*in_dynsym_resolve_code) (CORE_ADDR pc); + + /* Extra hook for finding and opening a solib. Convenience function + for remote debuggers finding host libs */ + int (*find_and_open_solib) (char *soname, unsigned o_flags, char **temp_pathname); + }; void free_so (struct so_list *so); *************** *** 122,126 **** --- 127,133 ---- (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