def test_getSymByAddr_exact_false(self): ''' test for bug that was replacing symresolvers with symbol objects. ''' fname, base, size, width = ('foo', 0x0, 0, 4) fres = e_sym_resolv.FileSymbol(fname, base, size, width) self.symres.addSymbol(fres) # now symobjsbyname['foo'] = FileSymbol symcache = [(0x16001, 0, 'alpha', e_sym_resolv.SYMSTOR_SYM_SYMBOL)] self.symres.impSymCache(symcache, symfname='foo') # look up the FileSymbol as a 'Symbol' (not a resolver) # this causes the symobjsbyname to smash in a Symbol instead of a # SymbolResolver (symobjsbyname['foo'] = Symbol) sym = self.symres.getSymByAddr(0x10, exact=False) assert (sym != None) # now symobjsbyname['foo'] = Symbol # force return of a sym that has a fname set # causes a .get on symobjsbyname, retrieves Symbol, but then tries # to cache since it should be a resolver since we have an fname. # boom. sym = self.symres.getSymByAddr(0x16010, exact=False) assert (sym != None)
def addLibraryBase(self, libname, address, always=False): """ This should be used *at load time* to setup the library event metadata. This *must* be called from a context where it's safe to fire notifiers, because it will fire a notifier to alert about a LOAD_LIBRARY. (This means *not* from inside another notifer) """ self.setMeta("LatestLibrary", None) self.setMeta("LatestLibraryNorm", None) normname = self.normFileName(libname) if self.getSymByName(normname) is not None: normname = "%s_%.8x" % (normname, address) self.getMeta("LibraryPaths")[address] = libname self.getMeta("LibraryBases")[normname] = address self.setMeta("LatestLibrary", libname) self.setMeta("LatestLibraryNorm", normname) # Only actually do library work with a file or force if os.path.exists(libname) or always: width = self.arch.getPointerSize() sym = e_sym_resolv.FileSymbol(normname, address, 0, width=width) sym.casesens = self.casesens self.addSymbol(sym) self.libpaths[normname] = libname self.fireNotifiers(vtrace.NOTIFY_LOAD_LIBRARY)
def test_resolver(self): fname, base, size, width = ('foo', 0x0, 0, 4) fres = e_sym_resolv.FileSymbol(fname, base, size, width) self.symres.addSymbol(fres) assert(fname in self.symres.symobjsbyname) assert(isinstance(self.symres.symobjsbyname[fname], e_sym_resolv.SymbolResolver))
def test_sym(self): fname, base, size, width = ('foo', 0x1234, 0x5678, 4) fres = e_sym_resolv.FileSymbol(fname, base, size, width) # check Symbol vars assert (fres.name == fname) assert (fres.value == base) assert (fres.size == size) #assert(fres.fname == fname) # check SymbolResolver vars assert (fres.width == width) assert (fres.baseaddr == base)
def test_resolver_fname_none(self): with self.assertRaises(Exception): fresolv = e_sym_resolv.FileSymbol(None, 0, 0, 4)