Debian Codegraph @

testsuite/semok/mangled.stp

raw
1 #! stap -p2
2 #
3 # PR11880, allow probing by mangled name, especially useful for advanced users
4 # to distinguish overloaded function names in C++.
5 #
6 # For example, stap itself has:
7 # std::vector<Dwarf_Die> dwflpp::getscopes(Dwarf_Die* die)
8 # std::vector<Dwarf_Die> dwflpp::getscopes(Dwarf_Addr pc)
9 #
10 # We can probe both as process("stap").function("dwflpp::getscopes"), but we
11 # didn't have a way to select just one, except by matching line numbers. If
12 # you want both but with different handlers, then @defined would work, but
13 # that's still all-or-nothing.
14 #
15 # Now we can use the mangled name instead, and probe them individually as we
16 # please. The test here checks that the right $vars are available in the
17 # separate probes.
18
19 probe process("stap").function("_ZN6dwflpp9getscopesE[my]")
20 {
21 if (@defined($pc) && !@defined($die))
22 println("pc=", $pc$)
23 else
24 println($assert_nosuchvar)
25 }
26
27 probe process("stap").function("_ZN6dwflpp9getscopesEP9Dwarf_Die")
28 {
29 if (@defined($die) && !@defined($pc))
30 println("die=", $die$)
31 else
32 println($assert_nosuchvar)
33 }
34
35 probe process("stap").function("_ZN6dwflpp9getscopesE*")
36 {
37 if (@defined($pc) ^ @defined($die))
38 println("XOR ok")
39 else
40 println($assert_nosuchvar)
41 }