From: Tom Tromey Date: Sun, 2 Nov 2025 17:41:21 +0000 (-0700) Subject: Don't use "module" name X-Git-Url: https://git.feebdaed.xyz/?a=commitdiff_plain;h=b056a39914ed08da28f18f9b6eecf44447e069de;p=0xmirror%2Fbinutils-gdb.git Don't use "module" name 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 --- diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c index 30b45dc0f95..43e5a55a1b7 100644 --- a/gdb/compile/compile-object-run.c +++ b/gdb/compile/compile-object-run.c @@ -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 ()); diff --git a/gdb/compile/compile-object-run.h b/gdb/compile/compile-object-run.h index 7515b70ed58..ec2b7e02e4e 100644 --- a/gdb/compile/compile-object-run.h +++ b/gdb/compile/compile-object-run.h @@ -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 */ diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c index 3fa2896678f..fe5582647d7 100644 --- a/gdb/d-namespace.c +++ b/gdb/d-namespace.c @@ -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 diff --git a/gdb/python/py-events.h b/gdb/python/py-events.h index d9df3ab1206..e5b49266d5a 100644 --- a/gdb/python/py-events.h +++ b/gdb/python/py-events.h @@ -44,7 +44,7 @@ struct events_object #include "py-all-events.def" #undef GDB_PY_DEFINE_EVENT - PyObject *module; + PyObject *mod; }; diff --git a/gdb/python/py-evts.c b/gdb/python/py-evts.c index 73a1f08c5b5..cbd819ccefa 100644 --- a/gdb/python/py-evts.c +++ b/gdb/python/py-evts.c @@ -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; } diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index db8c274cdc0..88782f373d6 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -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; diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c index 3fa3b8da945..e7825565b46 100644 --- a/gdb/python/py-record-btrace.c +++ b/gdb/python/py-record-btrace.c @@ -866,7 +866,7 @@ recpy_call_filter (const uint64_t payload, std::optional 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 ()) { diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c index df8b8889e7a..dcca81a9df6 100644 --- a/gdb/python/py-utils.c +++ b/gdb/python/py-utils.c @@ -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; diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 502f66c5682..9a43cfae00a 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -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); diff --git a/gdb/python/python.c b/gdb/python/python.c index 0bf53cac2a9..29c8fbdb473 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -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) { diff --git a/gdbsupport/common-debug.cc b/gdbsupport/common-debug.cc index a78f2685dfd..2116c14e499 100644 --- a/gdbsupport/common-debug.cc +++ b/gdbsupport/common-debug.cc @@ -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"); diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h index 5886e3dd799..cc7ca6273cf 100644 --- a/gdbsupport/common-debug.h +++ b/gdbsupport/common-debug.h @@ -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::is_debug_enabled () const template static inline scoped_debug_start_end 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 (pred, module, func, start_prefix, + auto res = scoped_debug_start_end (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)