def _iterator_except(pointer, len): start = pointer end = pointer + len while pointer != end: if exception_flag: raise gdb.MemoryError("hi bob") yield ("[%d]" % int(pointer - start), pointer.dereference()) pointer += 1
def element(self, index): first, last = self.array_bounds if first <= index and index <= last: return self.array_elements[index] else: raise gdb.MemoryError( "Out of bound vector access ({} not in {} .. {})".format( index, first, last))
def children(self): if self.value['first']: node = self.value['first'] for i in range(self.length): yield ('[{}]'.format(i), node['element']) node = node['next'] if node: raise gdb.MemoryError('The linked list seems invalid')
def children(self): if self.value["first"]: node = self.value["first"] for i in range(self.length): yield ("[{}]".format(i), node["element"]) node = node["next"] if node: raise gdb.MemoryError("The linked list seems invalid")
def _read_replacement(self, length, offset): """Return a slice of the buffer representing the replacement nop instructions.""" assert self._nop_bytes is not None rb = self._nop_bytes # If this request is outside of a nop instruction then we don't know # what to do, so just raise a memory error. if offset >= len(rb) or (offset + length) > len(rb): raise gdb.MemoryError("invalid length and offset combination") # Return only the slice of the nop instruction as requested. s = offset e = offset + length return rb[s:e]
def get_dyntype_info(tagged_value): """ Compute information about the dynamic type of a tagged value. :param gdb.Value tagged_value: Value for the tagged record to process. :return (gdb.Value, int): A tuple that contains: 1. The address of the primary dispatch table. 2. The "offset to top" information for the input value. """ system_address = get_system_address() tag_addr = get_tag_addr(tagged_value) signature, offset_to_top, _ = decode_tag(tag_addr) if signature == SIGNATURE_SECONDARY: record_addr = (tagged_value.address.cast(system_address) - abs(offset_to_top)) tag_addr = get_tag_addr(record_addr.cast(tagged_value.type.pointer())) signature, _, _ = decode_tag(tag_addr) if signature != SIGNATURE_PRIMARY: raise gdb.MemoryError('Corrupted tag') return (tag_addr.cast(system_address), offset_to_top)
def read_memory(self, length, offset): raise gdb.MemoryError(0x1234)
def read_memory(self, length, offset): # Throw a memory error with a specific address. We don't # expect this address to show up in the output though. raise gdb.MemoryError(0x1234)
def disassemble(self, info): try: info.read_memory(1, -info.address + 2) except gdb.MemoryError as e: raise gdb.MemoryError("cannot read code at address 0x2") return DisassemblerResult(1, "BAD")
def to_string(self): raise gdb.MemoryError("Cannot access memory.")