Module: Vernier::StackTableHelpers
Defined Under Namespace
Classes: BaseType, Frame, Func, Stack
Instance Method Summary
collapse
Instance Method Details
#backtrace(stack_idx) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/vernier/stack_table_helpers.rb', line 25
def backtrace(stack_idx)
last_filename = nil
last_lineno = nil
full_stack(stack_idx).reverse.map do |stack_idx|
frame_idx = stack_frame_idx(stack_idx)
func_idx = frame_func_idx(frame_idx)
line = frame_line_no(frame_idx)
line = last_lineno if line == 0
last_lineno = line
name = func_name(func_idx)
filename = func_path(func_idx)
filename = last_filename if filename.empty?
last_filename = filename
"#{filename}:#{line}:in '#{name}'"
end.reverse
end
|
#full_stack(stack_idx) ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/vernier/stack_table_helpers.rb', line 43
def full_stack(stack_idx)
full_stack = []
while stack_idx
full_stack << stack_idx
stack_idx = stack_parent_idx(stack_idx)
end
full_stack
end
|
#inspect ⇒ Object
3
4
5
|
# File 'lib/vernier/stack_table_helpers.rb', line 3
def inspect
"#<#{self.class.name} #{stack_count} stacks, #{frame_count} frames, #{func_count} funcs>"
end
|
#stack(idx) ⇒ Object
149
150
151
152
|
# File 'lib/vernier/stack_table_helpers.rb', line 149
def stack(idx)
raise ArgumentError, "invalid index" unless idx
Stack.new(self, idx)
end
|
#to_h ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/vernier/stack_table_helpers.rb', line 7
def to_h
{
stack_table: {
parent: stack_count.times.map { stack_parent_idx(_1) },
frame: stack_count.times.map { stack_frame_idx(_1) }
},
frame_table: {
func: frame_count.times.map { frame_func_idx(_1) },
line: frame_count.times.map { frame_line_no(_1) }
},
func_table: {
name: func_count.times.map { func_name(_1) },
filename: func_count.times.map { func_filename(_1) },
first_line: func_count.times.map { func_first_lineno(_1) }
}
}
end
|