This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: visit_target_symbol() for derived_probes
I have tried to replicate what the dwarf and mark probes do as far as
handling target variable ($variable) for $counter in the perfmon probes.
The perfmon probe needs a read only value indicating which counter is
being used for that event. From what I understand discussing this with
Frank and examining the code here are the things that need to be done:
-allocate space for the variable
-generate a declaration for the synthesized function
-generate C code for the synthesized function
-replace the $target var use with a call to the synthesized function
It appears that I am not getting the function built in the latest patch
that is saved in bz#909. Where exactly does the creation of the
synthesized function occur for the dwarf and mark probes? I seem to be
missing the corresponding operation. Later the code gets a seg fault in
symresolution_info::visit_symbol(). Thus, for the this short example:
global handle
global cycles_start, cycles_end
probe perfmon.counter("CPU_CLK_UNHALTED") {handle=$counter}
probe begin { cycles_start = read_counter(handle) }
probe end
{
cycles_end = read_counter(handle);
elapsed = cycles_start - cycles_end;
printf("%d cycles\n", elapsed);
}
The following happens:
(gdb) run -p4 -k ../elapsed.stp
Starting program:
/home/wcohen/research/profiling/systemtap_perfmon/install/bin/stap -p4
-k ../elapsed.stp
while searching for arity 0 function:
semantic error: unresolved function call: identifier '$counter' at
../elapsed.stp:4:51
Program received signal SIGSEGV, Segmentation fault.
0x000000000042e60f in symresolution_info::visit_symbol (this=0x7fffd7223960,
e=0xb34790)
at
/usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/ext/mt_allocator.h:585
585 { ::new(__p) _Tp(__val); }
(gdb) where
#0 0x000000000042e60f in symresolution_info::visit_symbol (
this=0x7fffd7223960, e=0xb34790)
at
/usr/lib/gcc/x86_64-redhat-linux/4.0.2/../../../../include/c++/4.0.2/ext/mt_allocator.h:585
#1 0x000000000041d221 in traversing_visitor::visit_assignment (
this=0x7fffd7223960, e=0xb34510) at ../src/staptree.cxx:1434
#2 0x000000000041f5af in assignment::visit (this=0xb34510,
u=0x7fffd7223960)
at ../src/staptree.cxx:1070
#3 0x00000000004292dd in symresolution_info::visit_block (
this=0x7fffd7223960, e=0xb34370) at ../src/elaborate.cxx:973
#4 0x000000000042d8e4 in semantic_pass_symbols (s=@0x7fffd7223d50)
at ../src/elaborate.cxx:891
#5 0x00000000004307e1 in semantic_pass (s=@0x7fffd7223d50)
at ../src/elaborate.cxx:916
#6 0x000000000040830e in main (argc=Variable "argc" is not available.
) at ../src/main.cxx:468
-Will