2 # gdb helper commands and functions for Linux kernel debugging
4 # Kernel proc information reader
6 # Copyright (c) 2016 Linaro Ltd
9 # Kieran Bingham <kieran.bingham@linaro.org>
11 # This work is licensed under the terms of the GNU GPL version 2.
17 class LxCmdLine(gdb
.Command
):
18 """ Report the Linux Commandline used in the current kernel.
19 Equivalent to cat /proc/cmdline on a running target"""
22 super(LxCmdLine
, self
).__init
__("lx-cmdline", gdb
.COMMAND_DATA
)
24 def invoke(self
, arg
, from_tty
):
25 gdb
.write(gdb
.parse_and_eval("saved_command_line").string() + "\n")
30 class LxVersion(gdb
.Command
):
31 """ Report the Linux Version of the current kernel.
32 Equivalent to cat /proc/version on a running target"""
35 super(LxVersion
, self
).__init
__("lx-version", gdb
.COMMAND_DATA
)
37 def invoke(self
, arg
, from_tty
):
38 # linux_banner should contain a newline
39 gdb
.write(gdb
.parse_and_eval("linux_banner").string())
44 # Resource Structure Printers
48 def get_resources(resource
, depth
):
52 child
= resource
['child']
54 for res
, deep
in get_resources(child
, depth
+ 1):
57 resource
= resource
['sibling']
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'])
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")
73 class LxIOMem(gdb
.Command
):
74 """Identify the IO memory resource locations defined by the kernel
76 Equivalent to cat /proc/iomem on a running target"""
79 super(LxIOMem
, self
).__init
__("lx-iomem", gdb
.COMMAND_DATA
)
81 def invoke(self
, arg
, from_tty
):
82 return show_lx_resources("iomem_resource")
87 class LxIOPorts(gdb
.Command
):
88 """Identify the IO port resource locations defined by the kernel
90 Equivalent to cat /proc/ioports on a running target"""
93 super(LxIOPorts
, self
).__init
__("lx-ioports", gdb
.COMMAND_DATA
)
95 def invoke(self
, arg
, from_tty
):
96 return show_lx_resources("ioport_resource")
This page took 0.043169 seconds and 6 git commands to generate.