Skip to content

Instantly share code, notes, and snippets.

@ryao
Created March 3, 2015 16:22
Show Gist options
  • Save ryao/22d8d4367a2006be3d65 to your computer and use it in GitHub Desktop.
Save ryao/22d8d4367a2006be3d65 to your computer and use it in GitHub Desktop.
GDB command for loading kernel module symbols from sudo -i chroot /guest/gentoo /usr/bin/gdb /usr/src/linux/vmlinux
define lx-add-module-symbols
set $current = modules.next
set $offset = ((int)&((struct module *)0).list)
while($current.next != modules.next)
eval "python from subprocess import check_output; info = check_output(\"modinfo -k %s -n %s\", shell=True).strip().decode(\"ascii\"); gdb.execute('add-symbol-file ' + info + ' %p' )\n", \
init_uts_ns.name.release, \
((struct module *) (((void *) ($current)) - $offset ) )->name ,\
((struct module *) (((void *) ($current)) - $offset ) )->module_core
set $current = $current.next
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment