def get_frame_symbols(frm=None): with frame.Selector(frm) as fs: f = fs.frame if f.is_valid(): return {str(sym) for sym in f.block()} else: raise Exception("Frame no longer valid")
def serialize_frame_locals(frm=None): Pull._updatedNames.clear() with frame.Selector(frm) as fs: f = fs.frame if f.is_valid(): for sym in f.block(): desc = descriptions.MemoryDescription(sym.name) handler = Pull.handler_factory(sym.type) obj = handler(desc) obj.save()
def val_string(self): """ Get the printed value of a primitive object """ with frame.Selector(self.frame.frame) as s: ## TODO: Find a way to print values without messing with the $# vars # in the gdb interface. gdbPrint = gdb.execute("print " + self.name, False, True) ## TODO: If we can't fix the $# var, we may as well use it. ## this is free information we may as well store for the user's use. ansSections = gdbPrint[:-1].split(" = ")[1:] return " ".join(ansSections)
def __init__(self, description): super(MemoryPull, self).__init__(description) self._relativeName = description.relative_name self._frame = frame.Frame(description.frame) self._object = None with frame.Selector(self.frame.frame) as fs: sym = self.description.symbol if sym is not None: typ = sym.type if typ.code in { gdb.TYPE_CODE_PTR, gdb.TYPE_CODE_ARRAY, gdb.TYPE_CODE_STRUCT, gdb.TYPE_CODE_INT, gdb.TYPE_CODE_FUNC, }: try: self._object = gdb.parse_and_eval(self.name) except TypeError: try: self._object = sym.value(fs.frame.frame) self._value = str(self.object) except TypeError: print("DEBUG: TypeError detected!") else: try: self._object = gdb.parse_and_eval(self.name) except gdb.error as e: print("DEBUG:") traceback.print_exc() # pass if self.description.symbol and self.description.symbol.type: self._type_name = str(self.description.symbol.type) elif isinstance(self.object, gdb.Value): self._type_name = Pull.get_true_type_name(self.object.type) else: # TODO: This is for dev. Remove in production code. self._type_name = "void" # raise Exception("Untyped memory", self) if self.index is None: if self.object is None: self._index = "?" else: self._index = str(self.object.address)