This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
PATCH: clean up some filename handling in find_separate_debug_file
- From: Jim Blandy <jimb at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: 30 Jan 2003 16:41:10 -0500
- Subject: PATCH: clean up some filename handling in find_separate_debug_file
2003-01-29 Jim Blandy <jimb@redhat.com>
* symfile.c (find_separate_debug_file): Assert that the objfile's
directory name we compute ends with a slash, and then assume that
that's so everywhere we use it.
Index: gdb/symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.82
diff -c -r1.82 symfile.c
*** gdb/symfile.c 23 Jan 2003 23:17:28 -0000 1.82
--- gdb/symfile.c 30 Jan 2003 00:11:14 -0000
***************
*** 1167,1178 ****
dir = xstrdup (objfile->name);
! /* Strip off filename part */
for (i = strlen(dir) - 1; i >= 0; i--)
{
if (IS_DIR_SEPARATOR (dir[i]))
break;
}
dir[i+1] = '\0';
debugfile = alloca (strlen (debug_file_directory) + 1
--- 1167,1182 ----
dir = xstrdup (objfile->name);
! /* 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--)
{
if (IS_DIR_SEPARATOR (dir[i]))
break;
}
+ gdb_assert (i >= 0 && IS_DIR_SEPARATOR (dir[i]));
dir[i+1] = '\0';
debugfile = alloca (strlen (debug_file_directory) + 1
***************
*** 1210,1216 ****
strcpy (debugfile, debug_file_directory);
strcat (debugfile, "/");
strcat (debugfile, dir);
- strcat (debugfile, "/");
strcat (debugfile, basename);
if (separate_debug_file_exists (debugfile, crc32))
--- 1214,1219 ----