This is the mail archive of the archer@sourceware.org mailing list for the Archer project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[python] search for -gdb.py


I don't want to clutter /usr/lib with a bunch of -gdb.py files in the
distro.  So, we need a second place to look for them.

It looked convenient & simple to just reuse the existing
debug-file-directory.  That is what this patch implements.

This may result in a given -gdb.py file being read twice.
That is ok, though, because we warn users about this behavior.

Tom

2008-12-15  Tom Tromey  <tromey@redhat.com>

	* python/python.c (gdbpy_new_objfile): Look in
	debug_file_directory as well.

2008-12-15  Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (Auto-loading): Document debug-file-directory
	search.

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index dedf24b..1ada58b 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -18192,10 +18192,17 @@ traceback.
 When a new object file (@pxref{Objfiles in Python}) is read (for
 example, due to the @code{file} command, or because the inferior has
 loaded a shared library), @value{GDBN} will look for a file named by
-adding @samp{-gdb.py} to the object file's name.  If this file exists
-and is readable, @value{GDBN} will evaluate it as a Python script.
-Note that, if a separate debug file is used, @value{GDBN} will look
-for the @samp{-gdb.py} file both in the directory associated with the
+adding @samp{-gdb.py} to the object file's real name (the name formed
+after following all symlinks and resolving @code{.} and @code{..}
+components).  If this file exists and is readable, @value{GDBN} will
+evaluate it as a Python script.
+
+If this file does not exist, and if the parameter
+@code{debug-file-directory} is set, then @value{GDBN} will append the
+object file's real name to the value of this parameter, and try again.
+
+Also, if a separate debug file is used, @value{GDBN} will look for the
+@samp{-gdb.py} file both in the directory associated with the
 application and the directory associated with the separate debug file.
 
 When reading a @samp{-gdb.py} file, @var{GDBN} sets the ``current
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 9a1d321..fd84f60 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -741,6 +741,23 @@ gdbpy_new_objfile (struct objfile *objfile)
 
   input = fopen (filename, "r");
 
+  if (!input && debug_file_directory)
+    {
+      /* Also try the same file in the separate debug info directory.  */
+      char *debugfile;
+
+      debugfile = xmalloc (strlen (filename)
+			   + strlen (debug_file_directory) + 1);
+      strcpy (debugfile, debug_file_directory);
+      /* FILENAME is absolute, so we don't need a "/" here.  */
+      strcat (debugfile, filename);
+
+      xfree (filename);
+      filename = debugfile;
+
+      input = fopen (filename, "r");
+    }
+
   if (input)
     {
       /* We don't want to throw an exception here -- but the user


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]