mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
kgdb: Add module event hooks
Allow gdb to auto load kernel modules when it is attached, which makes it trivially easy to debug module init functions or pre-set breakpoints in a kernel module that has not loaded yet. Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
This commit is contained in:
@@ -688,6 +688,22 @@ kgdb_handle_exception(int evector, int signo, int ecode, struct pt_regs *regs)
|
|||||||
return kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
|
return kgdb_cpu_enter(ks, regs, DCPU_WANT_MASTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GDB places a breakpoint at this function to know dynamically
|
||||||
|
* loaded objects. It's not defined static so that only one instance with this
|
||||||
|
* name exists in the kernel.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int module_event(struct notifier_block *self, unsigned long val,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct notifier_block dbg_module_load_nb = {
|
||||||
|
.notifier_call = module_event,
|
||||||
|
};
|
||||||
|
|
||||||
int kgdb_nmicallback(int cpu, void *regs)
|
int kgdb_nmicallback(int cpu, void *regs)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
@@ -816,6 +832,7 @@ static void kgdb_register_callbacks(void)
|
|||||||
kgdb_arch_init();
|
kgdb_arch_init();
|
||||||
if (!dbg_is_early)
|
if (!dbg_is_early)
|
||||||
kgdb_arch_late();
|
kgdb_arch_late();
|
||||||
|
register_module_notifier(&dbg_module_load_nb);
|
||||||
register_reboot_notifier(&dbg_reboot_notifier);
|
register_reboot_notifier(&dbg_reboot_notifier);
|
||||||
atomic_notifier_chain_register(&panic_notifier_list,
|
atomic_notifier_chain_register(&panic_notifier_list,
|
||||||
&kgdb_panic_event_nb);
|
&kgdb_panic_event_nb);
|
||||||
@@ -839,6 +856,7 @@ static void kgdb_unregister_callbacks(void)
|
|||||||
if (kgdb_io_module_registered) {
|
if (kgdb_io_module_registered) {
|
||||||
kgdb_io_module_registered = 0;
|
kgdb_io_module_registered = 0;
|
||||||
unregister_reboot_notifier(&dbg_reboot_notifier);
|
unregister_reboot_notifier(&dbg_reboot_notifier);
|
||||||
|
unregister_module_notifier(&dbg_module_load_nb);
|
||||||
atomic_notifier_chain_unregister(&panic_notifier_list,
|
atomic_notifier_chain_unregister(&panic_notifier_list,
|
||||||
&kgdb_panic_event_nb);
|
&kgdb_panic_event_nb);
|
||||||
kgdb_arch_exit();
|
kgdb_arch_exit();
|
||||||
|
Reference in New Issue
Block a user