Re: [RFA] Get rid of xm-go32.h (was: [COMMIT] Get rid of xm-cygwin.h)

Eli Zaretskii
2005-05-12T21:35:57Z

> Date: Thu, 12 May 2005 21:04:47 +0200 (CEST)
> From: Mark Kettenis <mark.kettenis@xs4all.nl>
> CC: gdb-patches@sourceware.org
>
> I'd happily see tm-cisco.h and tm-os68k.h removed. But if there are
> reasons to keep them, or if you don't feel like doing the legwork
> needed to remove the associated targets completely, just remove the
> definition of GDBINIT_FILENAME from those files.

Will do the latter. (As I told earlier in this thread, I don't think
we should remove these targets without going through deprecating them
first, which should be announced in NEWS.)

> -XM_FILE= xm-go32.h
> +XM_FILE=
>
> NAT_FILE= nm-go32.h
> NATDEPFILES= go32-nat.o i386-nat.o
>
> Please remove XM_FILE completely.

Done.

> +#ifndef PATH_MAX
> +# ifdef FILENAME_MAX
> +# define PATH_MAX FILENAME_MAX
> +# else
> +# define PATH_MAX 512
> +# endif
> +#endif
>
> I think the proper constant to use here is NAME_MAX, which is the
> POSIX standard for the "Maximum number of bytes in a filename (not
> including terminating null)".

I don't want to use NAME_MAX because it's too conservative on some
platforms. For example, DJGPP sets it to 12, which limits it to 8+3
names.

I know that PATH_MAX can be as large as 4K on some platforms, but I
think that waste is not important enough to care about.

I committed the patches with PATH_MAX, but if you insist, I will
change that to NAME_MAX in a separate patch.

> Why not simply write:
>
> char gdbinit[NAME_MAX + 1] = ".gdbinit";

Done.

> init_cli_cmds (void)
> {
> struct cmd_list_element *c;
> + char *source_help_text;
> + extern char gdbinit[];
>
> Please don't add new 'externs'. Include "top.h" instead.

Done.

Here's the patch that was actually committed:

2005-05-13 Eli Zaretskii <eliz@gnu.org>

* Makefile.in (go32-nat.o): Add $(top_h) to prerequisites.

* go32-nat.c: Include top.h. Update copyright years.
(init_go32_ops): Override the default value of gdbinit[] with
"gdb.ini".

* cli/cli-cmds.c (init_cli_cmds): Use gdbinit[] instead of a
compile-time literal string GDBINIT_FILENAME.
Don't define GDBINIT_FILENAME.

* top.c (PATH_MAX): Define if not defined.
(gdbinit): Declare with a constant size PATH_MAX.

* config/i386/go32.mh (XM_FILE): Remove.

* config/i386/xm-go32.h: Remove file.

Index: gdb/config/i386/go32.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/go32.mh,v
retrieving revision 1.8
diff -u -r1.8 go32.mh
--- gdb/config/i386/go32.mh 20 Jan 2004 09:29:17 -0000 1.8
+++ gdb/config/i386/go32.mh 12 May 2005 21:14:34 -0000
@@ -1,8 +1,6 @@
# Host: Intel x86 running DJGPP
MH_CFLAGS=

-XM_FILE= xm-go32.h
-
NAT_FILE= nm-go32.h
NATDEPFILES= go32-nat.o i386-nat.o

Index: gdb/cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.59
diff -u -r1.59 cli-cmds.c
--- gdb/cli/cli-cmds.c 28 Apr 2005 20:32:41 -0000 1.59
+++ gdb/cli/cli-cmds.c 12 May 2005 21:15:16 -0000
@@ -50,10 +50,6 @@
#include "tui/tui.h" /* For tui_active et.al. */
#endif

-#ifndef GDBINIT_FILENAME
-#define GDBINIT_FILENAME ".gdbinit"
-#endif
-
/* Prototypes for local command functions */

static void complete_command (char *, int);
@@ -1100,6 +1096,7 @@
init_cli_cmds (void)
{
struct cmd_list_element *c;
+ char *source_help_text;

/* Define the classes of commands.
They will appear in the help list in the reverse of this order. */
@@ -1164,10 +1161,12 @@
Use the \"document\" command to give documentation for the new command.\n\
Commands defined in this way may have up to ten arguments."));

- c = add_cmd ("source", class_support, source_command, _("\
+ source_help_text = xstrprintf (_("\
Read commands from a file named FILE.\n\
-Note that the file \"" GDBINIT_FILENAME "\" is read automatically in this way\n\
-when gdb is started."), &cmdlist);
+Note that the file \"%s\" is read automatically in this way\n\
+when gdb is started."), gdbinit);
+ c = add_cmd ("source", class_support, source_command,
+ source_help_text, &cmdlist);
set_cmd_completer (c, filename_completer);

add_com ("quit", class_support, quit_command, _("Exit gdb."));
Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.728
diff -u -r1.728 Makefile.in
--- gdb/Makefile.in 12 May 2005 20:21:18 -0000 1.728
+++ gdb/Makefile.in 12 May 2005 21:16:10 -0000
@@ -1993,7 +1993,7 @@
go32-nat.o: go32-nat.c $(defs_h) $(inferior_h) $(gdb_wait_h) $(gdbcore_h) \
$(command_h) $(gdbcmd_h) $(floatformat_h) $(buildsym_h) \
$(i387_tdep_h) $(i386_tdep_h) $(value_h) $(regcache_h) \
- $(gdb_string_h)
+ $(gdb_string_h) $(top_h)
h8300-tdep.o: h8300-tdep.c $(defs_h) $(value_h) $(arch_utils_h) $(regcache_h) \
$(gdbcore_h) $(objfiles_h) $(gdb_assert_h) $(dis_asm_h) \
$(dwarf2_frame_h) $(frame_base_h) $(frame_unwind_h)
Index: gdb/config/i386/xm-go32.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/xm-go32.h,v
retrieving revision 1.9
diff -u -r1.9 xm-go32.h
--- gdb/config/i386/xm-go32.h 2004-11-13 17:00:02 1.9
+++ /dev/null 2005-05-12 08:47:16
@@ -1,21 +0,0 @@
-/* Host-dependent definitions for Intel x86 running DJGPP.
- Copyright 1993-1996 Free Software Foundation, Inc.
-
- This file is part of GDB.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#define GDBINIT_FILENAME "gdb.ini"