+
+/* Define a TYPE constant ID as an externally visible name. Use like this:
+
+ #define ID_val (some integer preprocessor expression)
+ #if ENUMABLE (ID_val)
+ DEFINE_GDB_SYMBOL_ENUM (ID)
+ #else
+ DEFINE_GDB_SYMBOL_BEGIN (TYPE, ID)
+ # define ID ID_val
+ DEFINE_GDB_SYMBOL_END (ID)
+ #endif
+
+ This hack is for the benefit of compilers that do not make macro
+ definitions visible to the debugger. It's used for symbols that
+ .gdbinit needs, symbols whose values may not fit in 'int' (where an
+ enum would suffice).
+
+ Some GCC versions before GCC 4.2 omit enums in debugging output;
+ see GCC bug 23336. So don't use enums with older GCC. */
+
+#if !defined __GNUC__ || 4 < __GNUC__ + (2 <= __GNUC_MINOR__)
+# define ENUMABLE(val) (INT_MIN <= (val) && (val) <= INT_MAX)
+#else
+# define ENUMABLE(val) 0
+#endif
+
+/* On AIX 7.1 ENUMABLE should return true when possible, otherwise the
+ linker can optimize the symbols away, making it harder to debug.
+ This was discovered only late in the release process, so to play it
+ safe for now, non-AIX platforms do not use enums for debugging symbols.
+ FIXME: remove this comment and the following four lines of code. */
+#ifndef _AIX
+# undef ENUMABLE
+# define ENUMABLE(val) 0
+#endif
+
+#define DEFINE_GDB_SYMBOL_ENUM(id) enum { id = id##_val };
+#if defined MAIN_PROGRAM
+# define DEFINE_GDB_SYMBOL_BEGIN(type, id) type const id EXTERNALLY_VISIBLE
+# define DEFINE_GDB_SYMBOL_END(id) = id;
+#else
+# define DEFINE_GDB_SYMBOL_BEGIN(type, id)
+# define DEFINE_GDB_SYMBOL_END(val)