diff options
author | David Smith <dsmith@redhat.com> | 2009-04-08 12:42:39 -0500 |
---|---|---|
committer | David Smith <dsmith@redhat.com> | 2009-04-08 12:42:39 -0500 |
commit | f149549158a3d6dcb1118323d1dbcec27c4b3bbe (patch) | |
tree | 026809a32737d2abf37808b0983de0a09315b2c2 | |
parent | 55c0f2bfefb04915622dd3688bba59da1addaec8 (diff) | |
parent | 909478bf88251987368339b1102f56fbd2d11ebd (diff) | |
download | systemtap-steved-f149549158a3d6dcb1118323d1dbcec27c4b3bbe.tar.gz systemtap-steved-f149549158a3d6dcb1118323d1dbcec27c4b3bbe.tar.xz systemtap-steved-f149549158a3d6dcb1118323d1dbcec27c4b3bbe.zip |
Merge branch 'master' of ssh://sources.redhat.com/git/systemtap
-rwxr-xr-x | doc/Tapset_Reference_Guide/publicanize.sh | 107 | ||||
-rw-r--r-- | runtime/sym.c | 4 | ||||
-rw-r--r-- | tapset/context.stp | 25 | ||||
-rw-r--r-- | tapsets.cxx | 2 | ||||
-rwxr-xr-x | testsuite/buildok/uaddr.stp | 8 | ||||
-rw-r--r-- | testsuite/systemtap.base/labels.exp | 15 | ||||
-rwxr-xr-x | testsuite/systemtap.examples/network/nettop.stp | 10 | ||||
-rw-r--r-- | translate.cxx | 7 |
8 files changed, 135 insertions, 43 deletions
diff --git a/doc/Tapset_Reference_Guide/publicanize.sh b/doc/Tapset_Reference_Guide/publicanize.sh index d4da6e02..0d1b134e 100755 --- a/doc/Tapset_Reference_Guide/publicanize.sh +++ b/doc/Tapset_Reference_Guide/publicanize.sh @@ -1,26 +1,74 @@ #!/bin/bash +INFILE="../SystemTap_Tapset_Reference/tapsets.xml" +OUTFILE="en-US/Tapset_Reference_Guide.xml" +TMPFILE='mktemp' || exit 1 +TMPFILE2='mktemp' || exit 1 -#copy the automated tapsets.xml -cp ../SystemTap_Tapset_Reference/tapsets.xml temp.xml ; +do_help() +{ + echo "publicanize.sh: usage: + -?/--help this message + -i/--input=file input file name + -o/--output=file output file name +" >&2 +} + + +#process optional arguments -i -o +while [ "$#" -ne 0 ] +do + arg=`printf %s $1 | awk -F= '{print $1}'` + val=`printf %s $1 | awk -F= '{print $2}'` + shift + if test -z "$val"; then + local possibleval=$1 + printf %s $1 "$possibleval" | grep ^- >/dev/null 2>&1 + if test "$?" != "0"; then + val=$possibleval + if [ "$#" -ge 1 ]; then + shift + fi + fi + fi + + case "$arg" in + -i|--input) + INFILE=$val + ;; + -o|--output) + OUTFILE=$val + ;; + -\?|--help) + do_help + exit 0 + ;; + *) + echo "Unknown option \"$arg\". See opcontrol --help" >&2 + exit 1 + ;; + esac +done + + +#copy the generated tapsets.xml +cp $INFILE $TMPFILE || exit 1 #remove all excess whitespace -sed -i -e 's/^\s*//g' temp.xml ; +sed -i -e 's/^\s*//g' $TMPFILE -#remove marked Intro (starthere to endhere), then copy it to en-US -sed '/starthere/,/endhere/d' temp.xml > Tapset_Reference_Guide.xml -cp Tapset_Reference_Guide.xml en-US/Tapset_Reference_Guide.xml; -rm Tapset_Reference_Guide.xml +#remove marked Intro (starthere to endhere) +sed -i -e '/starthere/,/endhere/d' $TMPFILE #re-convert programlisting tags -sed -i -e 's/<programlisting>/<programlisting>/g' en-US/Tapset_Reference_Guide.xml; -sed -i -e 's/<\/programlisting>/<\/programlisting>/g' en-US/Tapset_Reference_Guide.xml; +sed -i -e 's/<programlisting>/<programlisting>/g' $TMPFILE +sed -i -e 's/<\/programlisting>/<\/programlisting>/g' $TMPFILE #replace header -cat en-US/Tapset_Reference_Guide.xml | +cat $TMPFILE | perl -p -e 'undef $/;s|<bookinfo>\n<title>SystemTap Tapset Reference Manual</title>|<xi:include href="Book_Info.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />\n<xi:include href="Preface.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />|msg' | -perl -p -e 'undef $/;s|<authorgroup>\n<author>\n<firstname>William</firstname>\n<surname>Cohen</surname>\n<contrib></contrib>\n<affiliation>\n<address>\n<email>wcohen\@redhat.com</email>\n</address>\n</affiliation>\n</author>\n</authorgroup>||msg' | -perl -p -e 'undef $/;s|<copyright>\n<year>2008, 2009</year>\n<holder>Red Hat, Inc.</holder>\n</copyright>||msg' | +perl -p -e 'undef $/;s|<authorgroup>\n<author>\n<othername>SystemTap</othername>\n<contrib>Hackers</contrib>\n</author>\n</authorgroup>||msg' | +perl -p -e 'undef $/;s|<copyright>\n<year>2008-2009</year>\n<holder>Red Hat, Inc. and others</holder>\n</copyright>||msg' | perl -p -e 'undef $/;s|<legalnotice>\n<para>\nThis documentation is free software\; you can redistribute\nit and/or modify it under the terms of the GNU General Public\nLicense version 2 as published by the Free Software Foundation.\n</para>||msg' | perl -p -e 'undef $/;s|<para>\nThis program is distributed in the hope that it will be\nuseful, but WITHOUT ANY WARRANTY; without even the implied\nwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\n</para>||msg' | perl -p -e 'undef $/;s|<para>\nYou should have received a copy of the GNU General Public\nLicense along with this program; if not, write to the Free\nSoftware Foundation, Inc., 59 Temple Place, Suite 330, Boston,\nMA 02111-1307 USA\n</para>||msg' | @@ -32,34 +80,33 @@ perl -p -e 'undef $/;s|<programlisting>\n|<programlisting>\n<emphasis>function < perl -p -e 'undef $/;s|<para>\n</para>||msg' | perl -p -e 'undef $/;s|<para>\n\n</para>||msg' | perl -p -e 'undef $/;s|<para>\n<programlisting>|<programlisting>|msg' | -perl -p -e 'undef $/;s|</programlisting>\n</para>|</programlisting>|msg' > clean.xml +perl -p -e 'undef $/;s|</programlisting>\n</para>|</programlisting>|msg' > $TMPFILE2 #replace Intro with my own -perl -p -i -e 's|<!--markerforxi-->|<xi:include href="Introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />\n<xi:include href="Tapset_Dev_Guide.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />|g' clean.xml +perl -p -i -e 's|<!--markerforxi-->|<xi:include href="Introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />\n<xi:include href="Tapset_Dev_Guide.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />|g' $TMPFILE2 #for tapset name format section -#perl -p -i -e 'undef $/;s|<screen>\nname:return \(parameters\)\ndefinition\n</screen>|<screen>\n<replaceable>function/probe</replaceable> tapset_name:return \(parameters\)\n</screen>|msg' clean.xml -#perl -p -i -e 's|<para>In this guide, tapset definitions appear in the following format:</para>|<para>In this guide, the synopsis of each tapset appears in the following format:</para>|g' clean.xml -#perl -p -i -e 's|<!-- markerforxi pls dont remove -->|<xi:include href="tapsetnameformat-lastpara.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />\n<xi:include href="refentry-example.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />|g' clean.xml +#perl -p -i -e 'undef $/;s|<screen>\nname:return \(parameters\)\ndefinition\n</screen>|<screen>\n<replaceable>function/probe</replaceable> tapset_name:return \(parameters\)\n</screen>|msg' $TMPFILE2 +#perl -p -i -e 's|<para>In this guide, tapset definitions appear in the following format:</para>|<para>In this guide, the synopsis of each tapset appears in the following format:</para>|g' $TMPFILE2 +#perl -p -i -e 's|<!-- markerforxi pls dont remove -->|<xi:include href="tapsetnameformat-lastpara.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />\n<xi:include href="refentry-example.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />|g' $TMPFILE2 -cp clean.xml en-US/Tapset_Reference_Guide.xml -rm clean.xml - # statements change synopsis tags, as they are still currently unfixed in publican-redhat -sed -i -e 's/refsynopsisdiv>/refsect1>/g' en-US/Tapset_Reference_Guide.xml; -sed -i -e 's/refsect1>/refsection>/g' en-US/Tapset_Reference_Guide.xml; -sed -i -e 's/synopsis>/programlisting>\n/g' en-US/Tapset_Reference_Guide.xml; +sed -i -e 's/refsynopsisdiv>/refsect1>/g' $TMPFILE2 +sed -i -e 's/refsect1>/refsection>/g' $TMPFILE2 +sed -i -e 's/synopsis>/programlisting>\n/g' $TMPFILE2 # re-convert tags -sed -i -e 's/<emphasis>/<emphasis>/g' en-US/Tapset_Reference_Guide.xml; -sed -i -e 's/<\/emphasis>/<\/emphasis>/g' en-US/Tapset_Reference_Guide.xml; +sed -i -e 's/<emphasis>/<emphasis>/g' $TMPFILE2 +sed -i -e 's/<\/emphasis>/<\/emphasis>/g' $TMPFILE2 -sed -i -e 's/<remark>/<remark>/g' en-US/Tapset_Reference_Guide.xml; -sed -i -e 's/<\/remark>/<\/remark>/g' en-US/Tapset_Reference_Guide.xml; +sed -i -e 's/<remark>/<remark>/g' $TMPFILE2 +sed -i -e 's/<\/remark>/<\/remark>/g' $TMPFILE2 -sed -i -e 's/<command>/<command>/g' en-US/Tapset_Reference_Guide.xml; -sed -i -e 's/<\/command>/<\/command>/g' en-US/Tapset_Reference_Guide.xml; +sed -i -e 's/<command>/<command>/g' $TMPFILE2 +sed -i -e 's/<\/command>/<\/command>/g' $TMPFILE2 #useful marker script; moves content between starthere and endhere to file target -#sed -n '/starthere/,/endhere/ s/.*/&/w target' Tapset_Reference_Guide.xml
\ No newline at end of file +#sed -n '/starthere/,/endhere/ s/.*/&/w target' $TMPFILE2 + +mv $TMPFILE2 $OUTFILE diff --git a/runtime/sym.c b/runtime/sym.c index 0268f1ab..835e1b46 100644 --- a/runtime/sym.c +++ b/runtime/sym.c @@ -380,8 +380,8 @@ static void _stp_symbol_snprint(char *str, size_t len, unsigned long address, task); if (name) { if (add_mod && modname && *modname) - _stp_printf("%s %s+%#lx/%#lx\n", - name, modname, offset, size); + _stp_snprintf(str, len, "%s %s+%#lx/%#lx", + name, modname, offset, size); else strlcpy(str, name, len); } else diff --git a/tapset/context.stp b/tapset/context.stp index 9f4be0e6..36d68c8d 100644 --- a/tapset/context.stp +++ b/tapset/context.stp @@ -11,6 +11,11 @@ //provide information such as a backtrace to where the event occured and the current register values for the //processor. // </tapsetdescription> + +%{ +#include <asm/processor.h> +%} + /** * sfunction print_regs - Print a register dump. */ @@ -227,3 +232,23 @@ function stack_unused:long () %{ /* pure */ THIS->__retvalue = (long)&a & (THREAD_SIZE-1); %} +/** + * sfunction uaddr - User space address of current running task. + * + * Description: Returns the address in userspace that the current + * task was at when the probe occured. When the current running task + * isn't a user space thread, or the address cannot be found, zero + * is returned. + */ +function uaddr:long () %{ /* pure */ + int64_t addr = 0; + if (current->mm) + { + struct pt_regs *uregs; + uregs = task_pt_regs(current); + if (uregs) + addr = (int64_t) REG_IP(uregs); + } + THIS->__retvalue = addr; +%} + diff --git a/tapsets.cxx b/tapsets.cxx index a7bda5f5..694490d8 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -1369,7 +1369,7 @@ struct dwflpp function_name = name; } else if (tag == DW_TAG_label && name != 0 - && ((strncmp(name, sym, strlen(sym)) == 0) + && ((strcmp(name, sym) == 0) || (name_has_wildcard (sym) && function_name_matches_pattern (name, sym)))) { diff --git a/testsuite/buildok/uaddr.stp b/testsuite/buildok/uaddr.stp new file mode 100755 index 00000000..8acfc495 --- /dev/null +++ b/testsuite/buildok/uaddr.stp @@ -0,0 +1,8 @@ +#! stap -p4 +# +# Test the translatability for uaddr() +# +probe begin +{ + printf("uaddr: 0x%x\n", uaddr()) +} diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index 2f79a502..f389f08c 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -18,7 +18,7 @@ main () char *c; init_an_int: a = 2; -init_another_int: +init_an_int_again: b = 3; c = \"abc\"; ptr_inited: @@ -32,6 +32,7 @@ set fp [open $label_stppath "w"] puts $fp " probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_*\") {printf (\"VARS %s\\n\",\$\$vars)} probe process(\"labels.x\").function(\"main*@labels.c\").label(\"ptr_inited\") {printf (\"VARS %s\\n\",\$\$vars)} +probe process(\"labels.x\").function(\"main*@labels.c\").label(\"init_an_int\") {printf (\"init_an_int\\n\")} " close $fp @@ -55,12 +56,12 @@ spawn stap -c $label_exepath $label_stppath wait expect { -timeout 180 - -re {VARS a=0x0 b=0x0.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue } + -re {VARS a=0x0 b=0x0.*init_an_int.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue } timeout { fail "$test (timeout)" } eof { } } -if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label" } +if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label $ok" } # address of label in an executable @@ -68,7 +69,7 @@ set label_shpath "[pwd]/label.sh" set fp [open $label_shpath "w"] puts $fp " readelf --debug-dump $label_exepath | awk \" -/init_another_int/ {have_label=1} +/init_an_int_again/ {have_label=1} /DW_AT_low_pc/ {if (have_label) {print \$3;exit;}} \" " @@ -103,7 +104,7 @@ if { $res != "" } { # label in a shared object -spawn stap -p2 -l "process\(\"$label_sopath\"\).function\(\"\*\"\).label\(\"init_another_int\"\)" +spawn stap -p2 -l "process\(\"$label_sopath\"\).function\(\"\*\"\).label\(\"init_an_int_again\"\)" expect { -timeout 180 -re {process.*function} { incr ok; exp_continue } @@ -111,7 +112,7 @@ expect { eof { } } -if {$ok == 1} { pass "$test so .label" } { fail "$test so .label" } +if {$ok == 1} { pass "$test so .label" } { fail "$test so .label $ok" } # address of label in a shared object @@ -119,7 +120,7 @@ set label_shpath "[pwd]/label.sh" set fp [open $label_shpath "w"] puts $fp " readelf --debug-dump $label_sopath | awk \" -/init_another_int/ {have_label=1} +/init_an_int_again/ {have_label=1} /DW_AT_low_pc/ {if (have_label) {print \$3;exit;}} \" " diff --git a/testsuite/systemtap.examples/network/nettop.stp b/testsuite/systemtap.examples/network/nettop.stp index 15b4d62a..e96548f1 100755 --- a/testsuite/systemtap.examples/network/nettop.stp +++ b/testsuite/systemtap.examples/network/nettop.stp @@ -1,6 +1,7 @@ #! /usr/bin/env stap global ifxmit, ifrecv +global ifmerged probe netdev.transmit { @@ -18,7 +19,13 @@ function print_activity() "PID", "UID", "DEV", "XMIT_PK", "RECV_PK", "XMIT_KB", "RECV_KB", "COMMAND") - foreach ([pid, dev, exec, uid] in ifrecv-) { + foreach ([pid, dev, exec, uid] in ifrecv) { + ifmerged[pid, dev, exec, uid] += @count(ifrecv[pid,dev,exec,uid]); + } + foreach ([pid, dev, exec, uid] in ifxmit) { + ifmerged[pid, dev, exec, uid] += @count(ifxmit[pid,dev,exec,uid]); + } + foreach ([pid, dev, exec, uid] in ifmerged-) { n_xmit = @count(ifxmit[pid, dev, exec, uid]) n_recv = @count(ifrecv[pid, dev, exec, uid]) printf("%5d %5d %-7s %7d %7d %7d %7d %-15s\n", @@ -32,6 +39,7 @@ function print_activity() delete ifxmit delete ifrecv + delete ifmerged } probe timer.ms(5000), end, error diff --git a/translate.cxx b/translate.cxx index c42097bb..3442703d 100644 --- a/translate.cxx +++ b/translate.cxx @@ -4576,10 +4576,13 @@ dump_unwindsyms (Dwfl_Module *m, // PC's, so we omit undefined or "fake" absolute addresses. // These fake absolute addresses occur in some older i386 // kernels to indicate they are vDSO symbols, not real - // functions in the kernel. + // functions in the kernel. We also omit symbols that have + // suspicious addresses (before base). if ((GELF_ST_TYPE (sym.st_info) == STT_FUNC || GELF_ST_TYPE (sym.st_info) == STT_OBJECT) // PR10000: also need .data - && !(sym.st_shndx == SHN_UNDEF || sym.st_shndx == SHN_ABS)) + && !(sym.st_shndx == SHN_UNDEF + || sym.st_shndx == SHN_ABS + || sym.st_value < base)) { Dwarf_Addr sym_addr = sym.st_value; const char *secname = NULL; |