]> sourceware.org Git - systemtap.git/commitdiff
Extract addr_of for unprivileged_[my]probes.exp once and with optional dot.
authorMark Wielaard <mjw@redhat.com>
Fri, 21 Oct 2011 14:49:02 +0000 (16:49 +0200)
committerMark Wielaard <mjw@redhat.com>
Fri, 21 Oct 2011 14:54:08 +0000 (16:54 +0200)
Some architectures prefix function symbols with a '.', so accept an
optional dot prefix. Also extract each symbol only once instead of
for each pass over the list.

testsuite/systemtap.unprivileged/unprivileged_myproc.exp
testsuite/systemtap.unprivileged/unprivileged_probes.exp

index 19a9898930b2ff9bc1a5322d5537d8b80c2d05e3..f158aab40a1ba1bff135997d881c80ff4042da05 100644 (file)
@@ -79,6 +79,7 @@ set valid_probe_types [list \
 # Add arguments to a probe type template.
 proc add_args { probe_type pid } {
     global exepath sopath
+    global addr_of_bar addr_of_libloopfunc
 
     set probe "$probe_type"
 
@@ -104,13 +105,11 @@ proc add_args { probe_type pid } {
     # Replace "library(string).function(string)" with "library(string.function("libloopfunc")"
     regsub -all "library\\(string\\).function\\(string\\)" $probe "library(string).function(\"libloopfunc\")" probe
     # Replace "library(string).function(number)" with "library(string).function($addr_of_libloopfunc)"
-    set addr_of_libloopfunc [exec objdump -d $sopath | awk {/<libloopfunc>/ { printf "0x%s\n",$1 }}]
     regsub -all "library\\(string\\).function\\(number\\)" $probe "library(string).function($addr_of_libloopfunc)" probe
 
     # Replace "function(string)" with "function("bar")"
     regsub -all "function\\(string\\)" $probe "function(\"bar\")" probe
     # Replace "function(number)" with "function($addr_of_bar)"
-    set addr_of_bar [exec objdump -d $exepath | awk {/<bar>/ { printf "0x%s\n",$1 }}]
     regsub -all "function\\(number\\)" $probe "function($addr_of_bar)" probe
 
     # Replace "label(string)" with "label("a")"
@@ -124,13 +123,11 @@ proc add_args { probe_type pid } {
     regsub -all "mark\\(string\\)" $probe "mark(\"main_enter\")" probe
 
     # Replace "library(string).statement(number)" with "library(string).statement($addr_of_libloopfunc)"
-    set addr_of_libloopfunc [exec objdump -d $sopath | awk {/<libloopfunc>/ { printf "0x%s\n",$1 }}]
     regsub -all "library\\(string\\).statement\\(number\\)" $probe "library(string).statement($addr_of_libloopfunc)" probe
     # Replace "library(string).statement(string)" with "library(string).statement("libloopfunc@libloop.c:*")"
     regsub -all "library\\(string\\).statement\\(string\\)" $probe "library(string).statement(\"libloopfunc@libloop.c:*\")" probe
 
     # Replace "statement(number)" with "statement($addr_of_bar)"
-    set addr_of_bar [exec objdump -d $exepath | awk {/<bar>/ { printf "0x%s\n",$1 }}]
     regsub -all "statement\\(number\\)" $probe "statement($addr_of_bar)" probe
     # Replace "statement(string)" with "statement("bar@loop.c:*")"
     regsub -all "statement\\(string\\)" $probe "statement(\"bar@loop.c:*\")" probe
@@ -294,6 +291,13 @@ if { $res == "" } {
     return
 }
 
+# Extract needed addresses. Note, some architectures add a '.' to the
+# function name, so match that optionally.
+set addr_of_bar [exec objdump -d $exepath | awk {/<\.?bar>/ { printf "0x%s\n",$1 }}]
+verbose -log "addr_of_bar: $addr_of_bar"
+set addr_of_libloopfunc [exec objdump -d $sopath | awk {/<\.?libloopfunc>/ { printf "0x%s\n",$1 }}]
+verbose -log "addr_of_libloopfunc: $addr_of_libloopfunc"
+
 # Obtain a list of all process* probe types from stap
 verbose -log "eval exec stap --dump-probe-types | grep ^process"
 catch {eval exec stap --dump-probe-types | grep ^process} res_stap
index 8100f05daa05a71c7025e00b13845aa89d448370..5d3640d97bd73dfc8d46149855f68753269d80fa 100644 (file)
@@ -171,6 +171,7 @@ set invalid_probe_types [list \
 # Add arguments to a probe type template.
 proc add_args { probe_type } {
     global exepath sopath
+    global addr_of_bar addr_of_libfoofunc
 
     set probe "$probe_type"
 
@@ -194,13 +195,11 @@ proc add_args { probe_type } {
     # Replace "library(string).function(string)" with "library(string.function("libfoofunc")"
     regsub -all "library\\(string\\).function\\(string\\)" $probe "library(string).function(\"libfoofunc\")" probe
     # Replace "library(string).function(number)" with "library(string).function($addr_of_libfoofunc)"
-    set addr_of_libfoofunc [exec objdump -d $sopath | awk {/<libfoofunc>/ { printf "0x%s\n",$1 }}]
     regsub -all "library\\(string\\).function\\(number\\)" $probe "library(string).function($addr_of_libfoofunc)" probe
 
     # Replace "function(string)" with "function("bar")"
     regsub -all "function\\(string\\)" $probe "function(\"bar\")" probe
     # Replace "function(number)" with "function($addr_of_bar)"
-    set addr_of_bar [exec objdump -d $exepath | awk {/<bar>/ { printf "0x%s\n",$1 }}]
     regsub -all "function\\(number\\)" $probe "function($addr_of_bar)" probe
 
     # Replace "label(string)" with "label("a")"
@@ -214,13 +213,11 @@ proc add_args { probe_type } {
     regsub -all "mark\\(string\\)" $probe "mark(\"main_enter\")" probe
 
     # Replace "library(string).statement(number)" with "library(string).statement($addr_of_libfoofunc)"
-    set addr_of_libfoofunc [exec objdump -d $sopath | awk {/<libfoofunc>/ { printf "0x%s\n",$1 }}]
     regsub -all "library\\(string\\).statement\\(number\\)" $probe "library(string).statement($addr_of_libfoofunc)" probe
     # Replace "library(string).statement(string)" with "library(string).statement("libfoofunc@libfoo.c:*")"
     regsub -all "library\\(string\\).statement\\(string\\)" $probe "library(string).statement(\"libfoofunc@libfoo.c:*\")" probe
 
     # Replace "statement(number)" with "statement($addr_of_bar)"
-    set addr_of_bar [exec objdump -d $exepath | awk {/<bar>/ { printf "0x%s\n",$1 }}]
     regsub -all "statement\\(number\\)" $probe "statement($addr_of_bar)" probe
     # Replace "statement(string)" with "statement("bar@foo.c:*")"
     regsub -all "statement\\(string\\)" $probe "statement(\"bar@foo.c:*\")" probe
@@ -368,6 +365,13 @@ if { $res == "" } {
     return
 }
 
+# Extract needed addresses. Note, some architectures add a '.' to the
+# function name, so match that optionally.
+set addr_of_bar [exec objdump -d $exepath | awk {/<\.?bar>/ { printf "0x%s\n",$1 }}]
+verbose -log "addr_of_bar: $addr_of_bar"
+set addr_of_libfoofunc [exec objdump -d $sopath | awk {/<\.?libfoofunc>/ { printf "0x%s\n",$1 }}]
+verbose -log "addr_of_libfoofunc: $addr_of_libfoofunc"
+
 # Obtain a list of all supported probe types from stap
 verbose -log "eval exec stap --dump-probe-types"
 catch {eval exec stap --dump-probe-types} res_stap
This page took 0.032155 seconds and 5 git commands to generate.