Skip to content

Add gdb python scripts as kernel debugging helpers

Jan Kiszka linux-ia64 linux-kbuild lkml sparclinux 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest13 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13scripts/gdb: Add infrastructureMakefile scripts/Makefile scripts/gdb/Makefile +1 more+36 -20 replies
2/13scripts/gdb: Add container_of helper and convenience functionscripts/gdb/utils.py scripts/gdb/vmlinux-gdb.py+57 -00 replies
3/13scripts/gdb: Add lx-symbols commandscripts/gdb/symbols.py scripts/gdb/vmlinux-gdb.py+89 -00 replies
4/13scripts/gdb: Add get_target_endianness helperscripts/gdb/utils.py+17 -00 replies
5/13scripts/gdb: Add read_u16/32/64 helpersscripts/gdb/utils.py+18 -00 replies
6/13scripts/gdb: Add lx-dmesg commandscripts/gdb/dmesg.py scripts/gdb/vmlinux-gdb.py+64 -02 replies
7/13scripts/gdb: Add task iteration helperscripts/gdb/task.py+40 -00 replies
8/13scripts/gdb: Add helper and convenience function to look up tasksscripts/gdb/task.py scripts/gdb/vmlinux-gdb.py+30 -00 replies
9/13scripts/gdb: Add is_target_arch helperscripts/gdb/utils.py+9 -00 replies
10/13scripts/gdb: Add internal helper and convenience function to retrieve thread_infoscripts/gdb/task.py+39 -00 replies
11/13scripts/gdb: Add get_gdbserver_type helperscripts/gdb/utils.py+35 -00 replies
12/13scripts/gdb: Add internal helper and convenience function for per-cpu lookupscripts/gdb/percpu.py scripts/gdb/vmlinux-gdb.py+62 -00 replies
13/13scripts/gdb: Add lx_current convenience functionscripts/gdb/percpu.py+15 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/13] Add gdb python scripts as kernel debugging helpers

I'm sitting too long on this stuff, time to finally role it out:

This adds the infrastructure and first tools that make kernel debugging through gdb more comfortable. Since 7.0, gdb supports python scripting. And this opens the doors to automate steps like the tedious loading of module symbols at the right address, resolving per-cpu variables or even retrieving the current kernel log without resuming an stopped target.

Many of the helpers naturally depend on the layout of structures or internal mechanics of the kernel. So the best place to maintain such things, keeping them consistent with the corresponding kernel is, well, the kernel itself.

While these scripts have been originally developed for debugging via QEMU/KVM, I've now also added the required bits for KGDB. Works fine, but as QEMU/KVM tends to outperform KGDB it remains the recommendation
- when available.

There are two architecture dependencies so far, one regarding per-cpu, the other regarding thread_info calculation. None of them I was able to test on a target, so I'm counting on review/testing by the corresponding communities.

This series should be considered the foundation of much more kernel state exploration helper, e.g. around tasks, timers, locks, sockets - I guess people will have even more ideas.

Hope it's useful!

PS: Also available via git://git.kiszka.org/linux.git queues/gdb-scripts

CC "David S. Miller" <[email protected]>
CC Fenghua Yu <[email protected]>
CC Kay Sievers <[email protected]>
CC Michal Marek <[email protected]>
CC Tony Luck <[email protected]>

Jan Kiszka (13):
scripts/gdb: Add infrastructure
scripts/gdb: Add container_of helper and convenience function scripts/gdb: Add lx-symbols command
scripts/gdb: Add get_target_endianness helper
scripts/gdb: Add read_u16/32/64 helpers
scripts/gdb: Add lx-dmesg command
scripts/gdb: Add task iteration helper
scripts/gdb: Add helper and convenience function to look up tasks scripts/gdb: Add is_target_arch helper
scripts/gdb: Add internal helper and convenience function to retrieve
thread_info
scripts/gdb: Add get_gdbserver_type helper
scripts/gdb: Add internal helper and convenience function for per-cpu
lookup
scripts/gdb: Add lx_current convenience function

 Makefile                   |    6 ++-
 scripts/Makefile           |    3 +-
 scripts/gdb/Makefile       |    9 +++
 scripts/gdb/dmesg.py       |   63 +++++++++++++++++++++
 scripts/gdb/percpu.py      |   76 +++++++++++++++++++++++++
 scripts/gdb/symbols.py     |   88 +++++++++++++++++++++++++++++
 scripts/gdb/task.py        |  108 +++++++++++++++++++++++++++++++++++
 scripts/gdb/utils.py       |  134 ++++++++++++++++++++++++++++++++++++++++++++
 scripts/gdb/vmlinux-gdb.py |   26 +++++++++
 9 files changed, 511 insertions(+), 2 deletions(-)
 create mode 100644 scripts/gdb/Makefile
 create mode 100644 scripts/gdb/dmesg.py
 create mode 100644 scripts/gdb/percpu.py
 create mode 100644 scripts/gdb/symbols.py
 create mode 100644 scripts/gdb/task.py
 create mode 100644 scripts/gdb/utils.py
 create mode 100644 scripts/gdb/vmlinux-gdb.py
Signature · 1 line
1.7.3.4