7Visualize bitmaps in gdb.
9(gdb) source <path to this file>
10(gdb) sk_bitmap <symbol>
12This should pop up a window with the bitmap displayed.
13Right clicking should bring up a menu, allowing the
14bitmap to be saved to a file.
44 """Displays the content of an SkBitmap image."""
47 super(sk_bitmap, self).
__init__(
'sk_bitmap',
49 gdb.COMPLETE_FILENAME)
52 frame = gdb.selected_frame()
53 val = frame.read_var(arg)
54 if str(val.type.strip_typedefs()) ==
'SkBitmap':
55 pixmap = val[
'fPixmap']
56 pixels = pixmap[
'fPixels']
57 row_bytes = pixmap[
'fRowBytes']
58 info = pixmap[
'fInfo']
59 dimensions = info[
'fDimensions']
60 width = dimensions[
'fWidth']
61 height = dimensions[
'fHeight']
62 color_type = info[
'fColorType']
63 alpha_type = info[
'fAlphaType']
65 process = gdb.selected_inferior()
66 memory_data = process.read_memory(pixels, row_bytes * height)
67 size = (width, height)
70 if color_type == ColorType.bgra_8888.value:
71 if alpha_type == AlphaType.unpremul.value:
72 image = Image.frombytes(
"RGBA", size, memory_data,
73 "raw",
"BGRA", row_bytes, 1)
74 elif alpha_type == AlphaType.premul.value:
76 image = Image.frombytes(
"RGBA", size, memory_data,
77 "raw",
"BGRa", row_bytes, 1)
83 print (
"Need to add support for %s %s." % (
def invoke(self, arg, from_tty)