Class: RbBCC::SymbolCache
- Inherits:
-
Object
- Object
- RbBCC::SymbolCache
- Defined in:
- lib/rbbcc/symbol_cache.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(pid) ⇒ SymbolCache
constructor
A new instance of SymbolCache.
- #resolve(addr, demangle) ⇒ Object
- #resolve_name(_module, name) ⇒ Object
Constructor Details
#initialize(pid) ⇒ SymbolCache
Returns a new instance of SymbolCache.
22 23 24 |
# File 'lib/rbbcc/symbol_cache.rb', line 22 def initialize(pid) @cache = Clib.bcc_symcache_new(pid, nil) end |
Class Method Details
.cache(pid) ⇒ Object Also known as: []
10 11 12 13 14 |
# File 'lib/rbbcc/symbol_cache.rb', line 10 def cache(pid) pid = -1 if pid < 0 && pid != -1 caches[pid] ||= SymbolCache.new(pid) caches[pid] end |
.caches ⇒ Object
6 7 8 |
# File 'lib/rbbcc/symbol_cache.rb', line 6 def caches @caches ||= {} end |
.resolve_global(name) ⇒ Object
17 18 19 |
# File 'lib/rbbcc/symbol_cache.rb', line 17 def resolve_global(name) self[-1].resolve_name(nil, name) end |
Instance Method Details
#resolve(addr, demangle) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rbbcc/symbol_cache.rb', line 26 def resolve(addr, demangle) sym = Clib::BCCSymbol.malloc ret = if demangle Clib.bcc_symcache_resolve(@cache, addr, sym) else Clib.bcc_symcache_resolve_no_demangle(@cache, addr, sym) end if ret < 0 return [nil, addr, nil] end if demangle name_res = Clib.__extract_char(sym.demangle_name) Clib.bcc_symbol_free_demangle_name(sym) else name_res = Clib.__extract_char(sym.name) end return [name_res, sym.offset, Clib.__extract_char(sym.module)] end |
#resolve_name(_module, name) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/rbbcc/symbol_cache.rb', line 47 def resolve_name(_module, name) addr_p = Fiddle::Pointer.malloc(Fiddle::SIZEOF_UINTPTR_T) if Clib.bcc_symcache_resolve_name(@cache, _module, name, addr_p) < 0 return false end return addr_p end |