This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] gdb: Use std::max and std::min throughout


On 09/19/2016 12:47 PM, Ulrich Weigand wrote:

> 
> It seems the reason for this is a GDB header trick in common/gdb_locale.h:
> 
> #ifdef ENABLE_NLS
> ...
> #else
> # define gettext(Msgid) (Msgid)
> ...
> #endif
> 
> This will obviously cause problems if the <libintl.h> header is included
> at any point after "gdb_locale.h" (which is in turn included by "defs.h"
> via "common-defs.h", and thus by any GDB file).
> 
> Apparently in the past this newer happened.  But after your change to
> include <algorithm>, this is now triggered, since (at least the GCC 4.1
> copy of) <algorihm> includes <libintl.h> via <bits/stl_algobase.h>,
> <iosfwd>, and <bits/c++locale.h>.
> 
> Any thoughts how to fix this?

I tried a --disable-nls with both gcc 5.1 and 4.7 here, and it
doesn't trigger this.  I can't seem to find the libintl.h inclusion
you're seeing.  Sounds like that was changed at some point.

The gdb_locale.h code in question is:

#ifdef ENABLE_NLS
# include <libintl.h>
# define _(String) gettext (String)
# ifdef gettext_noop
#  define N_(String) gettext_noop (String)
# else
#  define N_(String) (String)
# endif
#else
# define gettext(Msgid) (Msgid)
# define dgettext(Domainname, Msgid) (Msgid)
# define dcgettext(Domainname, Msgid, Category) (Msgid)
# define textdomain(Domainname) while (0) /* nothing */
# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */
# define _(String) (String)
# define N_(String) (String)
#endif

How about always including libintl.h, even when ENABLE_NLS:

#ifdef HAVE_LIBINTL_H
# include <libintl.h>
#endif

#ifdef ENABLE_NLS
# define _(String) gettext (String)
# ifdef gettext_noop
#  define N_(String) gettext_noop (String)
# else
#  define N_(String) (String)
# endif
#else
# define gettext(Msgid) (Msgid)
# define dgettext(Domainname, Msgid) (Msgid)
# define dcgettext(Domainname, Msgid, Category) (Msgid)
# define textdomain(Domainname) while (0) /* nothing */
# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */
# define _(String) (String)
# define N_(String) (String)
#endif

I.e., something like the patch below.

>From 55a19a41adba756ebb82f987a5ebbba4dcd8ee27 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Mon, 19 Sep 2016 14:29:12 +0100
Subject: [PATCH] fix libintl.h

---
 gdb/common/common.m4    | 2 +-
 gdb/common/gdb_locale.h | 5 ++++-
 gdb/config.in           | 9 ++++++---
 gdb/configure           | 2 +-
 gdb/gdbserver/config.in | 3 +++
 gdb/gdbserver/configure | 2 +-
 6 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/gdb/common/common.m4 b/gdb/common/common.m4
index 68afc65..4192020 100644
--- a/gdb/common/common.m4
+++ b/gdb/common/common.m4
@@ -28,7 +28,7 @@ AC_DEFUN([GDB_AC_COMMON], [
   AC_CHECK_HEADERS(linux/perf_event.h locale.h memory.h signal.h dnl
 		   sys/resource.h sys/socket.h sys/syscall.h dnl
 		   sys/un.h sys/wait.h dnl
-		   thread_db.h wait.h)
+		   thread_db.h wait.h libintl.h)
 
   AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 socketpair sigaction])
 
diff --git a/gdb/common/gdb_locale.h b/gdb/common/gdb_locale.h
index 686260e..15fa364 100644
--- a/gdb/common/gdb_locale.h
+++ b/gdb/common/gdb_locale.h
@@ -23,8 +23,11 @@
 # include <locale.h>
 #endif
 
-#ifdef ENABLE_NLS
+#ifdef HAVE_LIBINTL_H
 # include <libintl.h>
+#endif
+
+#ifdef ENABLE_NLS
 # define _(String) gettext (String)
 # ifdef gettext_noop
 #  define N_(String) gettext_noop (String)
diff --git a/gdb/config.in b/gdb/config.in
index c82a5b4..465d3a9 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -237,6 +237,9 @@
 /* Define to 1 if you have the `libiconvlist' function. */
 #undef HAVE_LIBICONVLIST
 
+/* Define to 1 if you have the <libintl.h> header file. */
+#undef HAVE_LIBINTL_H
+
 /* Define if you have the ipt library. */
 #undef HAVE_LIBIPT
 
@@ -453,12 +456,12 @@
 /* Define to 1 if your system has struct lwp. */
 #undef HAVE_STRUCT_LWP
 
-/* Define to 1 if `struct ptrace_lwpinfo' is a member of `pl_tdname'. */
-#undef HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME
-
 /* Define to 1 if `struct ptrace_lwpinfo' is a member of `pl_syscall_code'. */
 #undef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE
 
+/* Define to 1 if `struct ptrace_lwpinfo' is a member of `pl_tdname'. */
+#undef HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME
+
 /* Define to 1 if your system has struct reg in <machine/reg.h>. */
 #undef HAVE_STRUCT_REG
 
diff --git a/gdb/configure b/gdb/configure
index e2d853d..499d3c3 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -12198,7 +12198,7 @@ $as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h
   fi
 
 
-  for ac_header in linux/perf_event.h locale.h memory.h signal.h 		   sys/resource.h sys/socket.h sys/syscall.h 		   sys/un.h sys/wait.h 		   thread_db.h wait.h
+  for ac_header in linux/perf_event.h locale.h memory.h signal.h 		   sys/resource.h sys/socket.h sys/syscall.h 		   sys/un.h sys/wait.h 		   thread_db.h wait.h libintl.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index 04072cf..52ba0cd 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -117,6 +117,9 @@
 /* Define to 1 if you have the `dl' library (-ldl). */
 #undef HAVE_LIBDL
 
+/* Define to 1 if you have the <libintl.h> header file. */
+#undef HAVE_LIBINTL_H
+
 /* Define to 1 if you have the `mcheck' library (-lmcheck). */
 #undef HAVE_LIBMCHECK
 
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index f112517..4b83790 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -5867,7 +5867,7 @@ $as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h
   fi
 
 
-  for ac_header in linux/perf_event.h locale.h memory.h signal.h 		   sys/resource.h sys/socket.h sys/syscall.h 		   sys/un.h sys/wait.h 		   thread_db.h wait.h
+  for ac_header in linux/perf_event.h locale.h memory.h signal.h 		   sys/resource.h sys/socket.h sys/syscall.h 		   sys/un.h sys/wait.h 		   thread_db.h wait.h libintl.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-- 
2.5.5



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]