mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-22 17:57:45 +08:00
libctf, types: enhance ctf_type_aname to print function arg types
Somehow this never got implemented, which makes debugging any kind of bug that has to do with argument types fantastically confusing, because it *looks* like the func type takes no arguments though in fact it does. This also lets us simplify the dumper slightly (and introduces our first uses of ctf_assert and ctf_err_warn: there will be many more). ctf_type_aname dumps function types without including the function pointer name itself: ctf_dump search-and-replaces it in. This seems to give the nicest-looking results for existing users of both, even if it is a bit fiddly. libctf/ * ctf-types.c (ctf_type_aname): Print arg types here... * ctf-dump.c (ctf_dump_funcs): ... not here: but do substitute in the type name here.
This commit is contained in:
@ -745,7 +745,51 @@ ctf_type_aname (ctf_file_t *fp, ctf_id_t type)
|
||||
ctf_decl_sprintf (&cd, "[%u]", cdp->cd_n);
|
||||
break;
|
||||
case CTF_K_FUNCTION:
|
||||
ctf_decl_sprintf (&cd, "()");
|
||||
{
|
||||
size_t i;
|
||||
ctf_funcinfo_t fi;
|
||||
ctf_id_t *argv = NULL;
|
||||
|
||||
if (ctf_func_type_info (rfp, cdp->cd_type, &fi) < 0)
|
||||
goto err; /* errno is set for us. */
|
||||
|
||||
if ((argv = calloc (fi.ctc_argc, sizeof (ctf_id_t *))) == NULL)
|
||||
{
|
||||
ctf_set_errno (rfp, errno);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (ctf_func_type_args (rfp, cdp->cd_type,
|
||||
fi.ctc_argc, argv) < 0)
|
||||
goto err; /* errno is set for us. */
|
||||
|
||||
ctf_decl_sprintf (&cd, "(*) (");
|
||||
for (i = 0; i < fi.ctc_argc; i++)
|
||||
{
|
||||
char *arg = ctf_type_aname (rfp, argv[i]);
|
||||
|
||||
if (arg == NULL)
|
||||
goto err; /* errno is set for us. */
|
||||
ctf_decl_sprintf (&cd, "%s", arg);
|
||||
free (arg);
|
||||
|
||||
if ((i < fi.ctc_argc - 1)
|
||||
|| (fi.ctc_flags & CTF_FUNC_VARARG))
|
||||
ctf_decl_sprintf (&cd, ", ");
|
||||
}
|
||||
|
||||
if (fi.ctc_flags & CTF_FUNC_VARARG)
|
||||
ctf_decl_sprintf (&cd, "...");
|
||||
ctf_decl_sprintf (&cd, ")");
|
||||
|
||||
free (argv);
|
||||
break;
|
||||
|
||||
err:
|
||||
free (argv);
|
||||
ctf_decl_fini (&cd);
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
case CTF_K_STRUCT:
|
||||
case CTF_K_FORWARD:
|
||||
|
Reference in New Issue
Block a user