Skip to content

Commit e17ac02

Browse files
committed
Merge tag 'kgdb-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux
Pull kgdb updates from Daniel Thompson: "Everything for kgdb this time around is either simplifications or clean ups. In particular Douglas Anderson's modifications to the backtrace machine in the *last* dev cycle have enabled Doug to tidy up some MIPS specific backtrace code and stop sharing certain data structures across the kernel. Note that The MIPS folks were on Cc: for the MIPS patch and reacted positively (but without an explicit Acked-by). Doug also got rid of the implicit switching between tasks and register sets during some but not of kdb's backtrace actions (because the implicit switching was either confusing for users, pointless or both). Finally there is a coverity fix and patch to replace open coded console traversal with the proper helper function" * tag 'kgdb-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/danielt/linux: kdb: Use for_each_console() helper kdb: remove redundant assignment to pointer bp kdb: Get rid of confusing diag msg from "rd" if current task has no regs kdb: Gid rid of implicit setting of the current task / regs kdb: kdb_current_task shouldn't be exported kdb: kdb_current_regs should be private MIPS: kdb: Remove old workaround for backtracing on other CPUs
2 parents 754beee + dc2c733 commit e17ac02

File tree

7 files changed

+19
-39
lines changed

7 files changed

+19
-39
lines changed

arch/mips/kernel/traps.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,6 @@ void show_stack(struct task_struct *task, unsigned long *sp)
210210
regs.regs[29] = task->thread.reg29;
211211
regs.regs[31] = 0;
212212
regs.cp0_epc = task->thread.reg31;
213-
#ifdef CONFIG_KGDB_KDB
214-
} else if (atomic_read(&kgdb_active) != -1 &&
215-
kdb_current_regs) {
216-
memcpy(&regs, kdb_current_regs, sizeof(regs));
217-
#endif /* CONFIG_KGDB_KDB */
218213
} else {
219214
prepare_frametrace(&regs);
220215
}

include/linux/kdb.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ int kdb_process_cpu(const struct task_struct *p)
183183
return cpu;
184184
}
185185

186-
/* kdb access to register set for stack dumping */
187-
extern struct pt_regs *kdb_current_regs;
188186
#ifdef CONFIG_KALLSYMS
189187
extern const char *kdb_walk_kallsyms(loff_t *pos);
190188
#else /* ! CONFIG_KALLSYMS */

kernel/debug/kdb/kdb_bp.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ static int kdb_bc(int argc, const char **argv)
412412
* assume that the breakpoint number is desired.
413413
*/
414414
if (addr < KDB_MAXBPT) {
415-
bp = &kdb_breakpoints[addr];
416415
lowbp = highbp = addr;
417416
highbp++;
418417
} else {

kernel/debug/kdb/kdb_bt.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ kdb_bt_cpu(unsigned long cpu)
119119
return;
120120
}
121121

122-
kdb_set_current_task(kdb_tsk);
123122
kdb_bt1(kdb_tsk, ~0UL, false);
124123
}
125124

