From: Aleksandar Ristovski <ARistovski@qnx.com>
To: Daniel Jacobowitz <drow@false.org>, Eli Zaretskii <eliz@gnu.org>
Cc: dje@google.com, gdb-patches@sources.redhat.com,
gcc-patches@gcc.gnu.org, Ryan Mansfield <RMansfield@qnx.com>
Subject: RE: [patch] IS_ABSOLUTE_PATH to handle both DOS and POSIX path st yles
Date: Wed, 09 Jan 2008 16:13:00 -0000 [thread overview]
Message-ID: <2F6320727174C448A52CEB63D85D11F40A76@nova.ott.qnx.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1645 bytes --]
> -----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
[-- Attachment #2: IS_ABSOLUTE_PATHpatch.diff --]
[-- Type: application/octet-stream, Size: 4395 bytes --]
Index: gdb/source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.83
diff -u -p -r1.83 source.c
--- gdb/source.c 1 Jan 2008 22:53:13 -0000 1.83
+++ gdb/source.c 9 Jan 2008 16:09:40 -0000
@@ -895,7 +895,7 @@ get_substitute_path_rule (const char *pa
Return NULL if no substitution rule was specified by the user,
or if no rule applied to the given PATH. */
-static char *
+char *
rewrite_source_path (const char *path)
{
const struct substitute_path_rule *rule = get_substitute_path_rule (path);
Index: gdb/source.h
===================================================================
RCS file: /cvs/src/src/gdb/source.h,v
retrieving revision 1.9
diff -u -p -r1.9 source.h
--- gdb/source.h 1 Jan 2008 22:53:13 -0000 1.9
+++ gdb/source.h 9 Jan 2008 16:09:40 -0000
@@ -20,6 +20,7 @@
#define SOURCE_H
struct symtab;
+struct partial_symtab;
/* Open a source file given a symtab S. Returns a file descriptor or
negative number for error. */
@@ -66,4 +67,7 @@ extern struct symtab_and_line set_curren
/* Reset any information stored about a default file and line to print. */
extern void clear_current_source_symtab_and_line (void);
+
+extern char *rewrite_source_path (const char *path);
+
#endif
Index: gdb/utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.184
diff -u -p -r1.184 utils.c
--- gdb/utils.c 1 Jan 2008 22:53:13 -0000 1.184
+++ gdb/utils.c 9 Jan 2008 16:09:40 -0000
@@ -34,6 +34,8 @@
#include <pc.h>
#endif
+#include "source.h"
+
/* SunOS's curses.h has a '#define reg register' in it. Thank you Sun. */
#ifdef reg
#undef reg
@@ -3223,3 +3225,21 @@ ldirname (const char *filename)
dirname[base - filename] = '\0';
return dirname;
}
+
+int
+is_absolute_path (const char *path)
+{
+ char *rwpath = rewrite_source_path (path);
+
+ if (rwpath == NULL)
+ rwpath = (char *) path;
+ else
+ make_cleanup (xfree, rwpath);
+
+#ifdef HAVE_DOS_BASED_FILE_SYSTEM
+ return IS_ABSOLUTE_PATH_DOS (rwpath);
+#else
+ return IS_ABSOLUTE_PATH_POSIX (rwpath);
+#endif
+
+}
Index: include/filenames.h
===================================================================
RCS file: /cvs/src/src/include/filenames.h,v
retrieving revision 1.4
diff -u -p -r1.4 filenames.h
--- include/filenames.h 29 Mar 2007 21:03:43 -0000 1.4
+++ include/filenames.h 9 Jan 2008 16:09:41 -0000
@@ -26,6 +26,22 @@ Foundation, Inc., 51 Franklin Street - F
#ifndef FILENAMES_H
#define FILENAMES_H
+/* For DOS style paths. */
+
+#define IS_DIR_SEPARATOR_DOS(c) ((c) == '/' || (c) == '\\')
+
+/*Note that IS_ABSOLUTE_PATH_DOS macro does not recognize
+ path starting with '/' as an absolute path. Otherwise, it behaves
+ as IS_DIR_SEPARATOR macro when configured for DOS-like
+ file system (see comment for IS_ABSOLUTE_PATH below). */
+
+#define IS_ABSOLUTE_PATH_DOS(f) (IS_DIR_SEPARATOR_DOS((f)[0]) || (((f)[0]) && ((f)[1] == ':')))
+
+/* For POSIX style paths. */
+
+#define IS_DIR_SEPARATOR_POSIX(c) ((c) == '/')
+#define IS_ABSOLUTE_PATH_POSIX(f) (IS_DIR_SEPARATOR_POSIX((f)[0]))
+
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
#ifndef HAVE_DOS_BASED_FILE_SYSTEM
@@ -37,16 +53,19 @@ Foundation, Inc., 51 Franklin Street - F
only semi-absolute. This is because the users of IS_ABSOLUTE_PATH
want to know whether to prepend the current working directory to
a file name, which should not be done with a name like d:foo. */
-#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || (((f)[0]) && ((f)[1] == ':')))
+//#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]) || (((f)[0]) && ((f)[1] == ':')))
#else /* not DOSish */
#define IS_DIR_SEPARATOR(c) ((c) == '/')
-#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]))
+// #define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]))
+extern int is_absolute_path (const char *path);
#endif /* not DOSish */
extern int filename_cmp (const char *s1, const char *s2);
#define FILENAME_CMP(s1, s2) filename_cmp(s1, s2)
+extern int is_absolute_path (const char *path);
+#define IS_ABSOLUTE_PATH(f) is_absolute_path(f)
#endif /* FILENAMES_H */
next reply other threads:[~2008-01-09 16:13 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-09 16:13 Aleksandar Ristovski [this message]
2008-01-09 19:10 ` Eli Zaretskii
2008-01-09 19:43 ` Daniel Jacobowitz
2008-01-10 4:13 ` Eli Zaretskii
2008-01-10 14:01 ` Daniel Jacobowitz
[not found] <2F6320727174C448A52CEB63D85D11F40A58@nova.ott.qnx.com>
[not found] ` <20080106054030.GA10410@caradoc.them.org>
2008-01-06 19:38 ` Eli Zaretskii
2008-01-06 20:03 ` Doug Evans
2008-01-06 20:18 ` Eli Zaretskii
2008-01-06 21:07 ` Doug Evans
2008-01-07 3:40 ` Daniel Jacobowitz
2008-01-07 4:21 ` Eli Zaretskii
2008-01-07 13:17 ` Daniel Jacobowitz
2008-01-07 21:28 ` Eli Zaretskii
2008-01-07 4:18 ` Eli Zaretskii
2008-01-07 17:36 ` Doug Evans
2008-01-07 21:32 ` Eli Zaretskii
2008-01-07 21:36 ` Daniel Jacobowitz
2008-01-08 4:25 ` Eli Zaretskii
2008-01-08 13:47 ` Daniel Jacobowitz
-- strict thread matches above, loose matches on Subject: below --
2008-01-04 19:26 Aleksandar Ristovski
2008-01-04 19:33 ` Daniel Jacobowitz
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=2F6320727174C448A52CEB63D85D11F40A76@nova.ott.qnx.com \
--to=aristovski@qnx.com \
--cc=RMansfield@qnx.com \
--cc=dje@google.com \
--cc=drow@false.org \
--cc=eliz@gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--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