straces 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/straces.rb +31 -10
- data/straces.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51245154ff7877023486583fd33719bbfd50a9ef490bea0a132ced5a162a5b61
|
4
|
+
data.tar.gz: 65bc6d33500b88d51a93b96a0d5011e8b8e5accd7004863e2b1251d32d6fa129
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acf8587a2631bdd8eff809a1ed4b655718a403b722ec40d08d97f8b7e6e989a39b74154a217bcead9b51c1deac91aaf7df1b2fc8809cf2ad8518543c039d6165
|
7
|
+
data.tar.gz: b119b17004b3019bd434f6abd3900790ac66bf92f00336003d6d2f5627aa20ee76fe5283c510e5c8c87bfb1ddae45b0b0dd0e1bf3df9fff33526f8fe598521c5
|
data/Gemfile.lock
CHANGED
data/lib/straces.rb
CHANGED
@@ -38,7 +38,22 @@ end
|
|
38
38
|
|
39
39
|
|
40
40
|
def strace_parse(line)
|
41
|
-
|
41
|
+
return nil if line.end_with? "<unfinished ...>"
|
42
|
+
return nil if line.end_with? "resumed>) = ?"
|
43
|
+
return nil if line.end_with? "+++ exited with 0 +++"
|
44
|
+
# accept4(3,
|
45
|
+
return nil if line.end_with? ", "
|
46
|
+
matcher = line.match /^(?<pid>\d*)\s?(?<time>\d\d:\d\d:\d\d\.?\d*)?\s?(?<interrupted>\<\.\.\.)?(?<call>[^\(]+)(?<middle>.*)?\<(?<timing>\d+\.\d+)\>$/
|
47
|
+
|
48
|
+
#63796 11:18:12 clock_gettime(CLOCK_MONOTONIC, {tv_sec=27510, tv_nsec=693534954}) = 0 <0.000108>
|
49
|
+
#63796 11:18:12 <... clock_gettime resumed> {tv_sec=27510, tv_nsec=648632454}) = 0 <0.000356>
|
50
|
+
|
51
|
+
call, middle = if matcher[:interrupted]
|
52
|
+
syscall, rest = matcher[:call].split(" ")
|
53
|
+
[syscall, rest]
|
54
|
+
else
|
55
|
+
[matcher[:call], matcher[:middle]]
|
56
|
+
end
|
42
57
|
|
43
58
|
# <detached ..>
|
44
59
|
timing = Float matcher[:timing] rescue 0.0
|
@@ -46,8 +61,8 @@ def strace_parse(line)
|
|
46
61
|
if matcher
|
47
62
|
{
|
48
63
|
pid: matcher[:pid],
|
49
|
-
call:
|
50
|
-
middle:
|
64
|
+
call: call,
|
65
|
+
middle: middle,
|
51
66
|
timing: timing
|
52
67
|
}
|
53
68
|
else
|
@@ -105,10 +120,10 @@ objs.each_with_index do |obj, i|
|
|
105
120
|
obj[:time].round(4).to_s.ljust(6, "0"),
|
106
121
|
obj[:timing].round(6).to_s.ljust(8, "0"),
|
107
122
|
obj[:call].ljust(16),
|
108
|
-
"#"*(obj[:normalized] == 0 ? 1 : obj[:normalized])
|
123
|
+
"#".green*(obj[:normalized] == 0 ? 1 : obj[:normalized])
|
109
124
|
].join " "
|
110
125
|
else
|
111
|
-
matches = filter.match /^(?<comparator>gt|lt|ge|le|eq)=(?<value>\d+\.?\d*)$/
|
126
|
+
matches = filter.match /^(?<comparator>at|gt|lt|ge|le|eq)=(?<value>\d+\.?\d*)$/
|
112
127
|
comparator = matches && matches[:comparator]
|
113
128
|
value = Float matches[:value] rescue nil
|
114
129
|
if comparator.nil? || value.nil?
|
@@ -125,16 +140,22 @@ objs.each_with_index do |obj, i|
|
|
125
140
|
:<
|
126
141
|
when "lte"
|
127
142
|
:<=
|
128
|
-
when "eq"
|
143
|
+
when "eq","at"
|
129
144
|
:==
|
130
145
|
end
|
131
146
|
|
132
|
-
if
|
147
|
+
target = if comparator == "at"
|
148
|
+
obj[:time].round(4)
|
149
|
+
else
|
150
|
+
obj[:timing]
|
151
|
+
end
|
152
|
+
|
153
|
+
if target.send(ruby_comparator, value)
|
133
154
|
terminal_width=Integer `tput cols`
|
134
155
|
puts "-"*terminal_width
|
135
|
-
puts objs[i-lines_before..i-1].map {|o| format(o)}
|
136
|
-
puts format(objs[i]).red
|
137
|
-
puts objs[i+1..i+lines_after].map {|o| format(o)}
|
156
|
+
puts objs[i-lines_before..i-1].map {|o| format(o) + "\n" + "#".green*(o[:normalized] == 0 ? 1 : o[:normalized])}
|
157
|
+
puts format(objs[i]).red + "\n" + "#".green*(objs[i][:normalized] == 0 ? 1 : objs[i][:normalized])
|
158
|
+
puts objs[i+1..i+lines_after].map {|o| format(o) + "\n" + "#".green*(o[:normalized] == 0 ? 1 : o[:normalized])}
|
138
159
|
|
139
160
|
puts ""
|
140
161
|
end
|
data/straces.gemspec
CHANGED