History

kdb: Get rid of confusing diag msg from "rd" if current task has no regs

If you switch to a sleeping task with the "pid" command and then type "rd", kdb tells you this: No current kdb registers. You may need to select another task diag: -17: Invalid register name The first message makes sense, but not the second. Fix it by just returning 0 after commands accessing the current registers finish if we've already printed the "No current kdb registers" error. While fixing kdb_rd(), change the function to use "if" rather than "ifdef". It cleans the function up a bit and any modern compiler will have no trouble handling still producing good code.

Douglas Anderson committed 7 years ago

Commit bbfceba1 parent 9441d5f1 file · +13 −15Browse files

Showing the changes to kernel/debug (1 of 1 file). Show all

Unified · Split

kernel/debug/kdb/kdb_main.c+13−15
@@ -543,9 +543,8 @@ int kdbgetaddrarg(int argc, const char **argv, int *nextarg, · 542 unmodified lines
543543 if (diag)
544544 return diag;
545545 } else if (symname[0] == '%') {
546− diag = kdb_check_regs();
547− if (diag)
548− return diag;
546+ if (kdb_check_regs())
547+ return 0;
549548 /* Implement register values with % at a later time as it is
550549 * arch optional.
551550 */
@@ -1836,8 +1835,7 @@ static int kdb_go(int argc, const char **argv) · 1284 unmodified lines
18361835 */
18371836 static int kdb_rd(int argc, const char **argv)
18381837 {
1839− int len = kdb_check_regs();
1840−#if DBG_MAX_REG_NUM > 0
1838+ int len = 0;
18411839 int i;
18421840 char *rname;
18431841 int rsize;
@@ -1846,8 +1844,14 @@ static int kdb_rd(int argc, const char **argv) · 2 unmodified lines
18461844 u16 reg16;
18471845 u8 reg8;
18481846
1849− if (len)
1850− 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+ }
18511855
18521856 for (i = 0; i < DBG_MAX_REG_NUM; i++) {
18531857 rsize = dbg_reg_def[i].size * 2;
@@ -1889,12 +1893,7 @@ static int kdb_rd(int argc, const char **argv) · 35 unmodified lines
18891893 }
18901894 }
18911895 kdb_printf("\n");
1892−#else
1893− if (len)
1894− return len;
18951896
1896− kdb_dumpregs(kdb_current_regs);
1897−#endif
18981897 return 0;
18991898 }
19001899
@@ -1928,9 +1927,8 @@ static int kdb_rm(int argc, const char **argv) · 27 unmodified lines
19281927 if (diag)
19291928 return diag;
19301929
1931− diag = kdb_check_regs();
1932− if (diag)
1933− return diag;
1930+ if (kdb_check_regs())
1931+ return 0;
19341932
19351933 diag = KDB_BADREG;
19361934 for (i = 0; i < DBG_MAX_REG_NUM; i++) {