Skip to content

Commit

Permalink
Merge tag 'kgdb-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
Linus Torvalds committed Feb 3, 2020
2 parents 754beee + dc2c733 commit e17ac02
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 39 deletions.
5 changes: 0 additions & 5 deletions arch/mips/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,6 @@ void show_stack(struct task_struct *task, unsigned long *sp)
regs.regs[29] = task->thread.reg29;
regs.regs[31] = 0;
regs.cp0_epc = task->thread.reg31;
#ifdef CONFIG_KGDB_KDB
} else if (atomic_read(&kgdb_active) != -1 &&
kdb_current_regs) {
memcpy(&regs, kdb_current_regs, sizeof(regs));
#endif /* CONFIG_KGDB_KDB */
} else {
prepare_frametrace(&regs);
}
Expand Down
2 changes: 0 additions & 2 deletions include/linux/kdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ int kdb_process_cpu(const struct task_struct *p)
return cpu;
}

/* kdb access to register set for stack dumping */
extern struct pt_regs *kdb_current_regs;
#ifdef CONFIG_KALLSYMS
extern const char *kdb_walk_kallsyms(loff_t *pos);
#else /* ! CONFIG_KALLSYMS */
Expand Down
1 change: 0 additions & 1 deletion kernel/debug/kdb/kdb_bp.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,6 @@ static int kdb_bc(int argc, const char **argv)
* assume that the breakpoint number is desired.
*/
if (addr < KDB_MAXBPT) {
bp = &kdb_breakpoints[addr];
lowbp = highbp = addr;
highbp++;
} else {
Expand Down
8 changes: 1 addition & 7 deletions kernel/debug/kdb/kdb_bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ kdb_bt_cpu(unsigned long cpu)
return;
}

kdb_set_current_task(kdb_tsk);
kdb_bt1(kdb_tsk, ~0UL, false);
}

Expand Down Expand Up @@ -166,10 +165,8 @@ kdb_bt(int argc, const char **argv)
if (diag)
return diag;
p = find_task_by_pid_ns(pid, &init_pid_ns);
if (p) {
kdb_set_current_task(p);
if (p)
return kdb_bt1(p, ~0UL, false);
}
kdb_printf("No process with pid == %ld found\n", pid);
return 0;
} else if (strcmp(argv[0], "btt") == 0) {
Expand All @@ -178,11 +175,9 @@ kdb_bt(int argc, const char **argv)
diag = kdbgetularg((char *)argv[1], &addr);
if (diag)
return diag;
kdb_set_current_task((struct task_struct *)addr);
return kdb_bt1((struct task_struct *)addr, ~0UL, false);
} else if (strcmp(argv[0], "btc") == 0) {
unsigned long cpu = ~0;
struct task_struct *save_current_task = kdb_current_task;
if (argc > 1)
return KDB_ARGCOUNT;
if (argc == 1) {
Expand All @@ -204,7 +199,6 @@ kdb_bt(int argc, const char **argv)
kdb_bt_cpu(cpu);
touch_nmi_watchdog();
}
kdb_set_current_task(save_current_task);
}
return 0;
} else {
Expand Down
9 changes: 3 additions & 6 deletions kernel/debug/kdb/kdb_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
int this_cpu, old_cpu;
char *cp, *cp2, *cphold = NULL, replaced_byte = ' ';
char *moreprompt = "more> ";
struct console *c = console_drivers;
struct console *c;
unsigned long uninitialized_var(flags);

/* Serialize kdb_printf if multiple cpus try to write at once.
Expand Down Expand Up @@ -698,10 +698,9 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
cp2++;
}
}
while (c) {
for_each_console(c) {
c->write(c, cp, retlen - (cp - kdb_buffer));
touch_nmi_watchdog();
c = c->next;
}
}
if (logging) {
Expand Down Expand Up @@ -752,7 +751,6 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
moreprompt = "more> ";

kdb_input_flush();
c = console_drivers;

if (dbg_io_ops && !dbg_io_ops->is_console) {
len = strlen(moreprompt);
Expand All @@ -762,10 +760,9 @@ int vkdb_printf(enum kdb_msgsrc src, const char *fmt, va_list ap)
cp++;
}
}
while (c) {
for_each_console(c) {
c->write(c, moreprompt, strlen(moreprompt));
touch_nmi_watchdog();
c = c->next;
}

if (logging)
Expand Down
31 changes: 14 additions & 17 deletions kernel/debug/kdb/kdb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ int kdb_nextline = 1;
int kdb_state; /* General KDB state */

struct task_struct *kdb_current_task;
EXPORT_SYMBOL(kdb_current_task);
struct pt_regs *kdb_current_regs;

const char *kdb_diemsg;
Expand Down Expand Up @@ -544,9 +543,8 @@ int kdbgetaddrarg(int argc, const char **argv, int *nextarg,
if (diag)
return diag;
} else if (symname[0] == '%') {
diag = kdb_check_regs();
if (diag)
return diag;
if (kdb_check_regs())
return 0;
/* Implement register values with % at a later time as it is
* arch optional.
*/
Expand Down Expand Up @@ -1139,7 +1137,7 @@ static void kdb_dumpregs(struct pt_regs *regs)
console_loglevel = old_lvl;
}

void kdb_set_current_task(struct task_struct *p)
static void kdb_set_current_task(struct task_struct *p)
{
kdb_current_task = p;

Expand Down Expand Up @@ -1837,8 +1835,7 @@ static int kdb_go(int argc, const char **argv)
*/
static int kdb_rd(int argc, const char **argv)
{
int len = kdb_check_regs();
#if DBG_MAX_REG_NUM > 0
int len = 0;
int i;
char *rname;
int rsize;
Expand All @@ -1847,8 +1844,14 @@ static int kdb_rd(int argc, const char **argv)
u16 reg16;
u8 reg8;

if (len)
return len;
if (kdb_check_regs())
return 0;

/* Fallback to Linux showregs() if we don't have DBG_MAX_REG_NUM */
if (DBG_MAX_REG_NUM <= 0) {
kdb_dumpregs(kdb_current_regs);
return 0;
}

for (i = 0; i < DBG_MAX_REG_NUM; i++) {
rsize = dbg_reg_def[i].size * 2;
Expand Down Expand Up @@ -1890,12 +1893,7 @@ static int kdb_rd(int argc, const char **argv)
}
}
kdb_printf("\n");
#else
if (len)
return len;

kdb_dumpregs(kdb_current_regs);
#endif
return 0;
}

Expand Down Expand Up @@ -1929,9 +1927,8 @@ static int kdb_rm(int argc, const char **argv)
if (diag)
return diag;

diag = kdb_check_regs();
if (diag)
return diag;
if (kdb_check_regs())
return 0;

diag = KDB_BADREG;
for (i = 0; i < DBG_MAX_REG_NUM; i++) {
Expand Down
2 changes: 1 addition & 1 deletion kernel/debug/kdb/kdb_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ extern void *debug_kmalloc(size_t size, gfp_t flags);
extern void debug_kfree(void *);
extern void debug_kusage(void);

extern void kdb_set_current_task(struct task_struct *);
extern struct task_struct *kdb_current_task;
extern struct pt_regs *kdb_current_regs;

#ifdef CONFIG_KDB_KEYBOARD
extern void kdb_kbd_cleanup_state(void);
Expand Down

0 comments on commit e17ac02

Please sign in to comment.