drgn
drgn copied to clipboard
More convenient API for reading an array
Sometimes I need to read all elements of a dynamically sized array. This can be slow, especially with a high latency remote debugging connection to the target. So I would really like an API for reading all elements of the array at once, so that I can read the array with a small number of round trips to the target. I came up with this workaround (for my current use case, which is reading the KASAN ring buffer):
cast('struct kasan_stack_ring_entry(*) [%d]' % prog['stack_ring'].size, prog['stack_ring'].entries)[0].read_()
But it would be nice if there were a better way to do this. One possibility might be a read_array_() method for objects of pointer type that reads a specified number of elements via the pointer and returns the array.