gdb: Use SYS_DOMAIN instead of DOMAIN when calling sym-domains.def

Message ID 20240129183715.761022-1-lancelot.six@amd.com
State New
Headers
Series gdb: Use SYS_DOMAIN instead of DOMAIN when calling sym-domains.def |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 warning Patch is already merged
linaro-tcwg-bot/tcwg_gdb_check--master-arm warning Patch is already merged

Commit Message

Lancelot SIX Jan. 29, 2024, 6:37 p.m. UTC
  Since commit 6771fc6f1d9 "Use a .def file for domain_enum", the
sym-domains.def file has been introduced, and requires the user to
define the DOMAIN(x) macro.

On older systems (centos-7 with glibc-1.17 for example), this DOMAIN
macro conflicts with another macro defined in /usr/include/math.h.

Fix this conflict by changing sym-domains.def to use a macro named
SYM_DOMAIN instead of DOMAIN.

Change-Id: I679df30e2bd2f4333343f16bbd2a3511a37550a3
---
 gdb/guile/scm-symbol.c |  4 ++--
 gdb/python/py-symbol.c |  4 ++--
 gdb/sym-domains.def    | 16 ++++++++--------
 gdb/symtab.c           | 16 ++++++++--------
 gdb/symtab.h           | 12 ++++++------
 5 files changed, 26 insertions(+), 26 deletions(-)


base-commit: 1cb2b3dfd8992ced9e78a75cdfb4b9884c62185a
  

Comments

Lancelot SIX Jan. 29, 2024, 6:40 p.m. UTC | #1
On 29/01/2024 18:37, Lancelot SIX wrote:
> Since commit 6771fc6f1d9 "Use a .def file for domain_enum", the
> sym-domains.def file has been introduced, and requires the user to
> define the DOMAIN(x) macro.
> 
> On older systems (centos-7 with glibc-1.17 for example), this DOMAIN
                                         ^
This should be 2.17.  I fixed this locally.

> macro conflicts with another macro defined in /usr/include/math.h.
> 
> Fix this conflict by changing sym-domains.def to use a macro named
> SYM_DOMAIN instead of DOMAIN.
  
Tom Tromey Jan. 29, 2024, 7:13 p.m. UTC | #2
>>>>> "Lancelot" == Lancelot SIX <lancelot.six@amd.com> writes:

Lancelot> Since commit 6771fc6f1d9 "Use a .def file for domain_enum", the
Lancelot> sym-domains.def file has been introduced, and requires the user to
Lancelot> define the DOMAIN(x) macro.

Lancelot> On older systems (centos-7 with glibc-1.17 for example), this DOMAIN
Lancelot> macro conflicts with another macro defined in /usr/include/math.h.

Lancelot> Fix this conflict by changing sym-domains.def to use a macro named
Lancelot> SYM_DOMAIN instead of DOMAIN.

Thanks.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  
Lancelot SIX Jan. 29, 2024, 8:23 p.m. UTC | #3
> Lancelot> Fix this conflict by changing sym-domains.def to use a macro named
> Lancelot> SYM_DOMAIN instead of DOMAIN.
> 
> Thanks.
> Approved-By: Tom Tromey <tom@tromey.com>
> 
> Tom

Thanks,

I have pushed this patch.

Best,
Lancelot.
  

Patch

diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index 7061ff58872..860ed522274 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -697,11 +697,11 @@  static const scheme_integer_constant symbol_integer_constants[] =
   X (LOC_REGPARM_ADDR),
 #undef X
 
-#define DOMAIN(X) \
+#define SYM_DOMAIN(X) \
   { "SYMBOL_" #X "_DOMAIN", to_scripting_domain (X ## _DOMAIN) },	\
   { "SEARCH_" #X "_DOMAIN", to_scripting_domain (SEARCH_ ## X ## _DOMAIN) },
 #include "sym-domains.def"
-#undef DOMAIN
+#undef SYM_DOMAIN
 
   /* Historical.  */
   { "SYMBOL_VARIABLES_DOMAIN", to_scripting_domain (SEARCH_VAR_DOMAIN) },
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index db8df891b29..1ebdf028a34 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -677,14 +677,14 @@  gdbpy_initialize_symbols (void)
 				  LOC_REGPARM_ADDR) < 0)
     return -1;
 
