def fetch_globals_data(): """Fetch the reference count for the global tags (non-function) in the database. Returns the tuple `(address, tags)` where the `address` and `tags` fields are both dictionaries containing the reference count for the addresses and tag names. """ addr, tags = {}, {} left, right = db.config.bounds() six.print_(u'globals: fetching tags from data', file=output) for ea in db.address.iterate(left, right): if func.within(ea): continue ui.navigation.auto(ea) # grab both comment types and decode them. after they've been decoded, # then iterate through all of their keys and tally up their counts. repeatable, nonrepeatable = (db.comment(ea, repeatable=item) for item in [True, False]) for items in map(internal.comment.decode, [repeatable, nonrepeatable]): #items.pop('name', None) for name in items: addr[ea] = addr.get(ea, 0) + 1 tags[name] = tags.get(name, 0) + 1 continue continue return addr, tags
def fetch_contents(fn): """Fetch the reference count for the contents of function `fn` in the database. Returns the tuple `(func, address, tags)` where the `address` and `tags` fields are both dictionaries containing the reference count for the addresses and tag names. The field `func` contains the address of the function. """ addr, tags = {}, {} for ea in func.iterate(fn): ui.navigation.auto(ea) # grab both comment types so that we can decode them. after decoding, # then iterate through all of their keys and tally up their counts. repeatable, nonrepeatable = (db.comment(ea, repeatable=item) for item in [True, False]) for items in map(internal.comment.decode, [repeatable, nonrepeatable]): #items.pop('name', None) for name in items: addr[ea] = addr.get(ea, 0) + 1 tags[name] = tags.get(name, 0) + 1 continue continue return func.address(fn), addr, tags
def check_global(ea): '''Validate the cache defined for the global at the address `ea`.''' if func.within(ea): return False cache = internal.comment.decode(db.comment(db.top())) cache.update(internal.comment.decode(db.comment(db.bottom()))) node = internal.netnode.get(internal.comment.tagging.node()) tag = internal.comment.decode(db.comment(ea)) if cache and '__address__' not in cache: return False if not cache and tag: return False count = internal.netnode.alt.get(node, ea) if tag and not count: return False if len(tag['__address__']) != count: return False keys = tag['__tags__'] if any(t not in cache for t in keys): return False return True
def check_global(ea): '''Validate the cache defined for the global at the address `ea`.''' if func.within(ea): return False cache = internal.comment.decode(db.comment(db.top())) cache.update( internal.comment.decode(db.comment(db.bottom())) ) node = internal.netnode.get(internal.comment.tagging.node()) tag = internal.comment.decode(db.comment(ea)) if cache and '__address__' not in cache: return False if not cache and tag: return False count = internal.netnode.alt.get(node, ea) if tag and not count: return False if len(tag['__address__']) != count: return False keys = tag['__tags__'] if any(t not in cache for t in keys): return False return True
def check_contents(ea): '''Validate the cache defined for the contents of the function `ea`.''' node, key = internal.netnode.get(internal.comment.tagging.node()), internal.comment.contents._key(ea) tag = internal.comment.decode(db.comment(key)) encdata = internal.netnode.sup.get(node, key) if encdata is None and tag: return False if not isinstance(tag, dict): return False if not tag: return True if '__address__' not in tag: return False if '__tags__' not in tag: return False return True
def check_contents(ea): '''Validate the cache defined for the contents of the function `ea`.''' node, key = internal.netnode.get( internal.comment.tagging.node()), internal.comment.contents._key(ea) tag = internal.comment.decode(db.comment(key)) encdata = internal.netnode.sup.get(node, key) if encdata is None and tag: return False if not isinstance(tag, dict): return False if not tag: return True if '__address__' not in tag: return False if '__tags__' not in tag: return False return True