From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Kettenis To: gdb-patches@sources.redhat.com Cc: jimb@cygnus.com, ezannoni@cygnus.com Subject: [PATCH, RFA] Fix basename bug in symtab.c Date: Sun, 13 May 2001 13:45:00 -0000 Message-id: <200105132045.f4DKjpm03579@delius.kettenis.local> X-SW-Source: 2001-05/msg00281.html [Jim, Elena, sorry I keep saying cygnus instead of redhat :-(] Here is a patch that fixes the problems discussed on the discussion list. Eli pretty much convinced me that this is the right approach. We can still discuss the other uses of basename() in GDB, but since this fixes a rather serious bug on FreeBSD (and I suppose other systems as well), I'd like to get this in ASAP. Mark Index: ChangeLog from Mark Kettenis * symtab.c (lookup_symtab_1): Use lbasename (NAME) instead of basename (NAME). The FreeBSD basename returns a pointer to a static buffer, even if it's simply returning a string identical to its argument. (lookup_partial_symtab): Likewise. Index: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.37 diff -u -p -r1.37 symtab.c --- symtab.c 2001/05/11 17:48:31 1.37 +++ symtab.c 2001/05/13 19:37:21 @@ -154,7 +154,7 @@ got_symtab: /* Now, search for a matching tail (only if name doesn't have any dirs) */ - if (basename (name) == name) + if (lbasename (name) == name) ALL_SYMTABS (objfile, s) { if (FILENAME_CMP (basename (s->filename), name) == 0) @@ -244,7 +244,7 @@ lookup_partial_symtab (char *name) /* Now, search for a matching tail (only if name doesn't have any dirs) */ - if (basename (name) == name) + if (lbasename (name) == name) ALL_PSYMTABS (objfile, pst) { if (FILENAME_CMP (basename (pst->filename), name) == 0)