This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

[patch] symfile find_separate_debug_file


Hello,

I run into this accidentally. When debugging a shared object with embedded symbol file name (.gnu_debuglink section), we made an assumption that objfile would always have full path. However, if shared object was opened using base name only, we will end up with an objfile with the same name.

By looking at allocate_objfile which generates the name for an objfile, it is clear that there could be any kind of path including full path, relative path or file name only.

The patch checks for such situation and instead of gdb_assert-ing, creates current directory prefix.


Tested by running the case manually.



Thanks,


--
Aleksandar Ristovski
QNX Software Systems


ChangeLog:


* symfile.c (find_separate_debug_file): Fix the case when objfile has only basename as its name.

Index: gdb/symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.240
diff -u -p -r1.240 symfile.c
--- gdb/symfile.c	3 Aug 2009 17:00:34 -0000	1.240
+++ gdb/symfile.c	10 Aug 2009 17:56:24 -0000
@@ -1379,13 +1373,21 @@ find_separate_debug_file (struct objfile
   /* Strip off the final filename part, leaving the directory name,
      followed by a slash.  Objfile names should always be absolute and
      tilde-expanded, so there should always be a slash in there
-     somewhere.  */
-  for (i = strlen(dir) - 1; i >= 0; i--)
+     somewhere, unless there isn't.  See allocate_objfile.  */
+  for (i = strlen (dir) - 1; i >= 0; i--)
     {
       if (IS_DIR_SEPARATOR (dir[i]))
 	break;
     }
-  gdb_assert (i >= 0 && IS_DIR_SEPARATOR (dir[i]));
+  if (i < 0)
+    {
+      /* We are dealing with base name only.  Make it current dir.  */
+      if (strlen (dir) < 2)
+	dir = xrealloc (dir, 3);
+      dir[0] = '.';
+      dir[1] = '/';
+      i = 1;
+    }
   dir[i+1] = '\0';
 
   /* Set I to max (strlen (canon_name), strlen (dir)). */

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