]> git.feebdaed.xyz Git - 0xmirror/binutils-gdb.git/commitdiff
Don't use "module" name
authorTom Tromey <tom@tromey.com>
Sun, 2 Nov 2025 17:41:21 +0000 (10:41 -0700)
committerTom Tromey <tom@tromey.com>
Thu, 18 Dec 2025 18:50:08 +0000 (11:50 -0700)
In C++20, "module" is an "identifier with special meaning".  While it
can be used as a variable name, it highlights as a keyword in Emacs,
and I think it's nicer to just avoid it.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32660

12 files changed:
gdb/compile/compile-object-run.c
gdb/compile/compile-object-run.h
gdb/d-namespace.c
gdb/python/py-events.h
gdb/python/py-evts.c
gdb/python/py-framefilter.c
gdb/python/py-record-btrace.c
gdb/python/py-utils.c
gdb/python/python-internal.h
gdb/python/python.c
gdbsupport/common-debug.cc
gdbsupport/common-debug.h

index 30b45dc0f95a55b36ff97b5769f262aab80b87b7..43e5a55a1b77514bd3d9e59b5d885147cab1054d 100644 (file)
@@ -33,7 +33,7 @@ struct do_module_cleanup
 {
   do_module_cleanup (int *ptr, compile_module_up &&mod)
     : executedp (ptr),
-      module (std::move (mod))
+      mod (std::move (mod))
   {
   }
 
@@ -44,7 +44,7 @@ struct do_module_cleanup
   int *executedp;
 
   /* The compile module.  */
-  compile_module_up module;
+  compile_module_up mod;
 };
 
 /* Cleanup everything after the inferior function dummy frame gets
@@ -62,23 +62,23 @@ do_module_cleanup (void *arg, int registers_valid)
 
       /* This code cannot be in compile_object_run as OUT_VALUE_TYPE
         no longer exists there.  */
-      if (data->module->scope == COMPILE_I_PRINT_ADDRESS_SCOPE
-         || data->module->scope == COMPILE_I_PRINT_VALUE_SCOPE)
+      if (data->mod->scope == COMPILE_I_PRINT_ADDRESS_SCOPE
+         || data->mod->scope == COMPILE_I_PRINT_VALUE_SCOPE)
        {
          struct value *addr_value;
          struct type *ptr_type
-           = lookup_pointer_type (data->module->out_value_type);
+           = lookup_pointer_type (data->mod->out_value_type);
 
          addr_value = value_from_pointer (ptr_type,
-                                          data->module->out_value_addr);
+                                          data->mod->out_value_addr);
 
          /* SCOPE_DATA would be stale unless EXECUTEDP != NULL.  */
          compile_print_value (value_ind (addr_value),
-                              data->module->scope_data);
+                              data->mod->scope_data);
        }
     }
 
-  objfile *objfile = data->module->objfile;
+  objfile *objfile = data->mod->objfile;
   gdb_assert (objfile != nullptr);
 
   /* We have to make a copy of the name so that we can unlink the
@@ -92,7 +92,7 @@ do_module_cleanup (void *arg, int registers_valid)
   clear_symtab_users (0);
 
   /* Delete the .c file.  */
-  unlink (data->module->source_file.c_str ());
+  unlink (data->mod->source_file.c_str ());
 
   /* Delete the .o file.  */
   unlink (objfile_name_s.c_str ());
@@ -117,16 +117,16 @@ create_copied_type_recursive (objfile *objfile, type *func_type)
    longer touch MODULE's memory after this function has been called.  */
 
 void
-compile_object_run (compile_module_up &&module)
+compile_object_run (compile_module_up &&mod)
 {
   struct value *func_val;
   struct do_module_cleanup *data;
   int dtor_found, executed = 0;
-  struct symbol *func_sym = module->func_sym;
-  CORE_ADDR regs_addr = module->regs_addr;
-  struct objfile *objfile = module->objfile;
+  struct symbol *func_sym = mod->func_sym;
+  CORE_ADDR regs_addr = mod->regs_addr;
+  struct objfile *objfile = mod->objfile;
 
-  data = new struct do_module_cleanup (&executed, std::move (module));
+  data = new struct do_module_cleanup (&executed, std::move (mod));
 
   try
     {
@@ -153,10 +153,10 @@ compile_object_run (compile_module_up &&module)
        }
       if (func_type->num_fields () >= 2)
        {
-         gdb_assert (data->module->out_value_addr != 0);
+         gdb_assert (data->mod->out_value_addr != 0);
          vargs[current_arg] = value_from_pointer
               (func_type->field (current_arg).type (),
-               data->module->out_value_addr);
+               data->mod->out_value_addr);
          ++current_arg;
        }
       gdb_assert (current_arg == func_type->num_fields ());
