* [PATCH] Remove TYPE_FN_FIELD_STUB
@ 2026-02-09 2:55 Tom Tromey
2026-02-09 4:22 ` Simon Marchi
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2026-02-09 2:55 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
Nothing sets TYPE_FN_FIELD_STUB any more -- I suspect it was a stabs
thing, but didn't look.
This patch removes this macro and supporting code.
Regression tested on x86-64 Fedora 40.
---
gdb/c-typeprint.c | 36 +++-------
gdb/gdbtypes.c | 167 ----------------------------------------------
gdb/gdbtypes.h | 20 +-----
gdb/gnu-v3-abi.c | 1 -
gdb/linespec.c | 2 -
gdb/valops.c | 6 --
6 files changed, 14 insertions(+), 218 deletions(-)
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 683517a2176..cfacf48fe2d 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -1105,7 +1105,6 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
for (j = 0; j < len2; j++)
{
- const char *mangled_name;
gdb::unique_xmalloc_ptr<char> mangled_name_holder;
const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
int is_full_physname_constructor =
@@ -1151,14 +1150,8 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
gdb_puts (" ", stream);
}
- if (TYPE_FN_FIELD_STUB (f, j))
- {
- /* Build something we can demangle. */
- mangled_name_holder.reset (gdb_mangle_name (type, i, j));
- mangled_name = mangled_name_holder.get ();
- }
- else
- mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
+
+ const char *mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
gdb::unique_xmalloc_ptr<char> demangled_name
= gdb_demangle (mangled_name,
@@ -1170,22 +1163,15 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
arguments, the demangling will fail.
Let's try to reconstruct the function
signature from the symbol information. */
- if (!TYPE_FN_FIELD_STUB (f, j))
- {
- int staticp = TYPE_FN_FIELD_STATIC_P (f, j);
- struct type *mtype = TYPE_FN_FIELD_TYPE (f, j);
-
- cp_type_print_method_args (mtype,
- "",
- method_name,
- staticp,
- stream, language,
- &local_flags);
- }
- else
- fprintf_styled (stream, metadata_style.style (),
- _("<badly mangled name '%s'>"),
- mangled_name);
+ int staticp = TYPE_FN_FIELD_STATIC_P (f, j);
+ struct type *mtype = TYPE_FN_FIELD_TYPE (f, j);
+
+ cp_type_print_method_args (mtype,
+ "",
+ method_name,
+ staticp,
+ stream, language,
+ &local_flags);
}
else
{
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 848c5f6153a..f0729bece59 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -3145,171 +3145,6 @@ check_typedef (struct type *type)
return type;
}
-/* Parse a type expression in the string [P..P+LENGTH). If an error
- occurs, silently return a void type. */
-
-static struct type *
-safe_parse_type (struct gdbarch *gdbarch, const char *p, int length)
-{
- struct type *type = NULL; /* Initialize to keep gcc happy. */
-
- /* Suppress error messages. */
- scoped_restore saved_gdb_stderr = make_scoped_restore (&gdb_stderr,
- &null_stream);
-
- /* Call parse_and_eval_type() without fear of longjmp()s. */
- try
- {
- type = parse_and_eval_type (p, length);
- }
- catch (const gdb_exception_error &except)
- {
- type = builtin_type (gdbarch)->builtin_void;
- }
-
- return type;
-}
-
-/* Ugly hack to convert method stubs into method types.
-
- He ain't kiddin'. This demangles the name of the method into a
- string including argument types, parses out each argument type,
- generates a string casting a zero to that type, evaluates the
- string, and stuffs the resulting type into an argtype vector!!!
- Then it knows the type of the whole function (including argument
- types for overloading), which info used to be in the stab's but was
- removed to hack back the space required for them. */
-
-static void
-check_stub_method (struct type *type, int method_id, int signature_id)
-{
- struct gdbarch *gdbarch = type->arch ();
- struct fn_field *f;
- char *mangled_name = gdb_mangle_name (type, method_id, signature_id);
- gdb::unique_xmalloc_ptr<char> demangled_name
- = gdb_demangle (mangled_name, DMGL_PARAMS | DMGL_ANSI);
- char *argtypetext, *p;
- int depth = 0, argcount = 1;
- struct field *argtypes;
- struct type *mtype;
-
- /* Make sure we got back a function string that we can use. */
- if (demangled_name)
- p = strchr (demangled_name.get (), '(');
- else
- p = NULL;
-
- if (demangled_name == NULL || p == NULL)
- error (_("Internal: Cannot demangle mangled name `%s'."),
- mangled_name);
-
- /* Now, read in the parameters that define this type. */
- p += 1;
- argtypetext = p;
- while (*p)
- {
- if (*p == '(' || *p == '<')
- {
- depth += 1;
- }
- else if (*p == ')' || *p == '>')
- {
- depth -= 1;
- }
- else if (*p == ',' && depth == 0)
- {
- argcount += 1;
- }
-
- p += 1;
- }
-
- /* If we read one argument and it was ``void'', don't count it. */
- if (startswith (argtypetext, "(void)"))
- argcount -= 1;
-
- /* We need one extra slot, for the THIS pointer. */
-
- argtypes = (struct field *)
- TYPE_ZALLOC (type, (argcount + 1) * sizeof (struct field));
- p = argtypetext;
-
- /* Add THIS pointer for non-static methods. */
- f = TYPE_FN_FIELDLIST1 (type, method_id);
- if (TYPE_FN_FIELD_STATIC_P (f, signature_id))
- argcount = 0;
- else
- {
- argtypes[0].set_type (lookup_pointer_type (type));
- argcount = 1;
- }
-
- if (*p != ')') /* () means no args, skip while. */
- {
- depth = 0;
- while (*p)
- {
- if (depth <= 0 && (*p == ',' || *p == ')'))
- {
- /* Avoid parsing of ellipsis, they will be handled below.
- Also avoid ``void'' as above. */
- if (strncmp (argtypetext, "...", p - argtypetext) != 0
- && strncmp (argtypetext, "void", p - argtypetext) != 0)
- {
- argtypes[argcount].set_type
- (safe_parse_type (gdbarch, argtypetext, p - argtypetext));
- argcount += 1;
- }
- argtypetext = p + 1;
- }
-
- if (*p == '(' || *p == '<')
- {
- depth += 1;
- }
- else if (*p == ')' || *p == '>')
- {
- depth -= 1;
- }
-
- p += 1;
- }
- }
-
- TYPE_FN_FIELD_PHYSNAME (f, signature_id) = mangled_name;
-
- /* Now update the old "stub" type into a real type. */
- mtype = TYPE_FN_FIELD_TYPE (f, signature_id);
- /* MTYPE may currently be a function (TYPE_CODE_FUNC).
- We want a method (TYPE_CODE_METHOD). */
- smash_to_method_type (mtype, type, mtype->target_type (),
- gdb::make_array_view (argtypes, argcount),
- p[-2] == '.');
- mtype->set_is_stub (false);
- TYPE_FN_FIELD_STUB (f, signature_id) = 0;
-}
-
-/* This is the external interface to check_stub_method, above. This
- function unstubs all of the signatures for TYPE's METHOD_ID method
- name. After calling this function TYPE_FN_FIELD_STUB will be
- cleared for each signature and TYPE_FN_FIELDLIST_NAME will be
- correct.
-
- This function unfortunately can not die until stabs do. */
-
-void
-check_stub_method_group (struct type *type, int method_id)
-{
- int len = TYPE_FN_FIELDLIST_LENGTH (type, method_id);
- struct fn_field *f = TYPE_FN_FIELDLIST1 (type, method_id);
-
- for (int j = 0; j < len; j++)
- {
- if (TYPE_FN_FIELD_STUB (f, j))
- check_stub_method (type, method_id, j);
- }
-}
-
/* Ensure it is in .rodata (if available) by working around GCC PR 44690. */
const struct cplus_struct_type cplus_struct_default = { };
@@ -4992,8 +4827,6 @@ dump_fn_fieldlists (struct type *type, int spaces)
TYPE_FN_FIELD_PRIVATE (f, overload_idx));
gdb_printf ("%*sis_protected %d\n", spaces + 8, "",
TYPE_FN_FIELD_PROTECTED (f, overload_idx));
- gdb_printf ("%*sis_stub %d\n", spaces + 8, "",
- TYPE_FN_FIELD_STUB (f, overload_idx));
gdb_printf ("%*sdefaulted %d\n", spaces + 8, "",
TYPE_FN_FIELD_DEFAULTED (f, overload_idx));
gdb_printf ("%*sis_deleted %d\n", spaces + 8, "",
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 8ba314eb663..2d1f9937b4e 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1624,15 +1624,9 @@ struct fn_fieldlist
struct fn_field
{
- /* * If is_stub is clear, this is the mangled name which we can look
- up to find the address of the method (FIXME: it would be cleaner
- to have a pointer to the struct symbol here instead).
-
- If is_stub is set, this is the portion of the mangled name which
- specifies the arguments. For example, "ii", if there are two int
- arguments, or "" if there are no arguments. See gdb_mangle_name
- for the conversion from this format to the one used if is_stub is
- clear. */
+ /* * This is the mangled name which we can look up to find the
+ address of the method (FIXME: it would be cleaner to have a
+ pointer to the struct symbol here instead). */
const char *physname;
@@ -1655,11 +1649,6 @@ struct fn_field
unsigned int is_volatile:1;
unsigned int is_artificial:1;
- /* * A stub method only has some fields valid (but they are enough
- to reconstruct the rest of the fields). */
-
- unsigned int is_stub:1;
-
/* * True if this function is a constructor, false otherwise. */
unsigned int is_constructor : 1;
@@ -2005,7 +1994,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
#define TYPE_FN_FIELD_PROTECTED(thisfn, n) \
((thisfn)[n].accessibility == accessibility::PROTECTED)
#define TYPE_FN_FIELD_ARTIFICIAL(thisfn, n) ((thisfn)[n].is_artificial)
-#define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub)
#define TYPE_FN_FIELD_CONSTRUCTOR(thisfn, n) ((thisfn)[n].is_constructor)
#define TYPE_FN_FIELD_FCONTEXT(thisfn, n) ((thisfn)[n].fcontext)
#define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2)
@@ -2693,8 +2681,6 @@ extern void apply_bit_offset_to_field (struct field &field,
extern struct type *check_typedef (struct type *);
-extern void check_stub_method_group (struct type *, int);
-
extern char *gdb_mangle_name (struct type *, int, int);
/* Lookup a typedef or primitive type named NAME, visible in lexical block
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 3d519eaa971..1ea9d29c0b9 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -544,7 +544,6 @@ gnuv3_find_method_in (struct type *domain, CORE_ADDR voffset,
f = TYPE_FN_FIELDLIST1 (domain, i);
len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i);
- check_stub_method_group (domain, i);
for (j = 0; j < len2; j++)
if (TYPE_FN_FIELD_VOFFSET (f, j) == voffset)
return TYPE_FN_FIELD_PHYSNAME (f, j);
diff --git a/gdb/linespec.c b/gdb/linespec.c
index edd5f917f3a..4376a769e49 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1252,8 +1252,6 @@ find_methods (struct type *t, enum language t_lang, const char *name,
const char *phys_name;
f = TYPE_FN_FIELDLIST1 (t, method_counter);
- if (TYPE_FN_FIELD_STUB (f, field_counter))
- continue;
phys_name = TYPE_FN_FIELD_PHYSNAME (f, field_counter);
result_names->push_back (phys_name);
}
diff --git a/gdb/valops.c b/gdb/valops.c
index 568f8f84a9e..c89e5c4adc8 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -2209,7 +2209,6 @@ search_struct_method (const char *name, struct value **arg1p,
struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
name_matched = 1;
- check_stub_method_group (type, i);
if (j > 0 && !args.has_value ())
error (_("cannot resolve overloaded method "
"`%s': no arguments supplied"), name);
@@ -2510,9 +2509,6 @@ find_method_list (struct value **argp, const char *method,
*basetype = type;
*boffset = offset;
- /* Resolve any stub methods. */
- check_stub_method_group (type, i);
-
break;
}
}
@@ -3649,8 +3645,6 @@ value_struct_elt_for_reference (struct type *domain, int offset,
int len = TYPE_FN_FIELDLIST_LENGTH (t, i);
struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i);
- check_stub_method_group (t, i);
-
if (intype)
{
for (j = 0; j < len; ++j)
--
2.49.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] Remove TYPE_FN_FIELD_STUB
2026-02-09 2:55 [PATCH] Remove TYPE_FN_FIELD_STUB Tom Tromey
@ 2026-02-09 4:22 ` Simon Marchi
0 siblings, 0 replies; 2+ messages in thread
From: Simon Marchi @ 2026-02-09 4:22 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 2026-02-08 21:55, Tom Tromey wrote:
> Nothing sets TYPE_FN_FIELD_STUB any more -- I suspect it was a stabs
> thing, but didn't look.
>
> This patch removes this macro and supporting code.
>
> Regression tested on x86-64 Fedora 40.
I checked out various commits back to like 2003 and couldn't find a
spot using TYPE_FN_FIELD_STUB as a setter. So unless the is_stub field
is set differently... no idea when that was used.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Simon
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-09 4:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-09 2:55 [PATCH] Remove TYPE_FN_FIELD_STUB Tom Tromey
2026-02-09 4:22 ` Simon Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox