38 lines
909 B
Ruby
38 lines
909 B
Ruby
|
#!/usr/bin/env ruby
|
||
|
require 'pry'
|
||
|
class StraceParser
|
||
|
SYS_CALL_MATCHER = /\A[a-zA-Z_]*\(/
|
||
|
|
||
|
attr_accessor :file_lines
|
||
|
def initialize(filepath)
|
||
|
@file_lines = File.readlines(filepath).map(&:chomp)
|
||
|
end
|
||
|
|
||
|
def sys_calls
|
||
|
@file_lines.map do |line|
|
||
|
matches = line.match(SYS_CALL_MATCHER)
|
||
|
# catch any non-sys-call-matches. maybe we can fix the regex but this is fine for now.
|
||
|
sys_call = matches.to_s.chomp("(") unless matches.to_s == ""
|
||
|
end.compact
|
||
|
end
|
||
|
|
||
|
def sys_call_counts
|
||
|
sys_calls.group_by(&:itself).map {|k,v| [k, v.count] }.sort_by {|k,v|v}.reverse
|
||
|
end
|
||
|
|
||
|
def open_sys_calls
|
||
|
end
|
||
|
|
||
|
def read_sys_calls
|
||
|
end
|
||
|
|
||
|
def write_sys_calls
|
||
|
end
|
||
|
end
|
||
|
|
||
|
# to test - why is my dbb-app segfaulting on my manjaro linux install?
|
||
|
# something to do with qt5 but lets see if we can write a better tool to help
|
||
|
filepath = './strace.out'
|
||
|
parser = StraceParser.new(filepath)
|
||
|
binding.pry
|