@@ -166,10 +165,8 @@ kdb_bt(int argc, const char **argv)
166165
if (diag)
167166
return diag;
168167
p = find_task_by_pid_ns(pid, &init_pid_ns);
169-
if (p) {
170-
kdb_set_current_task(p);
168+
if (p)
171169
return kdb_bt1(p, ~0UL, false);
172-
}
173170
kdb_printf("No process with pid == %ld found\n", pid);
174171
return 0;
175172
} else if (strcmp(argv[0], "btt") == 0) {
@@ -178,11 +175,9 @@ kdb_bt(int argc, const char **argv)
178175
diag = kdbgetularg((char *)argv[1], &addr);
179176
if (diag)
180177
return diag;
181-
kdb_set_current_task((struct task_struct *)addr);
182178
return kdb_bt1((struct task_struct *)addr, ~0UL, false);
183179
} else if (strcmp(argv[0], "btc") == 0) {
184180
unsigned long cpu = ~0;
185-
struct task_struct *save_current_task = kdb_current_task;
186181
if (argc > 1)
187182
return KDB_ARGCOUNT;
188183
if (argc == 1) {
@@ -204,7 +199,6 @@ kdb_bt(int argc, const char **argv)
204199
kdb_bt_cpu(cpu);
205200
touch_nmi_watchdog();
206201
}
207-
kdb_set_current_task(save_current_task);
208202
}
209203
return 0;
210204
} else {

kernel/debug/kdb/kdb_io.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
553553
int this_cpu, old_cpu;
554554
char *cp, *cp2, *cphold = NULL, replaced_byte = ' ';
555555
char *moreprompt = "more> ";
556-
struct console *c = console_drivers;
556+
struct console *c;
557557
unsigned long uninitialized_var(flags);
558558

559559
/* Serialize kdb_printf if multiple cpus try to write at once.
@@ -698,10 +698,9 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
698698
cp2++;
699699
}
700700
}
701-
while (c) {
701+
for_each_console(c) {
702702
c->write(c, cp, retlen - (cp - kdb_buffer));
703703
touch_nmi_watchdog();
704-
c = c->next;
705704
}
706705
}
707706
if (logging) {
@@ -752,7 +751,6 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
752751
moreprompt = "more> ";
753752

754753
kdb_input_flush();
755-
c = console_drivers;
756754

757755
if (dbg_io_ops && !dbg_io_ops->is_console) {
758756
len = strlen(moreprompt);
@@ -762,10 +760,9 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
762760
cp++;
763761
}
764762
}
765-
while (c) {
763+
for_each_console(c) {
766764
c->write(c, moreprompt, strlen(moreprompt));
767765
touch_nmi_watchdog();
768-
c = c->next;
769766
}
770767

771768
if (logging)

kernel/debug/kdb/kdb_main.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ int kdb_nextline = 1;
7373
int kdb_state; /* General KDB state */
7474

7575
struct task_struct *kdb_current_task;
76-
EXPORT_SYMBOL(kdb_current_task);
7776
struct pt_regs *kdb_current_regs;
7877

7978
const char *kdb_diemsg;
@@ -544,9 +543,8 @@ int kdbgetaddrarg(int argc, const char **argv, int *nextarg,
544543
if (diag)
545544
return diag;
546545
} else if (symname[0] == '%') {
547-
diag = kdb_check_regs();
548-
if (diag)
549-
return diag;
546+
if (kdb_check_regs())
547+
return 0;
550548
/* Implement register values with % at a later time as it is
551549
* arch optional.
552550
*/
@@ -1139,7 +1137,7 @@ static void kdb_dumpregs(struct pt_regs *regs)
11391137
console_loglevel = old_lvl;
11401138
}
11411139

1142-
void kdb_set_current_task(struct task_struct *p)
1140+
static void kdb_set_current_task(struct task_struct *p)
11431141
{
11441142
kdb_current_task = p;
11451143

@@ -1837,8 +1835,7 @@ static int kdb_go(int argc, const char **argv)
18371835
*/
18381836
static int kdb_rd(int argc, const char **argv)
18391837
{
1840-
int len = kdb_check_regs();
1841-
#if DBG_MAX_REG_NUM > 0
1838+
int len = 0;
18421839
int i;
18431840
char *rname;
18441841
int rsize;
@@ -1847,8 +1844,14 @@ static int kdb_rd(int argc, const char **argv)
18471844
u16 reg16;
18481845
u8 reg8;
18491846

1850-
if (len)
1851-
return len;
1847+
if (kdb_check_regs())
1848+
return 0;
1849+
1850+
/* Fallback to Linux showregs() if we don't have DBG_MAX_REG_NUM */
1851+
if (DBG_MAX_REG_NUM <= 0) {
1852+
kdb_dumpregs(kdb_current_regs);
1853+
return 0;
1854+
}
18521855

18531856
for (i = 0; i < DBG_MAX_REG_NUM; i++) {
18541857
rsize = dbg_reg_def[i].size * 2;
@@ -1890,12 +1893,7 @@ static int kdb_rd(int argc, const char **argv)
18901893
}
18911894
}
18921895
kdb_printf("\n");
1893-
#else
1894-
if (len)
1895-
return len;
18961896

1897-
kdb_dumpregs(kdb_current_regs);
1898-
#endif
18991897
return 0;
19001898
}
19011899

@@ -1929,9 +1927,8 @@ static int kdb_rm(int argc, const char **argv)
19291927
if (diag)
19301928
return diag;
19311929

1932-
diag = kdb_check_regs();
1933-
if (diag)
1934-
return diag;
1930+
if (kdb_check_regs())
1931+
return 0;
19351932

19361933
diag = KDB_BADREG;
19371934
for (i = 0; i < DBG_MAX_REG_NUM; i++) {

kernel/debug/kdb/kdb_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@ extern void *debug_kmalloc(size_t size, gfp_t flags);
240240
extern void debug_kfree(void *);
241241
extern void debug_kusage(void);
242242

243-
extern void kdb_set_current_task(struct task_struct *);
244243
extern struct task_struct *kdb_current_task;
244+
extern struct pt_regs *kdb_current_regs;
245245

246246
#ifdef CONFIG_KDB_KEYBOARD
247247
extern void kdb_kbd_cleanup_state(void);

0 commit comments

Comments
 (0)