Class: RbBCC::StackTrace

Inherits:
TableBase show all
Defined in:
lib/rbbcc/table.rb

Constant Summary collapse

MAX_DEPTH =
127
BPF_F_STACK_BUILD_ID =
(1<<5)
BPF_STACK_BUILD_ID_EMPTY =

can’t get stacktrace

0
BPF_STACK_BUILD_ID_VALID =

valid build-id,ip

1
BPF_STACK_BUILD_ID_IP =

fallback to ip

2

Instance Attribute Summary

Attributes inherited from TableBase

#bpf, #flags, #keysize, #keytype, #leafsize, #leaftype, #map_fd, #map_id, #name, #ttype

Instance Method Summary collapse

Methods inherited from TableBase

#[], #[]=, #clear, #delete, #each_key, #each_pair, #each_value, #fetch, #initialize, #items, #next, #print_linear_hist, #print_log2_hist, #structured_key?, #values

Methods included from CPUHelper

_read_cpu_range, get_online_cpus, get_possible_cpus

Constructor Details

This class inherits a constructor from RbBCC::TableBase

Instance Method Details

#get_stack(stack_id) ⇒ Object



392
393
394
395
# File 'lib/rbbcc/table.rb', line 392

def get_stack(stack_id)
  key = stack_id.is_a?(Fiddle::Pointer) ? stack_id : byref(stack_id, @keysize)
  leaftype.new(self[stack_id])
end

#walk(stack_id, resolve: nil, &blk) ⇒ Object



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/rbbcc/table.rb', line 397

def walk(stack_id, resolve: nil, &blk)
  addrs = if (flags & BPF_F_STACK_BUILD_ID).nonzero?
            get_stack(stack_id).trace[0..MAX_DEPTH]
          else
            get_stack(stack_id).ip[0..MAX_DEPTH]
          end
  addrs.each do |addr|
    break if addr.zero?
    if resolve
      blk.call(resolve.call(addr))
    else
      blk.call(addr)
    end
  end
end