From: Danny Backx <danny.backx@scarlet.be>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb@sourceware.org
Subject: Re: Build question
Date: Sat, 05 Sep 2009 09:33:00 -0000 [thread overview]
Message-ID: <1252143311.6106.252.camel@pavilion> (raw)
In-Reply-To: <83vdk281xb.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1780 bytes --]
On Wed, 2009-09-02 at 06:23 +0300, Eli Zaretskii wrote:
> > From: Danny Backx <danny.backx@scarlet.be>
> > Cc: tromey@redhat.com, gdb@sourceware.org
> > Date: Tue, 01 Sep 2009 22:12:08 +0200
> >
> > Should I then look into :
> > - changing HAVE_DOS_BASED_FILE_SYSTEM into a variable
> > - doing the same thing for FILENAME_PREFIX_LEN and FILENAME_CMPN
>
> HAVE_DOS_BASED_FILE_SYSTEM should be controllable by a variable, and
> should then automatically DTRT with FILENAME_PREFIX_LEN. As for
> FILENAME_CMPN, I don't think it's appropriate for Posix systems to
> compare file names case-insensitively, so if you need that as well, I
> think a separate variable is in order.
ESR said "early and often", right ? Here is a first draft of my work.
Showing this early allows you to steer me in the right direction.
I've changed include/filenames.h and the gdb source files that contained
HAVE_DOS_BASED_FILE_SYSTEM to replace that by a variable.
Some surprises :
- libiberty also includes filenames.h
- filenames.h says it's part of bfd, so basing it on a global variable,
as I did, might have side effects
Otherwise, this code appears to work for me. I hardcoded the variable in
gdb/main.c, set this to both 0 and 1 for testing, and saw the expected
results.
Comments on all this welcome (e.g. I've left all this stuff in the
include file as inline functions, is this a bad idea?).
Also I left all the case sensitive stuff alone, and the also the
filename break characters, so HAVE_DOS_BASED_FILE_SYSTEM is still
present (gdb/symtab.c and gdb/completer.c).
Should I copy code that handles a variable like "solib-search-path" or
"annotate" to set the _have_dos_based_file_system at runtime ?
Danny
--
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
[-- Attachment #2: gdb-diff-dos-1 --]
[-- Type: text/x-patch, Size: 7963 bytes --]
Index: gdb/completer.c
===================================================================
RCS file: /cvs/src/src/gdb/completer.c,v
retrieving revision 1.34
diff -u -r1.34 completer.c
--- gdb/completer.c 25 Mar 2009 10:50:56 -0000 1.34
+++ gdb/completer.c 5 Sep 2009 09:23:13 -0000
@@ -232,13 +232,12 @@
else
break; /* Hit the end of text. */
}
-#if HAVE_DOS_BASED_FILE_SYSTEM
/* If we have a DOS-style absolute file name at the beginning of
TEXT, and the colon after the drive letter is the only colon
we found, pretend the colon is not there. */
- else if (p < text + 3 && *p == ':' && p == text + 1 + quoted)
+ else if (_have_dos_based_file_system
+ && p < text + 3 && *p == ':' && p == text + 1 + quoted)
;
-#endif
else if (*p == ':' && !colon)
{
colon = p;
Index: gdb/main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.77
diff -u -r1.77 main.c
--- gdb/main.c 27 Aug 2009 21:56:38 -0000 1.77
+++ gdb/main.c 5 Sep 2009 09:23:13 -0000
@@ -67,6 +67,9 @@
/* GDB datadir, used to store data files. */
char *gdb_datadir = 0;
+/* Filesystem type */
+int _have_dos_based_file_system = 1;
+
struct ui_file *gdb_stdout;
struct ui_file *gdb_stderr;
struct ui_file *gdb_stdlog;
Index: gdb/source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.103
diff -u -r1.103 source.c
--- gdb/source.c 23 Jul 2009 23:20:00 -0000 1.103
+++ gdb/source.c 5 Sep 2009 09:23:14 -0000
@@ -474,14 +474,20 @@
/* name is the start of the directory.
p is the separator (or null) following the end. */
- while (!(IS_DIR_SEPARATOR (*name) && p <= name + 1) /* "/" */
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
- /* On MS-DOS and MS-Windows, h:\ is different from h: */
- && !(p == name + 3 && name[1] == ':') /* "d:/" */
-#endif
- && IS_DIR_SEPARATOR (p[-1]))
- /* Sigh. "foo/" => "foo" */
- --p;
+ if (_have_dos_based_file_system) {
+ while (!(IS_DIR_SEPARATOR (*name) && p <= name + 1) /* "/" */
+ /* On MS-DOS and MS-Windows, h:\ is different from h: */
+ && !(p == name + 3 && name[1] == ':') /* "d:/" */
+ && IS_DIR_SEPARATOR (p[-1]))
+ /* Sigh. "foo/" => "foo" */
+ --p;
+ } else {
+ while (!(IS_DIR_SEPARATOR (*name) && p <= name + 1) /* "/" */
+ /* On MS-DOS and MS-Windows, h:\ is different from h: */
+ && IS_DIR_SEPARATOR (p[-1]))
+ /* Sigh. "foo/" => "foo" */
+ --p;
+ }
*p = '\0';
while (p > name && p[-1] == '.')
@@ -514,10 +520,9 @@
if (name[0] == '~')
name = tilde_expand (name);
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
- else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */
+ else if (_have_dos_based_file_system
+ && IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */
name = concat (name, ".", (char *)NULL);
-#endif
else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$')
name = concat (current_directory, SLASH_STRING, name, (char *)NULL);
else
Index: gdb/utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.219
diff -u -r1.219 utils.c
--- gdb/utils.c 18 Aug 2009 16:17:16 -0000 1.219
+++ gdb/utils.c 5 Sep 2009 09:23:14 -0000
@@ -3280,15 +3280,14 @@
strncpy (dir_name, filename, base_name - filename);
dir_name[base_name - filename] = '\000';
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
/* We need to be careful when filename is of the form 'd:foo', which
is equivalent of d:./foo, which is totally different from d:/foo. */
- if (strlen (dir_name) == 2 && isalpha (dir_name[0]) && dir_name[1] == ':')
+ if (_have_dos_based_file_system
+ && strlen (dir_name) == 2 && isalpha (dir_name[0]) && dir_name[1] == ':')
{
dir_name[2] = '.';
dir_name[3] = '\000';
}
-#endif
/* Canonicalize the directory prefix, and build the resulting
filename. If the dirname realpath already contains an ending
Index: gdb/cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.92
diff -u -r1.92 cli-cmds.c
--- gdb/cli/cli-cmds.c 11 Jul 2009 14:04:23 -0000 1.92
+++ gdb/cli/cli-cmds.c 5 Sep 2009 09:23:14 -0000
@@ -357,24 +357,26 @@
if (chdir (dir) < 0)
perror_with_name (dir);
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
/* There's too much mess with DOSish names like "d:", "d:.",
"d:./foo" etc. Instead of having lots of special #ifdef'ed code,
simply get the canonicalized name of the current directory. */
- dir = getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
-#endif
+ if (_have_dos_based_file_system)
+ dir = getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
len = strlen (dir);
if (IS_DIR_SEPARATOR (dir[len - 1]))
{
/* Remove the trailing slash unless this is a root directory
(including a drive letter on non-Unix systems). */
- if (!(len == 1) /* "/" */
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
- && !(len == 3 && dir[1] == ':') /* "d:/" */
-#endif
- )
- len--;
+ if (_have_dos_based_file_system) {
+ if (!(len == 1) /* "/" */
+ && !(len == 3 && dir[1] == ':') /* "d:/" */
+ )
+ len--;
+ } else {
+ if (!(len == 1)) /* "/" */
+ len--;
+ }
}
dir = savestring (dir, len);
Index: include/filenames.h
===================================================================
RCS file: /cvs/src/src/include/filenames.h,v
retrieving revision 1.5
diff -u -r1.5 filenames.h
--- include/filenames.h 21 Mar 2008 23:40:18 -0000 1.5
+++ include/filenames.h 5 Sep 2009 09:23:15 -0000
@@ -5,7 +5,7 @@
use forward- and back-slash in path names interchangeably, and
some of them have case-insensitive file names.
- Copyright 2000, 2001, 2007 Free Software Foundation, Inc.
+ Copyright 2000, 2001, 2007, 2009 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -30,25 +30,54 @@
extern "C" {
#endif
-#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
-
-#ifndef HAVE_DOS_BASED_FILE_SYSTEM
-#define HAVE_DOS_BASED_FILE_SYSTEM 1
+#ifndef FALSE
+#define FALSE 0
+#endif
+#ifndef TRUE
+#define TRUE 1
#endif
-#define IS_DIR_SEPARATOR(c) ((c) == '/' || (c) == '\\')
-/* Note that IS_ABSOLUTE_PATH accepts d:foo as well, although it is
- 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] == ':')))
-
-#else /* not DOSish */
+/*
+ * Defined in gdb/main.c
+ *
+ * This determines whether we have
+ * as a separator : / or \
+ * a prefix [a-z]: or not
+ * Replaces HAVE_DOS_BASED_FILE_SYSTEM and FILENAME_PREFIX_LEN.
+ *
+ * Case sensitive/insensitive file name comparison is *not* influenced by this.
+ */
+
+extern int _have_dos_based_file_system;
+
+static inline int _isalpha(int c)
+{
+ if (c <= 'Z' && c >= 'A')
+ return TRUE;
+ if (c <= 'z' && c >= 'a')
+ return TRUE;
+ return FALSE;
+}
-#define IS_DIR_SEPARATOR(c) ((c) == '/')
-#define IS_ABSOLUTE_PATH(f) (IS_DIR_SEPARATOR((f)[0]))
+static inline int IS_DIR_SEPARATOR(int c)
+{
+ if (_have_dos_based_file_system) {
+ return (c == '/' || c == '\\');
+ } else {
+ return (c == '/');
+ }
+}
-#endif /* not DOSish */
+static inline int IS_ABSOLUTE_PATH(const char *f)
+{
+ if (IS_DIR_SEPARATOR(f[0]))
+ return TRUE;
+ if (_have_dos_based_file_system) {
+ if (_isalpha(f[0]) && f[1] == ':')
+ return TRUE;
+ }
+ return FALSE;
+}
extern int filename_cmp (const char *s1, const char *s2);
#define FILENAME_CMP(s1, s2) filename_cmp(s1, s2)
next prev parent reply other threads:[~2009-09-05 9:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-21 0:24 Danny Backx
2009-08-21 17:30 ` Tom Tromey
2009-08-21 17:57 ` Eli Zaretskii
2009-08-21 18:23 ` Danny Backx
2009-08-21 18:51 ` Eli Zaretskii
2009-08-21 20:15 ` Danny Backx
2009-08-21 21:57 ` Eli Zaretskii
2009-08-22 9:03 ` Tom Tromey
2009-08-22 9:55 ` Danny Backx
2009-08-22 11:07 ` Eli Zaretskii
2009-08-24 10:11 ` Danny Backx
2009-09-01 18:03 ` Danny Backx
2009-09-01 19:34 ` Eli Zaretskii
2009-09-01 20:10 ` Danny Backx
2009-09-02 3:25 ` Eli Zaretskii
2009-09-05 9:33 ` Danny Backx [this message]
2009-09-01 19:35 ` Eli Zaretskii
2009-08-22 22:01 ` Daniel Jacobowitz
2009-08-23 7:28 ` Joel Brobecker
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=1252143311.6106.252.camel@pavilion \
--to=danny.backx@scarlet.be \
--cc=eliz@gnu.org \
--cc=gdb@sourceware.org \
/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