[Kgdb-bugreport] [PATCH] module debugging with more realistic kernel names
Status: Beta
Brought to you by:
jwessel
From: Tim B. <tr...@ph...> - 2007-07-03 01:05:46
|
The kgdb module notification patch (kgdbmod) expects the kernel to be called "vmlinux". This is often not the case (e.g. vmlinux-2.6.21.1). When invoked on a kernel that does not match vmlinux, gdb does not complain, and debugs the kernel almost as normal, except that it does not notice any kernel modules. When gdb is run under xemacs, if the target filename is a symlink, xemacs will helpfully dereference the link, so that M-x gdb vmlinux ends up with gdb seeing vmlinux-2.6.21.1 and consequently failing to notice kernel modules. The patch fixes this by only requiring a partial match against the given string (e.g. "vmlinux"), so that vmlinux-2.6.16 etc. will match okay. Tim Index: gdb-6.4-kgdbmod/gdb/defs.h =================================================================== --- gdb-6.4-kgdbmod.orig/gdb/defs.h +++ gdb-6.4-kgdbmod/gdb/defs.h @@ -1217,4 +1217,6 @@ extern int use_windows; extern ULONGEST align_up (ULONGEST v, int n); extern ULONGEST align_down (ULONGEST v, int n); +#define LINUX_KERNEL_NAME_STEM "vmlinux" + #endif /* #ifndef DEFS_H */ Index: gdb-6.4-kgdbmod/gdb/symfile.c =================================================================== --- gdb-6.4-kgdbmod.orig/gdb/symfile.c +++ gdb-6.4-kgdbmod/gdb/symfile.c @@ -869,7 +869,8 @@ new_symfile_objfile (struct objfile *obj filename = symfile_objfile->name; while (dir = strchr(filename, '/')) filename = dir + 1; - if (!strcmp(filename, "vmlinux")) + /* only require the given characters to match, so that longer filenames will still match */ + if (!strncmp(filename, LINUX_KERNEL_NAME_STEM, strlen(LINUX_KERNEL_NAME_STEM))) { sym = lookup_symbol ("start_kernel", NULL, VAR_DOMAIN, NULL, NULL); if (sym) |