diff options
Diffstat (limited to 'kernel/debug/kdb/kdb_io.c')
| -rw-r--r-- | kernel/debug/kdb/kdb_io.c | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 7c70812caea5..fc1ef736253c 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c | |||
| @@ -439,7 +439,7 @@ poll_again: | |||
| 439 | * substituted for %d, %x or %o in the prompt. | 439 | * substituted for %d, %x or %o in the prompt. |
| 440 | */ | 440 | */ |
| 441 | 441 | ||
| 442 | char *kdb_getstr(char *buffer, size_t bufsize, char *prompt) | 442 | char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt) |
| 443 | { | 443 | { |
| 444 | if (prompt && kdb_prompt_str != prompt) | 444 | if (prompt && kdb_prompt_str != prompt) |
| 445 | strncpy(kdb_prompt_str, prompt, CMD_BUFLEN); | 445 | strncpy(kdb_prompt_str, prompt, CMD_BUFLEN); |
| @@ -548,7 +548,7 @@ static int kdb_search_string(char *searched, char *searchfor) | |||
| 548 | return 0; | 548 | return 0; |
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | int vkdb_printf(const char *fmt, va_list ap) | 551 | int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap) |
| 552 | { | 552 | { |
| 553 | int diag; | 553 | int diag; |
| 554 | int linecount; | 554 | int linecount; |
| @@ -680,6 +680,12 @@ int vkdb_printf(const char *fmt, va_list ap) | |||
| 680 | size_avail = sizeof(kdb_buffer) - len; | 680 | size_avail = sizeof(kdb_buffer) - len; |
| 681 | goto kdb_print_out; | 681 | goto kdb_print_out; |
| 682 | } | 682 | } |
| 683 | if (kdb_grepping_flag >= KDB_GREPPING_FLAG_SEARCH) | ||
| 684 | /* | ||
| 685 | * This was a interactive search (using '/' at more | ||
| 686 | * prompt) and it has completed. Clear the flag. | ||
| 687 | */ | ||
| 688 | kdb_grepping_flag = 0; | ||
| 683 | /* | 689 | /* |
| 684 | * at this point the string is a full line and | 690 | * at this point the string is a full line and |
| 685 | * should be printed, up to the null. | 691 | * should be printed, up to the null. |
| @@ -691,19 +697,20 @@ kdb_printit: | |||
| 691 | * Write to all consoles. | 697 | * Write to all consoles. |
| 692 | */ | 698 | */ |
| 693 | retlen = strlen(kdb_buffer); | 699 | retlen = strlen(kdb_buffer); |
| 700 | cp = (char *) printk_skip_level(kdb_buffer); | ||
| 694 | if (!dbg_kdb_mode && kgdb_connected) { | 701 | if (!dbg_kdb_mode && kgdb_connected) { |
| 695 | gdbstub_msg_write(kdb_buffer, retlen); | 702 | gdbstub_msg_write(cp, retlen - (cp - kdb_buffer)); |
| 696 | } else { | 703 | } else { |
| 697 | if (dbg_io_ops && !dbg_io_ops->is_console) { | 704 | if (dbg_io_ops && !dbg_io_ops->is_console) { |
| 698 | len = retlen; | 705 | len = retlen - (cp - kdb_buffer); |
| 699 | cp = kdb_buffer; | 706 | cp2 = cp; |
| 700 | while (len--) { | 707 | while (len--) { |
| 701 | dbg_io_ops->write_char(*cp); | 708 | dbg_io_ops->write_char(*cp2); |
| 702 | cp++; | 709 | cp2++; |
| 703 | } | 710 | } |
| 704 | } | 711 | } |
| 705 | while (c) { | 712 | while (c) { |
| 706 | c->write(c, kdb_buffer, retlen); | 713 | c->write(c, cp, retlen - (cp - kdb_buffer)); |
| 707 | touch_nmi_watchdog(); | 714 | touch_nmi_watchdog(); |
| 708 | c = c->next; | 715 | c = c->next; |
| 709 | } | 716 | } |
| @@ -711,7 +718,10 @@ kdb_printit: | |||
| 711 | if (logging) { | 718 | if (logging) { |
| 712 | saved_loglevel = console_loglevel; | 719 | saved_loglevel = console_loglevel; |
| 713 | console_loglevel = CONSOLE_LOGLEVEL_SILENT; | 720 | console_loglevel = CONSOLE_LOGLEVEL_SILENT; |
| 714 | printk(KERN_INFO "%s", kdb_buffer); | 721 | if (printk_get_level(kdb_buffer) || src == KDB_MSGSRC_PRINTK) |
| 722 | printk("%s", kdb_buffer); | ||
| 723 | else | ||
| 724 | pr_info("%s", kdb_buffer); | ||
| 715 | } | 725 | } |
| 716 | 726 | ||
| 717 | if (KDB_STATE(PAGER)) { | 727 | if (KDB_STATE(PAGER)) { |
| @@ -794,11 +804,23 @@ kdb_printit: | |||
| 794 | kdb_nextline = linecount - 1; | 804 | kdb_nextline = linecount - 1; |
| 795 | kdb_printf("\r"); | 805 | kdb_printf("\r"); |
| 796 | suspend_grep = 1; /* for this recursion */ | 806 | suspend_grep = 1; /* for this recursion */ |
| 807 | } else if (buf1[0] == '/' && !kdb_grepping_flag) { | ||
| 808 | kdb_printf("\r"); | ||
| 809 | kdb_getstr(kdb_grep_string, KDB_GREP_STRLEN, | ||
| 810 | kdbgetenv("SEARCHPROMPT") ?: "search> "); | ||
| 811 | *strchrnul(kdb_grep_string, '\n') = '\0'; | ||
| 812 | kdb_grepping_flag += KDB_GREPPING_FLAG_SEARCH; | ||
| 813 | suspend_grep = 1; /* for this recursion */ | ||
| 797 | } else if (buf1[0] && buf1[0] != '\n') { | 814 | } else if (buf1[0] && buf1[0] != '\n') { |
| 798 | /* user hit something other than enter */ | 815 | /* user hit something other than enter */ |
| 799 | suspend_grep = 1; /* for this recursion */ | 816 | suspend_grep = 1; /* for this recursion */ |
| 800 | kdb_printf("\nOnly 'q' or 'Q' are processed at more " | 817 | if (buf1[0] != '/') |
| 801 | "prompt, input ignored\n"); | 818 | kdb_printf( |
| 819 | "\nOnly 'q', 'Q' or '/' are processed at " | ||
| 820 | "more prompt, input ignored\n"); | ||
| 821 | else | ||
| 822 | kdb_printf("\n'/' cannot be used during | " | ||
| 823 | "grep filtering, input ignored\n"); | ||
| 802 | } else if (kdb_grepping_flag) { | 824 | } else if (kdb_grepping_flag) { |
| 803 | /* user hit enter */ | 825 | /* user hit enter */ |
| 804 | suspend_grep = 1; /* for this recursion */ | 826 | suspend_grep = 1; /* for this recursion */ |
| @@ -844,7 +866,7 @@ int kdb_printf(const char *fmt, ...) | |||
| 844 | int r; | 866 | int r; |
| 845 | 867 | ||
| 846 | va_start(ap, fmt); | 868 | va_start(ap, fmt); |
| 847 | r = vkdb_printf(fmt, ap); | 869 | r = vkdb_printf(KDB_MSGSRC_INTERNAL, fmt, ap); |
| 848 | va_end(ap); | 870 | va_end(ap); |
| 849 | 871 | ||
| 850 | return r; | 872 | return r; |
