Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Aleksandar Ristovski <aristovski@qnx.com>
To: gdb-patches@sources.redhat.com
Subject: [patch] symfile find_separate_debug_file
Date: Mon, 10 Aug 2009 18:58:00 -0000	[thread overview]
Message-ID: <h5pnol$ejf$1@ger.gmane.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 794 bytes --]

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.


[-- Attachment #2: symfile-20090810.diff --]
[-- Type: text/x-patch, Size: 1126 bytes --]

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)). */

             reply	other threads:[~2009-08-10 18:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-10 18:58 Aleksandar Ristovski [this message]
2009-08-13 22:37 ` Tom Tromey
2009-08-13 22:50   ` Doug Evans
2009-08-14  0:40     ` Tom Tromey
2009-08-14 14:44       ` Aleksandar Ristovski
2009-08-14 15:45         ` Doug Evans

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='h5pnol$ejf$1@ger.gmane.org' \
    --to=aristovski@qnx.com \
    --cc=gdb-patches@sources.redhat.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