pfunct: Emit definitions for pointers inside pointer to function args
When using --compile we were missing emitting the types for function
arguments in function pointers arguments, i.e.:
Before:
/home/acme/git/build/v5.1-rc4+/kernel/events/core.o
/tmp/fullcircle.CZeLch.c:3770:141: warning: ‘struct perf_output_handle’ declared inside parameter list will not be visible outside of this definition or declaration
inline int __perf_event_output(struct perf_event * event, struct perf_sample_data * data, struct pt_regs * regs, int (*output_begin)(struct perf_output_handle *, struct perf_event *, unsigned int))
^~~~~~~~~~~~~~~~~~
After:
$ pfunct --compile /home/acme/git/build/v5.1-rc4+/kernel/events/core.o > a.c
$ gcc -g -c a.c
$ grep -w perf_output_handle -m1 -A5 a.c
struct perf_output_handle;
inline int __perf_event_output(struct perf_event * event, struct perf_sample_data * data, struct pt_regs * regs, int (*output_begin)(struct perf_output_handle *, struct perf_event *, unsigned int))
{
return 0;
}
$
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
diff --git a/pfunct.c b/pfunct.c
index f57fa53..03a1f56 100644
--- a/pfunct.c
+++ b/pfunct.c
@@ -351,7 +351,9 @@
goto try_again;
}
- if (tag__is_type(type) && !tag__type(type)->definition_emitted) {
+ if (type->tag == DW_TAG_subroutine_type) {
+ ftype__emit_definitions(tag__ftype(type), cu, &emissions, fp);
+ } else if (tag__is_type(type) && !tag__type(type)->definition_emitted) {
type__emit_definitions(type, cu, &emissions, fp);
if (!tag__is_typedef(type))
type__emit(type, cu, NULL, NULL, fp);