Module: RbBCC::Clib
- Extended by:
- Fiddle::Importer
- Defined in:
- lib/rbbcc/clib.rb
Constant Summary collapse
- PerfReader =
FIXME: This size of struct will change in future version and no struct member info in header. This is hacky
struct( [ "void * raw_cb", "void * lost_cb", "void * cb_cookie", "void * buf", "int buf_size", "void * base", "int rb_use_state", "int rb_read_tid", "int page_size", "int page_cnt", "int fd" ] )
- BCCSymbol =
struct([ "const char *name", "const char *demangle_name", "const char *module", "unsigned long offset" ])
- BCCSymbolOption =
struct([ 'int use_debug_file', 'int check_debug_file_crc', 'unsigned int use_symbol_type' ])
- BCCIPOffsetUnion =
union(['unsigned long long offset', 'unsigned long long ip'])
- BCCStacktraceBuildID =
struct([ 'unsigned int status', 'unsigned char[20] build_id', 'unsigned long long u' # truly union ])
Class Method Summary collapse
- .__extract_char(ptr) ⇒ Object
- .do_bcc_func_load(mod, prog_type, name, insns, len, license, kver, loglv, buf, buf_size, device) ⇒ Object
- .do_bpf_module_create_c_from_string(text, flags, cflags, ncflags, allow_limit, dev_name = nil) ⇒ Object
- .libbcc_version ⇒ Object
- .libbcc_version=(ver) ⇒ Object
- .libbcc_version_gteq?(ver) ⇒ Boolean
- .system_libbcc_versions ⇒ Object
Class Method Details
.__extract_char(ptr) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/rbbcc/clib.rb', line 5 def self.__extract_char(ptr) return nil if ptr.null? idx = 0 while ptr[idx, 1] != "\x00" idx += 1 end ptr.size = idx + 1 ptr.to_s end |
.do_bcc_func_load(mod, prog_type, name, insns, len, license, kver, loglv, buf, buf_size, device) ⇒ Object
80 81 82 |
# File 'lib/rbbcc/clib.rb', line 80 def self.do_bcc_func_load(mod, prog_type, name, insns, len, license, kver, loglv, buf, buf_size, device) bcc_func_load(mod, prog_type, name, insns, len, license, kver, loglv, buf, buf_size, device) end |
.do_bpf_module_create_c_from_string(text, flags, cflags, ncflags, allow_limit, dev_name = nil) ⇒ Object
76 77 78 |
# File 'lib/rbbcc/clib.rb', line 76 def self.do_bpf_module_create_c_from_string(text, flags, cflags, ncflags, allow_limit, dev_name) bpf_module_create_c_from_string(text, flags, cflags, ncflags, allow_limit, dev_name) end |
.libbcc_version ⇒ Object
19 20 21 |
# File 'lib/rbbcc/clib.rb', line 19 def self.libbcc_version @@libbcc_version end |
.libbcc_version=(ver) ⇒ Object
15 16 17 |
# File 'lib/rbbcc/clib.rb', line 15 def self.libbcc_version=(ver) @@libbcc_version ||= Gem::Version.new(ver) end |
.libbcc_version_gteq?(ver) ⇒ Boolean
23 24 25 |
# File 'lib/rbbcc/clib.rb', line 23 def self.libbcc_version_gteq?(ver) @@libbcc_version >= Gem::Version.new(ver) end |
.system_libbcc_versions ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rbbcc/clib.rb', line 27 def self.system_libbcc_versions paths = ['/lib', '/usr/lib', '/usr/lib64', '/usr/local/lib', '/usr/lib/x86_64-linux-gnu', '/usr/lib/aarch64-linux-gnu'].freeze candidates = paths.flat_map do |path| Dir.glob("#{path}/libbcc.so.[0-9]*") end candidates.map do |path| path.match(/libbcc\.so\.([\d.]+)/)&.captures&.first end.compact.uniq.sort_by { |v| Gem::Version.new(v) }.reverse rescue [] end |