Reimplement DJGPP's .gdbinit -> gdb.ini renaming.
authorPedro Alves <palves@redhat.com>
Mon, 1 Jul 2013 11:24:17 +0000 (11:24 +0000)
committerPedro Alves <palves@redhat.com>
Mon, 1 Jul 2013 11:24:17 +0000 (11:24 +0000)
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-07-01  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/ChangeLog
gdb/config.in
gdb/configure
gdb/configure.ac
gdb/go32-nat.c
gdb/top.c
gdb/top.h

index 7edc65ad5aa3a66a74f9d871b83ed1ad01d631bd..5a21e6b6dd6e5c7526922652642ac38f6d9f41ee 100644 (file)
@@ -1,3 +1,14 @@
+2013-07-01  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.
+       * configure, config.in: Regenerate.
+
 2013-07-01  Pedro Alves  <palves@redhat.com>
 
        * cli/cli-cmds.c (source_script): Make 'file' parameter const.
index 7cd22e315c67aef429b907b53b02547607867072..92c278978f38ff8c2cdafa17f1460e97c9653db5 100644 (file)
@@ -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
 
index 383d6348f90389c5e6ddaf1a9f3a929004ca3d11..dab0d204bcf62da81c0160983c8d5fc7ecf01576 100755 (executable)
@@ -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.
index 46a97bd0dc1ee674dc52bff77e0b9aa028c3542d..e378bde23938a82c33a04693b055d975ca4f6adf 100644 (file)
@@ -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,
index a3f75b29a00d0b75d1624358865847768b509aca..4dac617a7e806d3cde19fc5e097978e26bb9607f 100644 (file)
@@ -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.  */
index 8ac756f11f9ce16721c3e3faf0cbe7e69adcdfa4..e78897f36c96b534b47e14b89596b440eec96a2e 100644 (file)
--- 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;
 
index 44aefb1fa953fcd0e4f1da7324c0b72a171832b1..2f70539630aa1bd8be3f855cd4683abc93a27160 100644 (file)
--- 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 *);
This page took 0.038953 seconds and 4 git commands to generate.