aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/gdb/linux/proc.py
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@linaro.org>2016-05-23 19:24:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-23 20:04:14 -0400
commite7165a2d7d87cd397d166ebf4d49763d28f5fc3d (patch)
treed9f2c2e9989b4a182fccc2e5594328900c6c5a52 /scripts/gdb/linux/proc.py
parent74627cf2df50bfc29f51341578038e284796a101 (diff)
scripts/gdb: add io resource readers
Provide iomem_resource and ioports_resource printers and command hooks It can be quite interesting to halt the kernel as it's booting and check to see this list as it is being populated. It should be useful in the event that a kernel is not booting, you can identify what memory resources have been registered Link: http://lkml.kernel.org/r/f0a6b9fa9c92af4d7ed2e7343ccc84150e9c6fc5.1462865983.git.jan.kiszka@siemens.com Signed-off-by: Kieran Bingham <kieran.bingham@linaro.org> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/gdb/linux/proc.py')
-rw-r--r--scripts/gdb/linux/proc.py57
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
41LxVersion() 41LxVersion()
42
43
44# Resource Structure Printers
45# /proc/iomem
46# /proc/ioports
47
48def 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
60def 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
73class LxIOMem(gdb.Command):
74 """Identify the IO memory resource locations defined by the kernel
75
76Equivalent 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
84LxIOMem()
85
86
87class LxIOPorts(gdb.Command):
88 """Identify the IO port resource locations defined by the kernel
89
90Equivalent 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
98LxIOPorts()