summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhunt <hunt>2007-08-15 13:56:04 +0000
committerhunt <hunt>2007-08-15 13:56:04 +0000
commite55247696593367660bac9a520c4b89407044c0a (patch)
tree8f65ab0f86ca9b1e7ded7b1c0ef7335c50233f9a
parentbaf473b06c18baf559baf81f9e099069a7bf0cb5 (diff)
downloadsystemtap-steved-e55247696593367660bac9a520c4b89407044c0a.tar.gz
systemtap-steved-e55247696593367660bac9a520c4b89407044c0a.tar.xz
systemtap-steved-e55247696593367660bac9a520c4b89407044c0a.zip
2007-08-15 Martin Hunt <hunt@redhat.com>
* stap_merge.tcl: New.
-rw-r--r--runtime/staprun/ChangeLog4
-rwxr-xr-xruntime/staprun/stap_merge.tcl102
2 files changed, 106 insertions, 0 deletions
diff --git a/runtime/staprun/ChangeLog b/runtime/staprun/ChangeLog
index de522180..002284bf 100644
--- a/runtime/staprun/ChangeLog
+++ b/runtime/staprun/ChangeLog
@@ -1,3 +1,7 @@
+2007-08-15 Martin Hunt <hunt@redhat.com>
+
+ * stap_merge.tcl: New.
+
2007-08-14 David Smith <dsmith@redhat.com>
Merge from setuid-branch. Changes also by Martin Hunt
diff --git a/runtime/staprun/stap_merge.tcl b/runtime/staprun/stap_merge.tcl
new file mode 100755
index 00000000..47d419ce
--- /dev/null
+++ b/runtime/staprun/stap_merge.tcl
@@ -0,0 +1,102 @@
+#!/usr/bin/env tclsh
+#
+# stap_merge.tcl - systemtap merge program
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright (C) Red Hat Inc, 2007
+#
+#
+
+proc usage {} {
+ puts stderr "$::argv0 \[-v\] \[-o output_filename\] input_files ...\n"
+ exit 1
+}
+
+set outfile "stdout"
+set verbose 0
+set index 0
+while {[string match -* [lindex $argv $index]]} {
+ switch -glob -- [lindex $argv $index] {
+ -v {set verbose 1}
+ -o {incr index; set outfile [lindex $argv $index]}
+ default {usage}
+ }
+ incr index
+}
+
+if {$tcl_platform(byteOrder) == "littleEndian"} {
+ set int_format i
+} else {
+ set int_format I
+}
+
+set files [lrange $argv $index end]
+
+set n 0
+foreach file $files {
+ if {[catch {open $file} fd($n)]} {
+ puts stderr $fd($n)
+ exit 1
+ }
+ fconfigure $fd($n) -translation binary
+ if {![binary scan [read $fd($n) 4] $int_format timestamp($n)]} {
+ continue
+ }
+ set timestamp($n) [expr $timestamp($n) & 0xFFFFFFFF]
+ incr n
+}
+set ncpus $n
+
+if {$outfile != "stdout"} {
+ if {[catch {open $outfile w} outfile]} {
+ puts stderr $outfile
+ exit 1
+ }
+}
+fconfigure $outfile -translation binary
+
+while {1} {
+ set mincpu -1
+ for {set n 0} {$n < $ncpus} {incr n} {
+ if {[info exists fd($n)] && (![info exists min] || $timestamp($n) <= $min)} {
+ set min $timestamp($n)
+ set mincpu $n
+ }
+ }
+
+ if {![info exists min]} {break}
+
+ if {![binary scan [read $fd($mincpu) 4] $int_format len]} {
+ puts stderr "Error reading length from channel $mincpu"
+ exit 1
+ }
+
+ if {$verbose == 1} {
+ puts stderr "\[CPU:$mincpu, seq=$min, length=$len\]"
+ }
+
+ set data [read $fd($mincpu) $len]
+ puts -nonewline $outfile $data
+
+ set data [read $fd($mincpu) 4]
+ if {$data == ""} {
+ unset fd($mincpu)
+ } else {
+ binary scan $data $int_format timestamp($mincpu)
+ set timestamp($mincpu) [expr $timestamp($mincpu) & 0xFFFFFFFF]
+ }
+ unset min
+}