Skip to contentSkip to conversation

tool and script help GDB load Linux kernel modules (tool)

PATCH New Hui Zhu 1 participant 1 message Dec 21, 2013

lore
Share & tools
lore

Hui Zhu

author
#0 lore raw

PATCH 1/2 tool and script help GDB load Linux kernel modules (tool)

getmod a application of KGTP (https://kgtp.googlecode.com).

It can get Linux Kernel modules info from sysfs and output them as GDB command add-symbol-file format. Then you can call "source output_file_name" inside GDB to let it load all the debug info of Linux Kernel modules. It will help debug Linux Kernel modules with GDB with gdbstub such as KGTP, KGDB, QEMU.

It was written by C and built with -static make it friendly to the embedded system.
Following part is the help info of getmod:
Usage: ./getmod [option]
-s dir Add dir to module search directory list.
This options can use more than once.
-S Add /lib/modules/3.2.0-57-generic/kernel to module search directory list.
-r dir Add dir to replace the directory.
This options can use more than once.
-n No search the directory of the module
file directory.
-h Display this information.

---

tools/Makefile +5 -3
@@ -16,6 +16,7 @@ help:
 	@echo '  vm         - misc vm tools'
 	@echo '  x86_energy_perf_policy - Intel energy policy tool'
 	@echo '  tmon       - thermal monitoring and tuning tool'
+	@echo '  getmod     - Output LKM info in GDB add-symbol-file format.'
 	@echo ''
 	@echo 'You can do:'
 	@echo ' $$ make -C tools/ <tool>_install'
@@ -36,7 +37,7 @@ help:
 cpupower: FORCE
 	$(call descend,power/$@)
 
-cgroup firewire guest usb virtio vm net: FORCE
+cgroup firewire guest usb virtio vm net getmod: FORCE
 	$(call descend,$@)
 
 liblk: FORCE
@@ -77,7 +78,7 @@ install: cgroup_install cpupower_install
 cpupower_clean:
 	$(call descend,power/cpupower,clean)
 
-cgroup_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean net_clean:
+cgroup_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean net_clean getmod_clean:
 	$(call descend,$(@:_clean=),clean)
 
 liblk_clean:
@@ -97,6 +98,7 @@ tmon_clean:
 
 clean: cgroup_clean cpupower_clean firewire_clean lguest_clean perf_clean \
 		selftests_clean turbostat_clean usb_clean virtio_clean \
-		vm_clean net_clean x86_energy_perf_policy_clean tmon_clean
+		vm_clean net_clean x86_energy_perf_policy_clean tmon_clean \
+		getmod_clean
 
 .PHONY: FORCE
tools/getmod/Makefile new file +11 -0
@@ -0,0 +1,11 @@
+prefix = /usr
+
+all : getmod
+
+getmod : CFLAGS = -Wall -O2 -static
+
+clean :
+	rm -rf getmod
+
+install :
+	install getmod $(prefix)/sbin/
tools/getmod/getmod.c new file +407 -0

407 lines not on this page · raw message