Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Kris Warkentin" <kewarken@qnx.com>
To: "Kevin Buettner" <kevinb@redhat.com>,
	"Daniel Jacobowitz" <drow@mvista.com>,
	"Paul Koning" <pkoning@equallogic.com>
Cc: <kevinb@redhat.com>, <gdb@sources.redhat.com>,
	"Colin Burgess" <cburgess@qnx.com>
Subject: Re: [Proposal] GDB honouring RPATH in binaries.
Date: Fri, 21 Feb 2003 20:27:00 -0000	[thread overview]
Message-ID: <030b01c2d9e7$a34d4c60$0202040a@catdog> (raw)
In-Reply-To: <02e001c2d9e3$3ca030d0$0202040a@catdog>

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


  reply	other threads:[~2003-02-21 20:27 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-20 19:15 Kris Warkentin
2003-02-20 19:33 ` Kevin Buettner
2003-02-20 19:41   ` Kris Warkentin
2003-02-20 19:55     ` Kevin Buettner
2003-02-20 19:59       ` Kris Warkentin
2003-02-20 20:03         ` Daniel Jacobowitz
2003-02-20 19:41   ` Daniel Jacobowitz
2003-02-20 19:44     ` Kris Warkentin
2003-02-20 19:48       ` Daniel Jacobowitz
2003-02-20 19:54         ` Kris Warkentin
2003-02-20 19:58           ` Kevin Buettner
2003-02-20 20:00             ` Kevin Buettner
2003-02-20 20:01               ` Kris Warkentin
2003-02-20 20:05                 ` Daniel Jacobowitz
2003-02-20 20:12                   ` Kris Warkentin
2003-02-20 20:04             ` Paul Koning
2003-02-20 20:10               ` Daniel Jacobowitz
2003-02-21 15:32                 ` Kris Warkentin
2003-02-21 18:28                   ` [Proposal] " Kris Warkentin
2003-02-21 18:30                   ` Kris Warkentin
2003-02-21 18:32                     ` Kris Warkentin
2003-02-21 19:14                     ` Kris Warkentin
2003-02-21 19:18                       ` Colin Burgess
2003-02-21 19:42                     ` Kevin Buettner
2003-02-21 19:46                       ` Colin Burgess
2003-02-21 19:55                       ` Kris Warkentin
2003-02-21 20:27                         ` Kris Warkentin [this message]
2003-02-21 21:02                           ` Kevin Buettner
2003-02-21 21:04                             ` Kris Warkentin
2003-02-20 20:18               ` Kevin Buettner
2003-02-20 20:00           ` Daniel Jacobowitz
2003-02-20 19:50     ` Kevin Buettner
2003-02-20 19:48 ` Kevin Buettner
2003-02-20 19:52   ` Kris Warkentin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='030b01c2d9e7$a34d4c60$0202040a@catdog' \
    --to=kewarken@qnx.com \
    --cc=cburgess@qnx.com \
    --cc=drow@mvista.com \
    --cc=gdb@sources.redhat.com \
    --cc=kevinb@redhat.com \
    --cc=pkoning@equallogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox