From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1934 invoked by alias); 9 Jan 2008 16:13:38 -0000 Received: (qmail 1922 invoked by uid 22791); 9 Jan 2008 16:13:38 -0000 X-Spam-Check-By: sourceware.org Received: from qnxmail.qnx.com (HELO nimbus.ott.qnx.com) (209.226.137.76) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 09 Jan 2008 16:13:20 +0000 Received: by nimbus.ott.qnx.com with Internet Mail Service (5.5.2653.19) id ; Wed, 9 Jan 2008 11:13:17 -0500 Message-ID: <2F6320727174C448A52CEB63D85D11F40A76@nova.ott.qnx.com> From: Aleksandar Ristovski To: Daniel Jacobowitz , Eli Zaretskii Cc: dje@google.com, gdb-patches@sources.redhat.com, gcc-patches@gcc.gnu.org, Ryan Mansfield Subject: RE: [patch] IS_ABSOLUTE_PATH to handle both DOS and POSIX path st yles Date: Wed, 09 Jan 2008 16:13:00 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C852DA.89F751B1" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-01/txt/msg00191.txt.bz2 This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C852DA.89F751B1 Content-Type: text/plain Content-length: 1645 > -----Original Message----- > From: Daniel Jacobowitz [mailto:drow@false.org] > Sent: January 8, 2008 8:47 AM > To: Eli Zaretskii > Cc: dje@google.com; gdb-patches@sources.redhat.com; Aleksandar Ristovski; > gcc-patches@gcc.gnu.org; Ryan Mansfield > Subject: Re: [patch] IS_ABSOLUTE_PATH to handle both DOS and POSIX path st > yles > > On Tue, Jan 08, 2008 at 06:24:33AM +0200, Eli Zaretskii wrote: > > Yes, but why does GDB want to know at startup something about start.S > > and crtn.S? > > I believe we need this information when building psymtabs. If not, it > may be because we need symbol information for the program entry point. > One or the other. > > > Anyway, whatever problems can happen with these calls if we adopt my > > suggestion of a user option, they already happen today. So there's > > nothing to lose here. > > True. > > -- > Daniel Jacobowitz > CodeSourcery How about this approach: We use option "substitute-path" to rewrite paths that we want to check for IS_ABSOLUTE_PATH. The logic would be: gdb compares paths in a way native to its configured host system, but user should provide rules for rewriting non-native paths. For example, when debugging executable that has DOS paths in debug info, substitute rule could be C: /c Users would, therefore, be responsible for providing the substitute rules if they have a case of debugging binary compiled on a non-native file system. (This only works for drive letter in DOS paths, doesn't address the dir. Separator issue). The attached patch is just to demonstrate the idea, it is not final implementation. Thanks, Aleksandar Ristovski QNX Software Systems ------_=_NextPart_000_01C852DA.89F751B1 Content-Type: application/octet-stream; name="IS_ABSOLUTE_PATHpatch.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="IS_ABSOLUTE_PATHpatch.diff" Content-length: 5418 Index: gdb/source.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/source.c,v=0A= retrieving revision 1.83=0A= diff -u -p -r1.83 source.c=0A= --- gdb/source.c 1 Jan 2008 22:53:13 -0000 1.83=0A= +++ gdb/source.c 9 Jan 2008 16:09:40 -0000=0A= @@ -895,7 +895,7 @@ get_substitute_path_rule (const char *pa=0A= Return NULL if no substitution rule was specified by the user,=0A= or if no rule applied to the given PATH. */=0A= =20=20=20=20=0A= -static char *=0A= +char *=0A= rewrite_source_path (const char *path)=0A= {=0A= const struct substitute_path_rule *rule =3D get_substitute_path_rule (pa= th);=0A= Index: gdb/source.h=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/source.h,v=0A= retrieving revision 1.9=0A= diff -u -p -r1.9 source.h=0A= --- gdb/source.h 1 Jan 2008 22:53:13 -0000 1.9=0A= +++ gdb/source.h 9 Jan 2008 16:09:40 -0000=0A= @@ -20,6 +20,7 @@=0A= #define SOURCE_H=0A= =20=0A= struct symtab;=0A= +struct partial_symtab;=0A= =20=0A= /* Open a source file given a symtab S. Returns a file descriptor or=0A= negative number for error. */=0A= @@ -66,4 +67,7 @@ extern struct symtab_and_line set_curren=0A= =20=0A= /* Reset any information stored about a default file and line to print. */= =0A= extern void clear_current_source_symtab_and_line (void);=0A= +=0A= +extern char *rewrite_source_path (const char *path);=0A= +=0A= #endif=0A= Index: gdb/utils.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/utils.c,v=0A= retrieving revision 1.184=0A= diff -u -p -r1.184 utils.c=0A= --- gdb/utils.c 1 Jan 2008 22:53:13 -0000 1.184=0A= +++ gdb/utils.c 9 Jan 2008 16:09:40 -0000=0A= @@ -34,6 +34,8 @@=0A= #include =0A= #endif=0A= =20=0A= +#include "source.h"=0A= +=0A= /* SunOS's curses.h has a '#define reg register' in it. Thank you Sun. */= =0A= #ifdef reg=0A= #undef reg=0A= @@ -3223,3 +3225,21 @@ ldirname (const char *filename)=0A= dirname[base - filename] =3D '\0';=0A= return dirname;=0A= }=0A= +=0A= +int=0A= +is_absolute_path (const char *path)=0A= +{=0A= + char *rwpath =3D rewrite_source_path (path);=0A= +=0A= + if (rwpath =3D=3D NULL)=0A= + rwpath =3D (char *) path;=0A= + else=0A= + make_cleanup (xfree, rwpath);=0A= +=0A= +#ifdef HAVE_DOS_BASED_FILE_SYSTEM=0A= + return IS_ABSOLUTE_PATH_DOS (rwpath);=0A= +#else=0A= + return IS_ABSOLUTE_PATH_POSIX (rwpath);=0A= +#endif=0A= +=0A= +}=0A= Index: include/filenames.h=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/include/filenames.h,v=0A= retrieving revision 1.4=0A= diff -u -p -r1.4 filenames.h=0A= --- include/filenames.h 29 Mar 2007 21:03:43 -0000 1.4=0A= +++ include/filenames.h 9 Jan 2008 16:09:41 -0000=0A= @@ -26,6 +26,22 @@ Foundation, Inc., 51 Franklin Street - F=0A= #ifndef FILENAMES_H=0A= #define FILENAMES_H=0A= =20=0A= +/* For DOS style paths. */=0A= +=0A= +#define IS_DIR_SEPARATOR_DOS(c) ((c) =3D=3D '/' || (c) =3D=3D '\\')=0A= +=0A= +/*Note that IS_ABSOLUTE_PATH_DOS macro does not recognize=0A= + path starting with '/' as an absolute path. Otherwise, it behaves=0A= + as IS_DIR_SEPARATOR macro when configured for DOS-like=0A= + file system (see comment for IS_ABSOLUTE_PATH below). */=0A= +=0A= +#define IS_ABSOLUTE_PATH_DOS(f) (IS_DIR_SEPARATOR_DOS((f)[0]) || (((f)[0= ]) && ((f)[1] =3D=3D ':')))=0A= +=0A= +/* For POSIX style paths. */=0A= +=0A= +#define IS_DIR_SEPARATOR_POSIX(c) ((c) =3D=3D '/')=0A= +#define IS_ABSOLUTE_PATH_POSIX(f) (IS_DIR_SEPARATOR_POSIX((f)[0]))=0A= +=0A= #if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (= __CYGWIN__)=0A= =20=0A= #ifndef HAVE_DOS_BASED_FILE_SYSTEM=0A= @@ -37,16 +53,19 @@ Foundation, Inc., 51 Franklin Street - F=0A= only semi-absolute. This is because the users of IS_ABSOLUTE_PATH=0A= want to know whether to prepend the current working directory to=0A= a file name, which should not be done with a name like d:foo. */=0A= -#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || (((f)[0]) && ((f)= [1] =3D=3D ':')))=0A= +//#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || (((f)[0]) && ((= f)[1] =3D=3D ':')))=0A= =20=0A= #else /* not DOSish */=0A= =20=0A= #define IS_DIR_SEPARATOR(c) ((c) =3D=3D '/')=0A= -#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]))=0A= +// #define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]))=0A= +extern int is_absolute_path (const char *path);=0A= =20=0A= #endif /* not DOSish */=0A= =20=0A= extern int filename_cmp (const char *s1, const char *s2);=0A= #define FILENAME_CMP(s1, s2) filename_cmp(s1, s2)=0A= =20=0A= +extern int is_absolute_path (const char *path);=0A= +#define IS_ABSOLUTE_PATH(f) is_absolute_path(f)=0A= #endif /* FILENAMES_H */=0A= ------_=_NextPart_000_01C852DA.89F751B1--