Skip to contentSkip to conversation

scripts/gdb: add lx-fdtdump command

PATCH New [email protected] 1 participant 1 message Jul 12, 2017 GDB kernel debugging helper scripts

lore
Share & tools
lore
#0 lore raw

PATCH 24/96 scripts/gdb: add lx-fdtdump command

From: Peter Griffin <[email protected]>
Subject: scripts/gdb: add lx-fdtdump command

lx-fdtdump dumps the flattened device tree passed to the kernel from the bootloader to the filename specified as the command argument. If no argument is provided it defaults to fdtdump.dtb. This then allows further post processing on the machine running GDB. The fdt header is also also printed in the GDB console. For example:

(gdb) lx-fdtdump

fdt_magic:         0xD00DFEED
fdt_totalsize:     0xC108
off_dt_struct:     0x38
off_dt_strings:    0x3804
off_mem_rsvmap:    0x28
version:           17
last_comp_version: 16

Dumped fdt to fdtdump.dtb

Quoted 1 line

fdtdump fdtdump.dtb | less

This command is useful as the bootloader can often re-write parts of the device tree, and this can sometimes cause the kernel to not boot.

---

 scripts/gdb/linux/constants.py.in |    7 ++
 scripts/gdb/linux/proc.py         |   73 ++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+)
scripts/gdb/linux/constants.py.in renamed from scripts/gdb/linux/constants.py.in~scripts-gdb-add-lx-fdtdump-command +7 -0
diff -puN scripts/gdb/linux/constants.py.in~scripts-gdb-add-lx-fdtdump-command scripts/gdb/linux/constants.py.in
@@ -14,6 +14,7 @@
 
 #include <linux/fs.h>
 #include <linux/mount.h>
+#include <linux/of_fdt.h>
 
 /* We need to stringify expanded macros so that they can be parsed */
 
@@ -50,3 +51,9 @@ LX_VALUE(MNT_NOEXEC)
 LX_VALUE(MNT_NOATIME)
 LX_VALUE(MNT_NODIRATIME)
 LX_VALUE(MNT_RELATIME)
+
+/* linux/of_fdt.h> */
+LX_VALUE(OF_DT_HEADER)
+
+/* Kernel Configs */
+LX_CONFIG(CONFIG_OF)
scripts/gdb/linux/proc.py renamed from scripts/gdb/linux/proc.py~scripts-gdb-add-lx-fdtdump-command +73 -0

82 lines not on this page · raw message

_