Exemple #1
0
 def __call__(self, addr):
     result = self.cache.get(addr, None)
     if result:
         return result
     x = debug.SourceAddress(addr, 0)
     for a in [self.symbols, self.segments, self.modules]:
         index = bisect.bisect_left(a, x) - 1
         if index > 0 and index < len(a):
             s = a[index]
             if s.addr <= addr and (s.addr + s.size) > addr:
                 result = [
                     debug.SourceAddress(addr,
                                         ('%s+0x%x (%#08x)' %
                                          (s.name, addr - s.addr, addr)),
                                         s.filename, s.line)
                 ]
                 self.cache[addr] = result
                 return result
     result = self.delegate(addr)
     self.cache[addr] = result
     return result
Exemple #2
0
    def __call__(self, addr):
        if addr in syminfo_resolver.cache:
            return self.cache[addr]
        infosym = gdb.execute('info symbol 0x%x' % addr, False, True)
        func = infosym[:infosym.find(" + ")]
        sal = gdb.find_pc_line(addr)
        filename = None
        line = None
        try :
            # prefer (filename:line),
            filename = sal.symtab.filename
            line = sal.line
        except :
            # but if can't get it, at least give the name of the object
            if not infosym.startswith("No symbol matches") :
                filename = infosym[infosym.rfind("/")+1:].rstrip()

        if filename and filename.startswith('../../'):
            filename = filename[6:]
        result = [debug.SourceAddress(addr, name=func, filename=filename, line=line)]
        syminfo_resolver.cache[addr] = result
        return result