-#define DOMAIN(X)							\
+#define SYM_DOMAIN(X)							\
   if (PyModule_AddIntConstant (gdb_module, "SYMBOL_" #X "_DOMAIN",	\
 			       to_scripting_domain (X ## _DOMAIN)) < 0	\
       || PyModule_AddIntConstant (gdb_module, "SEARCH_" #X "_DOMAIN",	\
 				  to_scripting_domain (SEARCH_ ## X ## _DOMAIN)) < 0) \
     return -1;
 #include "sym-domains.def"
-#undef DOMAIN
+#undef SYM_DOMAIN
 
   return gdb_pymodule_addobject (gdb_module, "Symbol",
 				 (PyObject *) &symbol_object_type);
diff --git a/gdb/sym-domains.def b/gdb/sym-domains.def
index 7545631063b..dd5b1b6bc5a 100644
--- a/gdb/sym-domains.def
+++ b/gdb/sym-domains.def
@@ -21,38 +21,38 @@ 
    none of the following apply.  This usually indicates an error either
    in the symbol information or in gdb's handling of symbols.  */
 
-DOMAIN (UNDEF)
+SYM_DOMAIN (UNDEF)
 
 /* VAR_DOMAIN is the usual domain.  In C, this contains variables,
    function names, typedef names and enum type values.  */
 
-DOMAIN (VAR)
+SYM_DOMAIN (VAR)
 
 /* STRUCT_DOMAIN is used in C to hold struct, union and enum type names.
    Thus, if `struct foo' is used in a C program, it produces a symbol named
    `foo' in the STRUCT_DOMAIN.  */
 
-DOMAIN (STRUCT)
+SYM_DOMAIN (STRUCT)
 
 /* MODULE_DOMAIN is used in Fortran to hold module type names.  */
 
-DOMAIN (MODULE)
+SYM_DOMAIN (MODULE)
 
 /* LABEL_DOMAIN may be used for names of labels (for gotos).  */
 
-DOMAIN (LABEL)
+SYM_DOMAIN (LABEL)
 
 /* Fortran common blocks.  Their naming must be separate from VAR_DOMAIN.
    They also always use LOC_COMMON_BLOCK.  */
-DOMAIN (COMMON_BLOCK)
+SYM_DOMAIN (COMMON_BLOCK)
 
 /* TYPE_DOMAIN is for types and typedefs.  Note that tags are not
    found here, see STRUCT_DOMAIN above.  If a language does not have a
    tag namespace, then all types (including structures, etc) are
    here.  */
 
-DOMAIN (TYPE)
+SYM_DOMAIN (TYPE)
 
 /* FUNCTION_DOMAIN is for functions and methods.  */
 
-DOMAIN (FUNCTION)
+SYM_DOMAIN (FUNCTION)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 517e843244b..5221989e6f4 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -306,10 +306,10 @@  domain_name (domain_enum e)
 {
   switch (e)
     {
-#define DOMAIN(X)				\
+#define SYM_DOMAIN(X)				\
       case X ## _DOMAIN: return #X "_DOMAIN";
 #include "sym-domains.def"
-#undef DOMAIN
+#undef SYM_DOMAIN
     default: gdb_assert_not_reached ("bad domain_enum");
     }
 }
@@ -320,10 +320,10 @@  std::string
 domain_name (domain_search_flags flags)
 {
   static constexpr domain_search_flags::string_mapping mapping[] = {
-#define DOMAIN(X) \
+#define SYM_DOMAIN(X) \
     MAP_ENUM_FLAG (SEARCH_ ## X ## _DOMAIN),
 #include "sym-domains.def"
-#undef DOMAIN
+#undef SYM_DOMAIN
   };
 
   return flags.to_string (mapping);
@@ -340,10 +340,10 @@  from_scripting_domain (int val)
 	 convert it to a search constant.  */
       switch (val)
 	{
-#define DOMAIN(X)					\
+#define SYM_DOMAIN(X)					\
 	  case X ## _DOMAIN: break;
 #include "sym-domains.def"
-#undef DOMAIN
+#undef SYM_DOMAIN
 	default:
 	  error (_("unrecognized domain constant"));
 	}
@@ -361,10 +361,10 @@  from_scripting_domain (int val)
 	 this.  */
       val &= ~SCRIPTING_SEARCH_FLAG;
       int check = val;
-#define DOMAIN(X)				\
+#define SYM_DOMAIN(X)				\
       check &= ~ (int) SEARCH_ ## X ## _DOMAIN;
 #include "sym-domains.def"
-#undef DOMAIN
+#undef SYM_DOMAIN
       if (check != 0)
 	error (_("unrecognized domain constant"));
       return (domain_search_flag) val;
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 3029f60cb4b..d43207ed70a 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -894,9 +894,9 @@  struct minimal_symbol : public general_symbol_info
 
 enum domain_enum
 {
-#define DOMAIN(X) X ## _DOMAIN,
+#define SYM_DOMAIN(X) X ## _DOMAIN,
 #include "sym-domains.def"
-#undef DOMAIN
+#undef SYM_DOMAIN
 };
 
 /* The number of bits in a symbol used to represent the domain.  */
@@ -909,19 +909,19 @@  extern const char *domain_name (domain_enum);
    let the search match multiple kinds of symbol.  */
 enum domain_search_flag
 {
-#define DOMAIN(X) \
+#define SYM_DOMAIN(X) \
   SEARCH_ ## X ## _DOMAIN = (1 << X ## _DOMAIN),
 #include "sym-domains.def"
-#undef DOMAIN
+#undef SYM_DOMAIN
 };
 DEF_ENUM_FLAGS_TYPE (enum domain_search_flag, domain_search_flags);
 
 /* A convenience constant to search for any symbol.  */
 constexpr domain_search_flags SEARCH_ALL
     = ((domain_search_flags) 0
-#define DOMAIN(X) | SEARCH_ ## X ## _DOMAIN
+#define SYM_DOMAIN(X) | SEARCH_ ## X ## _DOMAIN
 #include "sym-domains.def"
-#undef DOMAIN
+#undef SYM_DOMAIN
        );
 
 /* A convenience define for "C-like" name lookups, matching variables,