From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 6/9] Reimplement DJGPP's .gdbinit -> gdb.ini renaming.
Date: Thu, 27 Jun 2013 18:52:00 -0000 [thread overview]
Message-ID: <20130627185243.6625.58681.stgit@brno.lan> (raw)
In-Reply-To: <20130627185200.6625.10526.stgit@brno.lan>
This simplifies the .gdbinit filename selection logic.
We have a GDBINIT_FILENAME define that supposedly configurations would
override, but none do so. Instead, the only configuration that wants
a different file name instead of ".gdbinit", djgpp, does a strcpy over
the gdbinit global array. This means the array needs to be sized, and
the code that does that is doing the usual
'PATH_MAX/FILENAME_MAX/fallback constant/etc.' mess.
Instead of all that, it's much simpler to have configure specificy the
.gdbinit filename. As bonus, we can then make the "gdbinit" global
array const.
gdb/
2013-06-27 Pedro Alves <palves@redhat.com>
* configure.ac (GDBINIT): Define, depending on host.
* go32-nat.c (init_go32_ops): Don't override gdbinit here.
* top.c (PATH_MAX): Delete fallback definition.
(GDBINIT_FILENAME): Delete.
(gdbinit): Reimplement as const char array set to the GDBINIT
string constant.
* top.h (gdbinit): Make const.
---
gdb/config.in | 3 +++
gdb/configure | 14 ++++++++++++++
gdb/configure.ac | 11 +++++++++++
gdb/go32-nat.c | 3 ---
gdb/top.c | 15 ++-------------
gdb/top.h | 2 +-
6 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/gdb/config.in b/gdb/config.in
index 7cd22e3..92c2789 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -37,6 +37,9 @@
language is requested. */
#undef ENABLE_NLS
+/* The .gdbinit filename. */
+#undef GDBINIT
+
/* look for global separate data files in this path [DATADIR/gdb] */
#undef GDB_DATADIR
diff --git a/gdb/configure b/gdb/configure
index 383d634..dab0d20 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -12329,6 +12329,20 @@ $as_echo "#define HAVE_PERSONALITY 1" >>confdefs.h
fi
+case $host_os in
+ go32* | *djgpp*)
+ gdbinit=gdb.ini
+ ;;
+ *)
+ gdbinit=.gdbinit
+ ;;
+esac
+
+cat >>confdefs.h <<_ACEOF
+#define GDBINIT "$gdbinit"
+_ACEOF
+
+
# Support for --with-sysroot is a copy of GDB_AC_WITH_DIR,
# except that the argument to --with-sysroot is optional.
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 46a97bd..e378bde 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1881,6 +1881,17 @@ then
[Define if you support the personality syscall.])
fi
+dnl Set the host's .gdbinit filename.
+case $host_os in
+ go32* | *djgpp*)
+ gdbinit=gdb.ini
+ ;;
+ *)
+ gdbinit=.gdbinit
+ ;;
+esac
+AC_DEFINE_UNQUOTED(GDBINIT,"$gdbinit",[The .gdbinit filename.])
+
dnl Handle optional features that can be enabled.
# Support for --with-sysroot is a copy of GDB_AC_WITH_DIR,
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index a3f75b2..4dac617 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -1028,9 +1028,6 @@ init_go32_ops (void)
/* We are always processing GCC-compiled programs. */
processing_gcc_compilation = 2;
-
- /* Override the default name of the GDB init file. */
- strcpy (gdbinit, "gdb.ini");
}
/* Return the current DOS codepage number. */
diff --git a/gdb/top.c b/gdb/top.c
index 8ac756f..e78897f 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -78,20 +78,9 @@ extern void initialize_all_files (void);
#define DEFAULT_PROMPT "(gdb) "
#endif
-/* Initialization file name for gdb. This is overridden in some configs. */
-
-#ifndef PATH_MAX
-# ifdef FILENAME_MAX
-# define PATH_MAX FILENAME_MAX
-# else
-# define PATH_MAX 512
-# endif
-#endif
+/* Initialization file name for gdb. This is host-dependent. */
-#ifndef GDBINIT_FILENAME
-#define GDBINIT_FILENAME ".gdbinit"
-#endif
-char gdbinit[PATH_MAX + 1] = GDBINIT_FILENAME;
+const char gdbinit[] = GDBINIT;
int inhibit_gdbinit = 0;
diff --git a/gdb/top.h b/gdb/top.h
index 44aefb1..2f70539 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -28,7 +28,7 @@ extern int in_user_command;
extern int confirm;
extern char gdb_dirbuf[1024];
extern int inhibit_gdbinit;
-extern char gdbinit[];
+extern const char gdbinit[];
extern void print_gdb_version (struct ui_file *);
extern void print_gdb_configuration (struct ui_file *);
next prev parent reply other threads:[~2013-06-27 18:52 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-27 18:52 [PATCH 00/09] Import unistd and pathmax gnulib modules Pedro Alves
2013-06-27 18:52 ` [PATCH 3/9] Import the "unistd" gnulib module Pedro Alves
2013-06-27 18:52 ` Pedro Alves [this message]
2013-06-27 18:52 ` [PATCH 5/9] Constify main.c:get_init_files Pedro Alves
2013-06-27 18:52 ` [PATCH 2/9] utils.c: pathconf call, check for _PC_PATH_MAX instead of HAVE_UNISTD_H Pedro Alves
2013-06-27 18:52 ` [PATCH 1/9] Reimport gnulib from scratch Pedro Alves
2013-06-28 8:49 ` Yao Qi
2013-06-28 9:55 ` Pedro Alves
2013-06-28 12:10 ` Yao Qi
2013-06-28 12:28 ` Pedro Alves
2013-06-27 18:52 ` [PATCH 4/9] Rely on gnulib's unistd.h replacement Pedro Alves
2013-06-28 9:05 ` Yao Qi
2013-06-28 17:44 ` Pedro Alves
2013-06-28 18:11 ` Pedro Alves
2013-06-27 18:53 ` [PATCH 7/9] Import the "pathmax" gnulib module Pedro Alves
2013-06-27 18:53 ` [PATCH 8/9] Normalize on PATH_MAX instead of MAXPATHLEN throughout Pedro Alves
2013-06-28 15:21 ` Tom Tromey
2013-06-28 18:06 ` Pedro Alves
2013-06-28 19:08 ` Tom Tromey
2013-06-27 18:59 ` [PATCH 9/9] [GDBserver] hostio.c: Fallback to packet buffer size if PATH_MAX is not available Pedro Alves
2013-06-28 15:43 ` [PATCH 00/09] Import unistd and pathmax gnulib modules Tom Tromey
2013-07-01 11:31 ` Pedro Alves
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=20130627185243.6625.58681.stgit@brno.lan \
--to=palves@redhat.com \
--cc=gdb-patches@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