diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-03-02 11:31:39 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-03-02 11:31:39 -0500 |
| commit | 3cfb07743a5bffecba83f0da26444e85c0a9bfbb (patch) | |
| tree | c27f27a8d8f4bad9eed265cf0894d2ce8f058b1d /kernel/debug | |
| parent | e23b62256a361611cbd45cd1456638f1a5106b5c (diff) | |
| parent | 36dfea42cc35509b481377980338cc3b89d79256 (diff) | |
Merge tag 'for_linux-3.9' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/kgdb
Pull KGDB/KDB fixes and cleanups from Jason Wessel:
"For a change we removed more code than we added. If people aren't
using it we shouldn't be carrying it. :-)
Cleanups:
- Remove kdb ssb command - there is no in kernel disassembler to
support it
- Remove kdb ll command - Always caused a kernel oops and there were
no bug reports so no one was using this command
- Use kernel ARRAY_SIZE macro instead of array computations
Fixes:
- Stop oops in kdb if user executes kdb_defcmd with args
- kdb help command truncated text
- ppc64 support for kgdbts
- Add missing kconfig option from original kdb port for dealing with
catastrophic kernel crashes such that you can reboot automatically
on continue from kdb"
* tag 'for_linux-3.9' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/kgdb:
kdb: Remove unhandled ssb command
kdb: Prevent kernel oops with kdb_defcmd
kdb: Remove the ll command
kdb_main: fix help print
kdb: Fix overlap in buffers with strcpy
Fixed dead ifdef block by adding missing Kconfig option.
kdb: Setup basic kdb state before invoking commands via kgdb
kdb: use ARRAY_SIZE where possible
kgdb/kgdbts: support ppc64
kdb: A fix for kdb command table expansion
Diffstat (limited to 'kernel/debug')
| -rw-r--r-- | kernel/debug/debug_core.h | 2 | ||||
| -rw-r--r-- | kernel/debug/gdbstub.c | 3 | ||||
| -rw-r--r-- | kernel/debug/kdb/kdb_bp.c | 20 | ||||
| -rw-r--r-- | kernel/debug/kdb/kdb_debugger.c | 25 | ||||
| -rw-r--r-- | kernel/debug/kdb/kdb_main.c | 135 | ||||
| -rw-r--r-- | kernel/debug/kdb/kdb_private.h | 4 |
6 files changed, 62 insertions, 127 deletions
diff --git a/kernel/debug/debug_core.h b/kernel/debug/debug_core.h index 3494c28a7e7a..2235967e78b0 100644 --- a/kernel/debug/debug_core.h +++ b/kernel/debug/debug_core.h | |||
| @@ -72,6 +72,8 @@ extern int dbg_kdb_mode; | |||
| 72 | #ifdef CONFIG_KGDB_KDB | 72 | #ifdef CONFIG_KGDB_KDB |
| 73 | extern int kdb_stub(struct kgdb_state *ks); | 73 | extern int kdb_stub(struct kgdb_state *ks); |
| 74 | extern int kdb_parse(const char *cmdstr); | 74 | extern int kdb_parse(const char *cmdstr); |
| 75 | extern int kdb_common_init_state(struct kgdb_state *ks); | ||
| 76 | extern int kdb_common_deinit_state(void); | ||
| 75 | #else /* ! CONFIG_KGDB_KDB */ | 77 | #else /* ! CONFIG_KGDB_KDB */ |
| 76 | static inline int kdb_stub(struct kgdb_state *ks) | 78 | static inline int kdb_stub(struct kgdb_state *ks) |
| 77 | { | 79 | { |
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c index 38573f35a5ad..19d9a578c753 100644 --- a/kernel/debug/gdbstub.c +++ b/kernel/debug/gdbstub.c | |||
| @@ -783,7 +783,10 @@ static void gdb_cmd_query(struct kgdb_state *ks) | |||
| 783 | len = len / 2; | 783 | len = len / 2; |
| 784 | remcom_out_buffer[len++] = 0; | 784 | remcom_out_buffer[len++] = 0; |
| 785 | 785 | ||
| 786 | kdb_common_init_state(ks); | ||
| 786 | kdb_parse(remcom_out_buffer); | 787 | kdb_parse(remcom_out_buffer); |
| 788 | kdb_common_deinit_state(); | ||
| 789 | |||
| 787 | strcpy(remcom_out_buffer, "OK"); | 790 | strcpy(remcom_out_buffer, "OK"); |
| 788 | } | 791 | } |
| 789 | break; | 792 | break; |
diff --git a/kernel/debug/kdb/kdb_bp.c b/kernel/debug/kdb/kdb_bp.c index 8418c2f8ec5d..70a504601dc3 100644 --- a/kernel/debug/kdb/kdb_bp.c +++ b/kernel/debug/kdb/kdb_bp.c | |||
| @@ -486,11 +486,9 @@ static int kdb_bc(int argc, const char **argv) | |||
| 486 | /* | 486 | /* |
| 487 | * kdb_ss | 487 | * kdb_ss |
| 488 | * | 488 | * |
| 489 | * Process the 'ss' (Single Step) and 'ssb' (Single Step to Branch) | 489 | * Process the 'ss' (Single Step) command. |
| 490 | * commands. | ||
| 491 | * | 490 | * |
| 492 | * ss | 491 | * ss |
| 493 | * ssb | ||
| 494 | * | 492 | * |
| 495 | * Parameters: | 493 | * Parameters: |
| 496 | * argc Argument count | 494 | * argc Argument count |
| @@ -498,35 +496,23 @@ static int kdb_bc(int argc, const char **argv) | |||
| 498 | * Outputs: | 496 | * Outputs: |
| 499 | * None. | 497 | * None. |
| 500 | * Returns: | 498 | * Returns: |
| 501 | * KDB_CMD_SS[B] for success, a kdb error if failure. | 499 | * KDB_CMD_SS for success, a kdb error if failure. |
| 502 | * Locking: | 500 | * Locking: |
| 503 | * None. | 501 | * None. |
| 504 | * Remarks: | 502 | * Remarks: |
| 505 | * | 503 | * |
| 506 | * Set the arch specific option to trigger a debug trap after the next | 504 | * Set the arch specific option to trigger a debug trap after the next |
| 507 | * instruction. | 505 | * instruction. |
| 508 | * | ||
| 509 | * For 'ssb', set the trace flag in the debug trap handler | ||
| 510 | * after printing the current insn and return directly without | ||
| 511 | * invoking the kdb command processor, until a branch instruction | ||
| 512 | * is encountered. | ||
| 513 | */ | 506 | */ |
| 514 | 507 | ||
| 515 | static int kdb_ss(int argc, const char **argv) | 508 | static int kdb_ss(int argc, const char **argv) |
| 516 | { | 509 | { |
| 517 | int ssb = 0; | ||
| 518 | |||
| 519 | ssb = (strcmp(argv[0], "ssb") == 0); | ||
| 520 | if (argc != 0) | 510 | if (argc != 0) |
| 521 | return KDB_ARGCOUNT; | 511 | return KDB_ARGCOUNT; |
| 522 | /* | 512 | /* |
| 523 | * Set trace flag and go. | 513 | * Set trace flag and go. |
| 524 | */ | 514 | */ |
| 525 | KDB_STATE_SET(DOING_SS); | 515 | KDB_STATE_SET(DOING_SS); |
| 526 | if (ssb) { | ||
| 527 | KDB_STATE_SET(DOING_SSB); | ||
| 528 | return KDB_CMD_SSB; | ||
| 529 | } | ||
| 530 | return KDB_CMD_SS; | 516 | return KDB_CMD_SS; |
| 531 | } | 517 | } |
| 532 | 518 | ||
| @@ -561,8 +547,6 @@ void __init kdb_initbptab(void) | |||
| 561 | 547 | ||
| 562 | kdb_register_repeat("ss", kdb_ss, "", | 548 | kdb_register_repeat("ss", kdb_ss, "", |
| 563 | "Single Step", 1, KDB_REPEAT_NO_ARGS); | 549 | "Single Step", 1, KDB_REPEAT_NO_ARGS); |
| 564 | kdb_register_repeat("ssb", kdb_ss, "", | ||
| 565 | "Single step to branch/call", 0, KDB_REPEAT_NO_ARGS); | ||
| 566 | /* | 550 | /* |
| 567 | * Architecture dependent initialization. | 551 | * Architecture dependent initialization. |
| 568 | */ | 552 | */ |
diff --git a/kernel/debug/kdb/kdb_debugger.c b/kernel/debug/kdb/kdb_debugger.c index be7b33b73d30..328d18ef31e4 100644 --- a/kernel/debug/kdb/kdb_debugger.c +++ b/kernel/debug/kdb/kdb_debugger.c | |||
| @@ -34,6 +34,22 @@ EXPORT_SYMBOL_GPL(kdb_poll_idx); | |||
| 34 | 34 | ||
| 35 | static struct kgdb_state *kdb_ks; | 35 | static struct kgdb_state *kdb_ks; |
| 36 | 36 | ||
| 37 | int kdb_common_init_state(struct kgdb_state *ks) | ||
| 38 | { | ||
| 39 | kdb_initial_cpu = atomic_read(&kgdb_active); | ||
| 40 | kdb_current_task = kgdb_info[ks->cpu].task; | ||
| 41 | kdb_current_regs = kgdb_info[ks->cpu].debuggerinfo; | ||
| 42 | return 0; | ||
| 43 | } | ||
| 44 | |||
| 45 | int kdb_common_deinit_state(void) | ||
| 46 | { | ||
| 47 | kdb_initial_cpu = -1; | ||
| 48 | kdb_current_task = NULL; | ||
| 49 | kdb_current_regs = NULL; | ||
| 50 | return 0; | ||
| 51 | } | ||
| 52 | |||
| 37 | int kdb_stub(struct kgdb_state *ks) | 53 | int kdb_stub(struct kgdb_state *ks) |
| 38 | { | 54 | { |
| 39 | int error = 0; | 55 | int error = 0; |
| @@ -94,13 +110,10 @@ int kdb_stub(struct kgdb_state *ks) | |||
| 94 | } | 110 | } |
| 95 | /* Set initial kdb state variables */ | 111 | /* Set initial kdb state variables */ |
| 96 | KDB_STATE_CLEAR(KGDB_TRANS); | 112 | KDB_STATE_CLEAR(KGDB_TRANS); |
| 97 | kdb_initial_cpu = atomic_read(&kgdb_active); | 113 | kdb_common_init_state(ks); |
| 98 | kdb_current_task = kgdb_info[ks->cpu].task; | ||
| 99 | kdb_current_regs = kgdb_info[ks->cpu].debuggerinfo; | ||
| 100 | /* Remove any breakpoints as needed by kdb and clear single step */ | 114 | /* Remove any breakpoints as needed by kdb and clear single step */ |
| 101 | kdb_bp_remove(); | 115 | kdb_bp_remove(); |
| 102 | KDB_STATE_CLEAR(DOING_SS); | 116 | KDB_STATE_CLEAR(DOING_SS); |
| 103 | KDB_STATE_CLEAR(DOING_SSB); | ||
| 104 | KDB_STATE_SET(PAGER); | 117 | KDB_STATE_SET(PAGER); |
| 105 | /* zero out any offline cpu data */ | 118 | /* zero out any offline cpu data */ |
| 106 | for_each_present_cpu(i) { | 119 | for_each_present_cpu(i) { |
| @@ -125,9 +138,7 @@ int kdb_stub(struct kgdb_state *ks) | |||
| 125 | * Upon exit from the kdb main loop setup break points and restart | 138 | * Upon exit from the kdb main loop setup break points and restart |
| 126 | * the system based on the requested continue state | 139 | * the system based on the requested continue state |
| 127 | */ | 140 | */ |
| 128 | kdb_initial_cpu = -1; | 141 | kdb_common_deinit_state(); |
| 129 | kdb_current_task = NULL; | ||
| 130 | kdb_current_regs = NULL; | ||
| 131 | KDB_STATE_CLEAR(PAGER); | 142 | KDB_STATE_CLEAR(PAGER); |
| 132 | kdbnearsym_cleanup(); | 143 | kdbnearsym_cleanup(); |
| 133 | if (error == KDB_CMD_KGDB) { | 144 | if (error == KDB_CMD_KGDB) { |
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index 8875254120b6..00eb8f7fbf41 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c | |||
| @@ -124,7 +124,7 @@ static kdbmsg_t kdbmsgs[] = { | |||
| 124 | }; | 124 | }; |
| 125 | #undef KDBMSG | 125 | #undef KDBMSG |
| 126 | 126 | ||
| 127 | static const int __nkdb_err = sizeof(kdbmsgs) / sizeof(kdbmsg_t); | 127 | static const int __nkdb_err = ARRAY_SIZE(kdbmsgs); |
| 128 | 128 | ||
| 129 | 129 | ||
| 130 | /* | 130 | /* |
| @@ -175,7 +175,7 @@ static char *__env[] = { | |||
| 175 | (char *)0, | 175 | (char *)0, |
| 176 | }; | 176 | }; |
