Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for_linus-3.7' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/kgdb

Pull KGDB/KDB fixes and cleanups from Jason Wessel:
"Cleanups
- Clean up compile warnings in kgdboc.c and x86/kernel/kgdb.c
- Add module event hooks for simplified debugging with gdb
Fixes
- Fix kdb to stop paging with 'q' on bta and dmesg
- Fix for data that scrolls off the vga console due to line wrapping
when using the kdb pager
New
- The debug core registers for kernel module events which allows a
kernel aware gdb to automatically load symbols and break on entry
to a kernel module
- Allow kgdboc=kdb to setup kdb on the vga console"

* tag 'for_linus-3.7' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/kgdb:
tty/console: fix warnings in drivers/tty/serial/kgdboc.c
kdb,vt_console: Fix missed data due to pager overruns
kdb: Fix dmesg/bta scroll to quit with 'q'
kgdboc: Accept either kbd or kdb to activate the vga + keyboard kdb shell
kgdb,x86: fix warning about unused variable
mips,kgdb: fix recursive page fault with CONFIG_KPROBES
kgdb: Add module event hooks

+84 -8
+9
arch/mips/kernel/kgdb.c
··· 283 283 struct pt_regs *regs = args->regs; 284 284 int trap = (regs->cp0_cause & 0x7c) >> 2; 285 285 286 + #ifdef CONFIG_KPROBES 287 + /* 288 + * Return immediately if the kprobes fault notifier has set 289 + * DIE_PAGE_FAULT. 290 + */ 291 + if (cmd == DIE_PAGE_FAULT) 292 + return NOTIFY_DONE; 293 + #endif /* CONFIG_KPROBES */ 294 + 286 295 /* Userspace events, ignore. */ 287 296 if (user_mode(regs)) 288 297 return NOTIFY_DONE;
+2
arch/x86/kernel/kgdb.c
··· 746 746 int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt) 747 747 { 748 748 int err; 749 + #ifdef CONFIG_DEBUG_RODATA 749 750 char opc[BREAK_INSTR_SIZE]; 751 + #endif /* CONFIG_DEBUG_RODATA */ 750 752 751 753 bpt->type = BP_BREAKPOINT; 752 754 err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
+2 -1
drivers/tty/serial/kgdboc.c
··· 97 97 98 98 static int kgdboc_register_kbd(char **cptr) 99 99 { 100 - if (strncmp(*cptr, "kbd", 3) == 0) { 100 + if (strncmp(*cptr, "kbd", 3) == 0 || 101 + strncmp(*cptr, "kdb", 3) == 0) { 101 102 if (kdb_poll_idx < KDB_POLL_FUNC_MAX) { 102 103 kdb_poll_funcs[kdb_poll_idx] = kdb_get_kbd_char; 103 104 kdb_poll_idx++;
+13
drivers/tty/vt/vt.c
··· 3442 3442 kdb_set(2, setargs); 3443 3443 } 3444 3444 } 3445 + if (vc->vc_cols < 999) { 3446 + int colcount; 3447 + char cols[4]; 3448 + const char *setargs[3] = { 3449 + "set", 3450 + "COLUMNS", 3451 + cols, 3452 + }; 3453 + if (kdbgetintenv(setargs[0], &colcount)) { 3454 + snprintf(cols, 4, "%i", vc->vc_cols); 3455 + kdb_set(2, setargs); 3456 + } 3457 + } 3445 3458 #endif /* CONFIG_KGDB_KDB */ 3446 3459 return ret; 3447 3460 }
+8 -2
include/linux/console.h
··· 83 83 int con_debug_enter(struct vc_data *vc); 84 84 int con_debug_leave(void); 85 85 #else 86 - #define con_debug_enter(vc) (0) 87 - #define con_debug_leave() (0) 86 + static inline int con_debug_enter(struct vc_data *vc) 87 + { 88 + return 0; 89 + } 90 + static inline int con_debug_leave(void) 91 + { 92 + return 0; 93 + } 88 94 #endif 89 95 90 96 /* scroll */
+18
kernel/debug/debug_core.c
··· 696 696 return ret; 697 697 } 698 698 699 + /* 700 + * GDB places a breakpoint at this function to know dynamically 701 + * loaded objects. It's not defined static so that only one instance with this 702 + * name exists in the kernel. 703 + */ 704 + 705 + static int module_event(struct notifier_block *self, unsigned long val, 706 + void *data) 707 + { 708 + return 0; 709 + } 710 + 711 + static struct notifier_block dbg_module_load_nb = { 712 + .notifier_call = module_event, 713 + }; 714 + 699 715 int kgdb_nmicallback(int cpu, void *regs) 700 716 { 701 717 #ifdef CONFIG_SMP ··· 840 824 kgdb_arch_init(); 841 825 if (!dbg_is_early) 842 826 kgdb_arch_late(); 827 + register_module_notifier(&dbg_module_load_nb); 843 828 register_reboot_notifier(&dbg_reboot_notifier); 844 829 atomic_notifier_chain_register(&panic_notifier_list, 845 830 &kgdb_panic_event_nb); ··· 864 847 if (kgdb_io_module_registered) { 865 848 kgdb_io_module_registered = 0; 866 849 unregister_reboot_notifier(&dbg_reboot_notifier); 850 + unregister_module_notifier(&dbg_module_load_nb); 867 851 atomic_notifier_chain_unregister(&panic_notifier_list, 868 852 &kgdb_panic_event_nb); 869 853 kgdb_arch_exit();
+2
kernel/debug/kdb/kdb_bt.c
··· 129 129 } 130 130 /* Now the inactive tasks */ 131 131 kdb_do_each_thread(g, p) { 132 + if (KDB_FLAG(CMD_INTERRUPT)) 133 + return 0; 132 134 if (task_curr(p)) 133 135 continue; 134 136 if (kdb_bt1(p, mask, argcount, btaprompt))
+28 -5
kernel/debug/kdb/kdb_io.c
··· 552 552 { 553 553 int diag; 554 554 int linecount; 555 + int colcount; 555 556 int logging, saved_loglevel = 0; 556 557 int saved_trap_printk; 557 558 int got_printf_lock = 0; ··· 584 583 diag = kdbgetintenv("LINES", &linecount); 585 584 if (diag || linecount <= 1) 586 585 linecount = 24; 586 + 587 + diag = kdbgetintenv("COLUMNS", &colcount); 588 + if (diag || colcount <= 1) 589 + colcount = 80; 587 590 588 591 diag = kdbgetintenv("LOGGING", &logging); 589 592 if (diag) ··· 695 690 gdbstub_msg_write(kdb_buffer, retlen); 696 691 } else { 697 692 if (dbg_io_ops && !dbg_io_ops->is_console) { 698 - len = strlen(kdb_buffer); 693 + len = retlen; 699 694 cp = kdb_buffer; 700 695 while (len--) { 701 696 dbg_io_ops->write_char(*cp); ··· 714 709 printk(KERN_INFO "%s", kdb_buffer); 715 710 } 716 711 717 - if (KDB_STATE(PAGER) && strchr(kdb_buffer, '\n')) 718 - kdb_nextline++; 712 + if (KDB_STATE(PAGER)) { 713 + /* 714 + * Check printed string to decide how to bump the 715 + * kdb_nextline to control when the more prompt should 716 + * show up. 717 + */ 718 + int got = 0; 719 + len = retlen; 720 + while (len--) { 721 + if (kdb_buffer[len] == '\n') { 722 + kdb_nextline++; 723 + got = 0; 724 + } else if (kdb_buffer[len] == '\r') { 725 + got = 0; 726 + } else { 727 + got++; 728 + } 729 + } 730 + kdb_nextline += got / (colcount + 1); 731 + } 719 732 720 733 /* check for having reached the LINES number of printed lines */ 721 - if (kdb_nextline == linecount) { 734 + if (kdb_nextline >= linecount) { 722 735 char buf1[16] = ""; 723 736 724 737 /* Watch out for recursion here. Any routine that calls ··· 788 765 kdb_grepping_flag = 0; 789 766 kdb_printf("\n"); 790 767 } else if (buf1[0] == ' ') { 791 - kdb_printf("\n"); 768 + kdb_printf("\r"); 792 769 suspend_grep = 1; /* for this recursion */ 793 770 } else if (buf1[0] == '\n') { 794 771 kdb_nextline = linecount - 1;
+2
kernel/debug/kdb/kdb_main.c
··· 2101 2101 } 2102 2102 if (!lines--) 2103 2103 break; 2104 + if (KDB_FLAG(CMD_INTERRUPT)) 2105 + return 0; 2104 2106 2105 2107 kdb_printf("%.*s\n", (int)len - 1, buf); 2106 2108 }