diff options
Diffstat (limited to 'scripts/gdb/linux/proc.py')
-rw-r--r-- | scripts/gdb/linux/proc.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/gdb/linux/proc.py b/scripts/gdb/linux/proc.py index 6e6709c1830c..d855b2fd9a06 100644 --- a/scripts/gdb/linux/proc.py +++ b/scripts/gdb/linux/proc.py | |||
@@ -39,3 +39,60 @@ class LxVersion(gdb.Command): | |||
39 | gdb.write(gdb.parse_and_eval("linux_banner").string()) | 39 | gdb.write(gdb.parse_and_eval("linux_banner").string()) |
40 | 40 | ||
41 | LxVersion() | 41 | LxVersion() |
42 | |||
43 | |||
44 | # Resource Structure Printers | ||
45 | # /proc/iomem | ||
46 | # /proc/ioports | ||
47 | |||
48 | def get_resources(resource, depth): | ||
49 | while resource: | ||
50 | yield resource, depth | ||
51 | |||
52 | child = resource['child'] | ||
53 | if child: | ||
54 | for res, deep in get_resources(child, depth + 1): | ||
55 | yield res, deep | ||
56 | |||
57 | resource = resource['sibling'] | ||
58 | |||
59 | |||
60 | def show_lx_resources(resource_str): | ||
61 | resource = gdb.parse_and_eval(resource_str) | ||
62 | width = 4 if resource['end'] < 0x10000 else 8 | ||
63 | # Iterate straight to the first child | ||
64 | for res, depth in get_resources(resource['child'], 0): | ||
65 | start = int(res['start']) | ||
66 | end = int(res['end']) | ||
67 | gdb.write(" " * depth * 2 + | ||
68 | "{0:0{1}x}-".format(start, width) + | ||
69 | "{0:0{1}x} : ".format(end, width) + | ||
70 | res['name'].string() + "\n") | ||
71 | |||
72 | |||
73 | class LxIOMem(gdb.Command): | ||
74 | """Identify the IO memory resource locations defined by the kernel | ||
75 | |||
76 | Equivalent to cat /proc/iomem on a running target""" | ||
77 | |||
78 | def __init__(self): | ||
79 | super(LxIOMem, self).__init__("lx-iomem", gdb.COMMAND_DATA) | ||
80 | |||
81 | def invoke(self, arg, from_tty): | ||
82 | return show_lx_resources("iomem_resource") | ||
83 | |||
84 | LxIOMem() | ||
85 | |||
86 | |||
87 | class LxIOPorts(gdb.Command): | ||
88 | """Identify the IO port resource locations defined by the kernel | ||
89 | |||
90 | Equivalent to cat /proc/ioports on a running target""" | ||
91 | |||
92 | def __init__(self): | ||
93 | super(LxIOPorts, self).__init__("lx-ioports", gdb.COMMAND_DATA) | ||
94 | |||
95 | def invoke(self, arg, from_tty): | ||
96 | return show_lx_resources("ioport_resource") | ||
97 | |||
98 | LxIOPorts() | ||