pfunct: Ask for generating compilable output that generates DWARF for types

I.e. --compile is similar to --expand_types but also makes sure the
function have empty function bodies, which ends up making at least gcc
to generate the DWARF info for the types referenced by the function
arguments and return types.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2019-04-04 16:03:33 -03:00
parent e7a786540d
commit 3ce2c52166
1 changed files with 19 additions and 0 deletions

View File

@ -30,6 +30,7 @@ static int show_cc_uninlined;
static char *symtab_name;
static bool show_prototypes;
static bool expand_types;
static bool compilable_output;
static struct type_emissions emissions;
static uint64_t addr;
@ -355,6 +356,8 @@ static void function__show(struct function *func, struct cu *cu)
if (expand_types)
function__emit_type_definitions(func, cu, stdout);
tag__fprintf(tag, cu, &conf, stdout);
if (compilable_output)
fprintf(stdout, "\n{\n}\n");
putchar('\n');
if (show_variables || show_inline_expansions)
function__fprintf_stats(tag, cu, &conf, stdout);
@ -461,6 +464,7 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version;
#define ARGP_symtab 300
#define ARGP_no_parm_names 301
#define ARGP_compile 302
static const struct argp_option pfunct__options[] = {
{
@ -574,6 +578,13 @@ static const struct argp_option pfunct__options[] = {
.flags = OPTION_ARG_OPTIONAL,
.doc = "show symbol table NAME (Default .symtab)",
},
{
.name = "compile",
.key = ARGP_compile,
.arg = "FUNCTION",
.flags = OPTION_ARG_OPTIONAL,
.doc = "Generate compilable source code with types expanded (Default all functions)",
},
{
.name = "no_parm_names",
.key = ARGP_no_parm_names,
@ -629,6 +640,14 @@ static error_t pfunct__options_parser(int key, char *arg,
conf_load.get_addr_info = true; break;
case ARGP_symtab: symtab_name = arg ?: ".symtab"; break;
case ARGP_no_parm_names: conf.no_parm_names = 1; break;
case ARGP_compile:
expand_types = true;
type_emissions__init(&emissions);
compilable_output = true;
conf.no_semicolon = true;
if (arg)
function_name = arg;
break;
default: return ARGP_ERR_UNKNOWN;
}