libcsdbg  1.28
C++ exception (and generic) stack trace debug library
const symbol * csdbg::process::cache_lookup ( mem_addr_t  addr) const
protectedvirtual

Perform a cache lookup.

Parameters
[in]addrthe address to lookup
Returns
the cached symbol or NULL if no such lookup is cached

Definition at line 47 of file process.cpp.

References csdbg::symbol::addr(), likely, csdbg::util::lock(), m_symcache, unlikely, and csdbg::util::unlock().

Referenced by lookup().

48 {
49  util::lock();
50 
51  /*
52  * Search the cache starting from the last entry (the latest added) to exploit
53  * locality of reference
54  */
55  for (i32 i = m_symcache->size() - 1; likely(i >= 0); i--) {
56  symbol *sym = m_symcache->at(i);
57  if ( unlikely(sym->addr() == addr) ) {
58  util::unlock();
59  return sym;
60  }
61  }
62 
63  util::unlock();
64  return NULL;
65 }
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344
static void lock()
Lock the global access mutex.
Definition: util.cpp:397
static void unlock()
Unlock the global access mutex.
Definition: util.cpp:406
chain< symbol > * m_symcache
Lookup cache.
Definition: process.hpp:41
int i32
32-bit signed integer
Definition: config.hpp:82
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349

+ Here is the call graph for this function:

+ Here is the caller graph for this function: