Bug 20042 - on rawhide, tracepoint handlers have a changed function signature
Summary: on rawhide, tracepoint handlers have a changed function signature
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: runtime (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Josh Stone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-03 16:29 UTC by David Smith
Modified: 2016-05-06 23:56 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Smith 2016-05-03 16:29:05 UTC
On rawhide (4.6.0-0.rc5.git3.1.fc25.x86_64), it looks like the tracepoint interface has changed, causing compilation errors with scripts that use tracepoints:

====
# stap -v ../src/testsuite/systemtap.base/tracepoints.stp 
Pass 1: parsed user script and 113 library scripts using 241388virt/38096res/7572shr/30784data kb, in 200usr/40sys/232real ms.
Pass 2: analyzed script: 1925 probes, 1 function, 0 embeds, 1 global using 260332virt/57992res/8624shr/49728data kb, in 82200usr/19540sys/53882real ms.
Pass 3: translated to C into "/tmp/staphWDwgS/stap_3b2a8c89bb4805ee669dd1b436014d8c_1186740_src.c" using 261868virt/59564res/8688shr/51264data kb, in 550usr/70sys/616real ms.
In file included from /tmp/staphWDwgS/stap_3b2a8c89bb4805ee669dd1b436014d8c_1186740_aux_30.c:8:0:
/tmp/staphWDwgS/stap_3b2a8c89bb4805ee669dd1b436014d8c_1186740_aux_30.c: In function ‘register_tracepoint_probe_1212’:
/tmp/staphWDwgS/stap_3b2a8c89bb4805ee669dd1b436014d8c_1186740_aux_30.c:27:42: error: passing argument 1 of ‘check_trace_callback_type_cpuhp_enter’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   return STP_TRACE_REGISTER(cpuhp_enter, enter_tracepoint_probe_1212);
                                          ^
/usr/local/share/systemtap/runtime/linux/stp_tracepoint.h:45:38: note: in definition of macro ‘STP_TRACE_REGISTER’
     check_trace_callback_type_##name(fn);   \
                                      ^~
In file included from ./arch/x86/include/asm/kvm_host.h:17:0,
                 from include/linux/kvm_host.h:36,
                 from /tmp/staphWDwgS/stap_3b2a8c89bb4805ee669dd1b436014d8c_1186740_aux_30.c:4:
include/linux/tracepoint.h:218:2: note: expected ‘void (*)(void *, unsigned int,  int,  int,  int (*)(unsigned int))’ but argument is of type ‘void (*)(void *, unsigned int,  int,  int,  void *)’
  check_trace_callback_type_##name(void (*cb)(data_proto)) \
  ^
include/linux/tracepoint.h:348:2: note: in expansion of macro ‘__DECLARE_TRACE’
  __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
  ^~~~~~~~~~~~~~~
include/linux/tracepoint.h:484:2: note: in expansion of macro ‘DECLARE_TRACE’
  DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
  ^~~~~~~~~~~~~
include/trace/events/cpuhp.h:9:1: note: in expansion of macro ‘TRACE_EVENT’
 TRACE_EVENT(cpuhp_enter,
 ^~~~~~~~~~~
In file included from /tmp/staphWDwgS/stap_3b2a8c89bb4805ee669dd1b436014d8c_1186740_aux_30.c:8:0:
/tmp/staphWDwgS/stap_3b2a8c89bb4805ee669dd1b436014d8c_1186740_aux_30.c: In function ‘unregister_tracepoint_probe_1212’:
/tmp/staphWDwgS/stap_3b2a8c89bb4805ee669dd1b436014d8c_1186740_aux_30.c:30:44: error: passing argument 1 of ‘check_trace_callback_type_cpuhp_enter’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   (void) STP_TRACE_UNREGISTER(cpuhp_enter, enter_tracepoint_probe_1212);
                                            ^
/usr/local/share/systemtap/runtime/linux/stp_tracepoint.h:49:38: note: in definition of macro ‘STP_TRACE_UNREGISTER’
     check_trace_callback_type_##name(fn);   \
                                      ^~
In file included from ./arch/x86/include/asm/kvm_host.h:17:0,
                 from include/linux/kvm_host.h:36,
                 from /tmp/staphWDwgS/stap_3b2a8c89bb4805ee669dd1b436014d8c_1186740_aux_30.c:4:
include/linux/tracepoint.h:218:2: note: expected ‘void (*)(void *, unsigned int,  int,  int,  int (*)(unsigned int))’ but argument is of type ‘void (*)(void *, unsigned int,  int,  int,  void *)’
  check_trace_callback_type_##name(void (*cb)(data_proto)) \
  ^
include/linux/tracepoint.h:348:2: note: in expansion of macro ‘__DECLARE_TRACE’
  __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),  \
  ^~~~~~~~~~~~~~~
include/linux/tracepoint.h:484:2: note: in expansion of macro ‘DECLARE_TRACE’
  DECLARE_TRACE(name, PARAMS(proto), PARAMS(args))
  ^~~~~~~~~~~~~
include/trace/events/cpuhp.h:9:1: note: in expansion of macro ‘TRACE_EVENT’
 TRACE_EVENT(cpuhp_enter,
 ^~~~~~~~~~~
cc1: all warnings being treated as errors
scripts/Makefile.build:291: recipe for target '/tmp/staphWDwgS/stap_3b2a8c89bb4805ee669dd1b436014d8c_1186740_aux_30.o' failed
make[1]: *** [/tmp/staphWDwgS/stap_3b2a8c89bb4805ee669dd1b436014d8c_1186740_aux_30.o] Error 1
make[1]: *** Waiting for unfinished jobs....
Makefile:1432: recipe for target '_module_/tmp/staphWDwgS' failed
make: *** [_module_/tmp/staphWDwgS] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compiled C into "stap_3b2a8c89bb4805ee669dd1b436014d8c_1186740.ko" in 47480usr/10000sys/38954real ms.
Pass 4: compilation failed.  [man error::pass4]
====
Comment 1 David Smith 2016-05-03 16:59:39 UTC
It appears that this isn't a problem with all tracepoints, just certain ones. The common problem might be that the tracepoints has a function pointer argument.

In the case of the 'cpuhp_enter' tracepoint, here's what include/trace/events/cpuhp.h has:

====
...
TRACE_EVENT(cpuhp_enter,

	TP_PROTO(unsigned int cpu,
		 int target,
		 int idx,
		 int (*fun)(unsigned int)),

	TP_ARGS(cpu, target, idx, fun),

	TP_STRUCT__entry(
		__field( unsigned int,	cpu		)
		__field( int,		target		)
		__field( int,		idx		)
		__field( void *,	fun		)
	),
...
====

The odd thing is here that in TP_PROTO, the function pointer is declared differently from the same function pointer in TP_STRUCT__entry. Systemtap is declaring the handler as:

====
static STP_TRACE_ENTER(enter_tracepoint_probe_104
, unsigned int __tracepoint_arg_cpu
, int __tracepoint_arg_target
, int __tracepoint_arg_idx
, void* __tracepoint_arg_fun
)
====

which matches the TP_STRUCT__entry definition, but we might need to switch to be more like the TP_PROTO definition.
Comment 2 Josh Stone 2016-05-03 18:08:07 UTC
I found that dwarf_wrappers.cxx dwarf_type_name doesn't handle DW_TAG_subroutine_type, and it treats unknowns as "void", so the function pointer type becomes "void*".  That can be improved, but we'll also need to be a bit more clever about the declaration since function pointer names are in the middle of the type.  We can probably just write a typedef for each argument to use in STP_TRACE_ENTER.
Comment 3 Josh Stone 2016-05-06 23:56:36 UTC
Function-pointer args are now handled, as of
commit b6e49c9798d074653ca9220639aef6d8d6a45327