index 7515b70ed58f187bf81a64ff41c69956900e9e54..ec2b7e02e4eec514abb11ba98eafa7c91439e35f 100644 (file)
@@ -19,6 +19,6 @@
 
 #include "compile-object-load.h"
 
-extern void compile_object_run (compile_module_up &&module);
+extern void compile_object_run (compile_module_up &&mod);
 
 #endif /* GDB_COMPILE_COMPILE_OBJECT_RUN_H */
index 3fa2896678fec2180290b7dd93ea4058453a2bb2..fe5582647d7c3b8dd5c8356d701983ec26f16d48 100644 (file)
@@ -158,22 +158,22 @@ d_lookup_symbol (const struct language_defn *langdef,
   return sym;
 }
 
-/* Look up NAME in the D module MODULE.  Other arguments are as in
+/* Look up NAME in the D module MOD.  Other arguments are as in
    d_lookup_symbol_nonlocal.  If SEARCH is non-zero, search through
    base classes for a matching symbol.  */
 
 static struct block_symbol
-d_lookup_symbol_in_module (const char *module, const char *name,
+d_lookup_symbol_in_module (const char *mod, const char *name,
                           const struct block *block,
                           const domain_search_flags domain, int search)
 {
   char *concatenated_name = NULL;
 
-  if (module[0] != '\0')
+  if (mod[0] != '\0')
     {
       concatenated_name
-       = (char *) alloca (strlen (module) + strlen (name) + 2);
-      strcpy (concatenated_name, module);
+       = (char *) alloca (strlen (mod) + strlen (name) + 2);
+      strcpy (concatenated_name, mod);
       strcat (concatenated_name, ".");
       strcat (concatenated_name, name);
       name = concatenated_name;
@@ -200,7 +200,7 @@ lookup_module_scope (const struct language_defn *langdef,
                     const domain_search_flags domain, const char *scope,
                     int scope_len)
 {
-  char *module;
+  char *mod;
 
   if (scope[scope_len] != '\0')
     {
@@ -233,11 +233,10 @@ lookup_module_scope (const struct language_defn *langdef,
   if (scope_len == 0 && strchr (name, '.') == NULL)
     return d_lookup_symbol (langdef, name, block, domain, 1);
 
-  module = (char *) alloca (scope_len + 1);
-  strncpy (module, scope, scope_len);
-  module[scope_len] = '\0';
-  return d_lookup_symbol_in_module (module, name,
-                                   block, domain, 1);
+  mod = (char *) alloca (scope_len + 1);
+  strncpy (mod, scope, scope_len);
+  mod[scope_len] = '\0';
+  return d_lookup_symbol_in_module (mod, name, block, domain, 1);
 }
 
 /* Search through the base classes of PARENT_TYPE for a symbol named
index d9df3ab12061e56c891429c4cab65fa5282167f1..e5b49266d5a3088cbdaae0fac45d6b6d4daf59df 100644 (file)
@@ -44,7 +44,7 @@ struct events_object
 #include "py-all-events.def"
 #undef GDB_PY_DEFINE_EVENT
 
-  PyObject *module;
+  PyObject *mod;
 
 };
 
index 73a1f08c5b5492c50a4e962b2f7377a619697921..cbd819ccefa73c2502c3801e8f83cee18519d848 100644 (file)
@@ -43,7 +43,7 @@ add_new_registry (eventregistry_object **registryp, const char *name)
   if (*registryp == NULL)
     return -1;
 
-  return gdb_pymodule_addobject (gdb_py_events.module,
+  return gdb_pymodule_addobject (gdb_py_events.mod,
                                 name,
                                 (PyObject *)(*registryp));
 }
@@ -54,8 +54,8 @@ add_new_registry (eventregistry_object **registryp, const char *name)
 PyMODINIT_FUNC
 gdbpy_events_mod_func ()
 {
-  gdb_py_events.module = PyModule_Create (&EventModuleDef);
-  if (gdb_py_events.module == nullptr)
+  gdb_py_events.mod = PyModule_Create (&EventModuleDef);
+  if (gdb_py_events.mod == nullptr)
     return nullptr;
 
 #define GDB_PY_DEFINE_EVENT(name)                                      \
@@ -64,5 +64,5 @@ gdbpy_events_mod_func ()
 #include "py-all-events.def"
 #undef GDB_PY_DEFINE_EVENT
 
-  return gdb_py_events.module;
+  return gdb_py_events.mod;
 }
index db8c274cdc0e0caa7234be877b1b8c39264cc430..88782f373d6a6458d4034d2318a9d905a5e8a639 100644 (file)
@@ -1092,11 +1092,11 @@ bootstrap_python_frame_filters (const frame_info_ptr &frame,
   if (frame_obj == NULL)
     return NULL;
 
-  gdbpy_ref<> module (PyImport_ImportModule ("gdb.frames"));
-  if (module == NULL)
+  gdbpy_ref<> mod (PyImport_ImportModule ("gdb.frames"));
+  if (mod == NULL)
     return NULL;
 
-  gdbpy_ref<> sort_func (PyObject_GetAttrString (module.get (),
+  gdbpy_ref<> sort_func (PyObject_GetAttrString (mod.get (),
                                                 "execute_frame_filters"));
   if (sort_func == NULL)
     return NULL;
index 3fa3b8da945ae1589babc17e7eb66075a9b68d4e..e7825565b46aa12743e04cb770240c6e7745a2ac 100644 (file)
@@ -866,7 +866,7 @@ recpy_call_filter (const uint64_t payload, std::optional<uint64_t> ip,
 static PyObject *
 get_ptwrite_filter ()
 {
-  gdbpy_ref<> module (PyImport_ImportModule ("gdb.ptwrite"));
+  gdbpy_ref<> mod (PyImport_ImportModule ("gdb.ptwrite"));
 
   if (PyErr_Occurred ())
   {
@@ -875,7 +875,7 @@ get_ptwrite_filter ()
   }
 
   /* We need to keep the reference count.  */
-  gdbpy_ref<> ptw_filter (gdbpy_call_method (module.get (), "get_filter"));
+  gdbpy_ref<> ptw_filter (gdbpy_call_method (mod.get (), "get_filter"));
 
   if (PyErr_Occurred ())
     {
index df8b8889e7a438ca7a967420e590fd9e5fc3a755..dcca81a9df6a46b81a2e6eb3873c95744edaadbc 100644 (file)
@@ -331,12 +331,12 @@ gdb_py_generic_dict (PyObject *self, void *closure)
    OBJECT.  */
 
 int
-gdb_pymodule_addobject (PyObject *module, const char *name, PyObject *object)
+gdb_pymodule_addobject (PyObject *mod, const char *name, PyObject *object)
 {
   int result;
 
   Py_INCREF (object);
-  result = PyModule_AddObject (module, name, object);
+  result = PyModule_AddObject (mod, name, object);
   if (result < 0)
     Py_DECREF (object);
   return result;
index 502f66c5682692a7a98f9fc423b44daae02d351d..9a43cfae00a8055601af8672d7237ea65ddcc1df 100644 (file)
@@ -991,7 +991,7 @@ int gdb_py_int_as_long (PyObject *, long *);
 
 PyObject *gdb_py_generic_dict (PyObject *self, void *closure);
 
-int gdb_pymodule_addobject (PyObject *module, const char *name,
+int gdb_pymodule_addobject (PyObject *mod, const char *name,
                            PyObject *object);
 
 
index 0bf53cac2a92332a95319567292de75aabf223c8..29c8fbdb473be7aa71ea2cf7e1bfb2e98e7e8daf 100644 (file)
@@ -1309,17 +1309,17 @@ gdbpy_colorize (const std::string &filename, const std::string &contents,
 
   gdbpy_enter enter_py;
 
-  gdbpy_ref<> module (PyImport_ImportModule ("gdb.styling"));
-  if (module == nullptr)
+  gdbpy_ref<> mod (PyImport_ImportModule ("gdb.styling"));
+  if (mod == nullptr)
     {
       gdbpy_print_stack ();
       return {};
     }
 
-  if (!PyObject_HasAttrString (module.get (), "colorize"))
+  if (!PyObject_HasAttrString (mod.get (), "colorize"))
     return {};
 
-  gdbpy_ref<> hook (PyObject_GetAttrString (module.get (), "colorize"));
+  gdbpy_ref<> hook (PyObject_GetAttrString (mod.get (), "colorize"));
   if (hook == nullptr)
     {
       gdbpy_print_stack ();
@@ -1394,17 +1394,17 @@ gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch)
 
   gdbpy_enter enter_py;
 
-  gdbpy_ref<> module (PyImport_ImportModule ("gdb.styling"));
-  if (module == nullptr)
+  gdbpy_ref<> mod (PyImport_ImportModule ("gdb.styling"));
+  if (mod == nullptr)
     {
       gdbpy_print_stack ();
       return {};
     }
 
-  if (!PyObject_HasAttrString (module.get (), "colorize_disasm"))
+  if (!PyObject_HasAttrString (mod.get (), "colorize_disasm"))
     return {};
 
-  gdbpy_ref<> hook (PyObject_GetAttrString (module.get (),
+  gdbpy_ref<> hook (PyObject_GetAttrString (mod.get (),
                                            "colorize_disasm"));
   if (hook == nullptr)
     {
index a78f2685dfd4c3e5918621e30e2dd0fb1f8a91cf..2116c14e499d1751e8ce89f7a825ac499a80332a 100644 (file)
@@ -38,26 +38,26 @@ debug_printf (const char *fmt, ...)
 /* See gdbsupport/common-debug.h.  */
 
 void
-debug_prefixed_printf (const char *module, const char *func,
+debug_prefixed_printf (const char *mod, const char *func,
                       const char *format, ...)
 {
   va_list ap;
 
   va_start (ap, format);
-  debug_prefixed_vprintf (module, func, format, ap);
+  debug_prefixed_vprintf (mod, func, format, ap);
   va_end (ap);
 }
 
 /* See gdbsupport/common-debug.h.  */
 
 void
-debug_prefixed_vprintf (const char *module, const char *func,
+debug_prefixed_vprintf (const char *mod, const char *func,
                        const char *format, va_list args)
 {
   if (func != nullptr)
-    debug_printf ("%*s[%s] %s: ", debug_print_depth * 2, "", module, func);
+    debug_printf ("%*s[%s] %s: ", debug_print_depth * 2, "", mod, func);
   else
-    debug_printf ("%*s[%s] ", debug_print_depth * 2, "", module);
+    debug_printf ("%*s[%s] ", debug_print_depth * 2, "", mod);
 
   debug_vprintf (format, args);
   debug_printf ("\n");
index 5886e3dd79959cdc71ac6c04737c3e1e8ae761e9..cc7ca6273cfe5e0b171ed06f61552d2b51fb5d7e 100644 (file)
@@ -47,13 +47,13 @@ extern void debug_vprintf (const char *format, va_list ap)
    with a newline at the end.  */
 
 extern void ATTRIBUTE_PRINTF (3, 4) debug_prefixed_printf
-  (const char *module, const char *func, const char *format, ...);
+  (const char *mod, const char *func, const char *format, ...);
 
 /* Print a debug statement prefixed with the module and function name, and
    with a newline at the end.  */
 
 extern void ATTRIBUTE_PRINTF (3, 0) debug_prefixed_vprintf
-  (const char *module, const char *func, const char *format, va_list args);
+  (const char *mod, const char *func, const char *format, va_list args);
 
 /* Helper to define "_debug_print" macros.
 
@@ -63,19 +63,19 @@ extern void ATTRIBUTE_PRINTF (3, 0) debug_prefixed_vprintf
    The other arguments, as well as the name of the current function, are
    forwarded to debug_prefixed_printf.  */
 
-#define debug_prefixed_printf_cond(debug_enabled_cond, module, fmt, ...) \
+#define debug_prefixed_printf_cond(debug_enabled_cond, mod, fmt, ...) \
   do \
     { \
       if (debug_enabled_cond) \
-       debug_prefixed_printf (module, __func__, fmt, ##__VA_ARGS__); \
+       debug_prefixed_printf (mod, __func__, fmt, ##__VA_ARGS__); \
     } \
   while (0)
 
-#define debug_prefixed_printf_cond_nofunc(debug_enabled_cond, module, fmt, ...) \
+#define debug_prefixed_printf_cond_nofunc(debug_enabled_cond, mod, fmt, ...) \
   do \
     { \
       if (debug_enabled_cond) \
-       debug_prefixed_printf (module, nullptr, fmt, ##__VA_ARGS__); \
+       debug_prefixed_printf (mod, nullptr, fmt, ##__VA_ARGS__); \
     } \
   while (0)
 
@@ -99,7 +99,7 @@ struct scoped_debug_start_end
      DEBUG_ENABLED should either be of type 'bool &' or should be a type
      that can be invoked.
 
-     MODULE and FUNC are forwarded to debug_prefixed_printf.
+     MOD and FUNC are forwarded to debug_prefixed_printf.
 
      START_PREFIX and END_PREFIX are the statements to print on construction and
      destruction, respectively.
@@ -109,13 +109,13 @@ struct scoped_debug_start_end
      The format string is rendered during construction and is reused as is
      for the message on exit.  */
 
-  scoped_debug_start_end (PT &debug_enabled, const char *module,
+  scoped_debug_start_end (PT &debug_enabled, const char *mod,
                          const char *func, const char *start_prefix,
                          const char *end_prefix, const char *fmt,
                          va_list args)
     ATTRIBUTE_NULL_PRINTF (7, 0)
     : m_debug_enabled (debug_enabled),
-      m_module (module),
+      m_module (mod),
       m_func (func),
       m_end_prefix (end_prefix),
       m_with_format (fmt != nullptr)
@@ -240,13 +240,13 @@ scoped_debug_start_end<bool &>::is_debug_enabled () const
 
 template<typename PT>
 static inline scoped_debug_start_end<PT &> ATTRIBUTE_NULL_PRINTF (6, 7)
-make_scoped_debug_start_end (PT &&pred, const char *module, const char *func,
+make_scoped_debug_start_end (PT &&pred, const char *mod, const char *func,
                             const char *start_prefix,
                             const char *end_prefix, const char *fmt, ...)
 {
   va_list args;
   va_start (args, fmt);
-  auto res = scoped_debug_start_end<PT &> (pred, module, func, start_prefix,
+  auto res = scoped_debug_start_end<PT &> (pred, mod, func, start_prefix,
                                           end_prefix, fmt, args);
   va_end (args);
 
@@ -255,9 +255,9 @@ make_scoped_debug_start_end (PT &&pred, const char *module, const char *func,
 
 /* Helper to define a module-specific start/end debug macro.  */
 
-#define scoped_debug_start_end(debug_enabled, module, fmt, ...)                \
-  auto CONCAT(scoped_debug_start_end, __LINE__)                                \
-    = make_scoped_debug_start_end (debug_enabled, module,      \
+#define scoped_debug_start_end(debug_enabled, mod, fmt, ...)   \
+  auto CONCAT(scoped_debug_start_end, __LINE__)                        \
+    = make_scoped_debug_start_end (debug_enabled, mod,         \
                                   __func__, "start", "end",    \
                                   fmt, ##__VA_ARGS__)
 
@@ -265,9 +265,9 @@ make_scoped_debug_start_end (PT &&pred, const char *module, const char *func,
    case of `scoped_debug_start_end` where the start and end messages are "enter"
    and "exit", to denote entry and exit of a function.  */
 
-#define scoped_debug_enter_exit(debug_enabled, module) \
-  auto CONCAT(scoped_debug_start_end, __LINE__)                                \
-    = make_scoped_debug_start_end (debug_enabled, module,      \
+#define scoped_debug_enter_exit(debug_enabled, mod)            \
+  auto CONCAT(scoped_debug_start_end, __LINE__)                        \
+    = make_scoped_debug_start_end (debug_enabled, mod,         \
                                   __func__, "enter", "exit",   \
                                   nullptr)