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
543 if (diag)543 if (diag)
544 return diag;544 return diag;
545 } else if (symname[0] == '%') {545 } else if (symname[0] == '%') {
546 diag = kdb_check_regs();546 if (kdb_check_regs())
547 if (diag)547 return 0;
548 return diag;
549 /* Implement register values with % at a later time as it is548 /* Implement register values with % at a later time as it is
550 * arch optional.549 * arch optional.
551 */550 */
@@ -1836,8 +1835,7 @@ static int kdb_go(int argc, const char **argv) · 1284 unmodified lines
1836 */1835 */
1837static int kdb_rd(int argc, const char **argv)1836static int kdb_rd(int argc, const char **argv)
1838{1837{
1839 int len = kdb_check_regs();1838 int len = 0;
1840#if DBG_MAX_REG_NUM > 0
1841 int i;1839 int i;
1842 char *rname;1840 char *rname;
1843 int rsize;1841 int rsize;
@@ -1846,8 +1844,14 @@ static int kdb_rd(int argc, const char **argv) · 2 unmodified lines
1846 u16 reg16;1844 u16 reg16;
1847 u8 reg8;1845 u8 reg8;
1848 1846
1849 if (len)1847 if (kdb_check_regs())
1850 return len;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 }
1851 1855
1852 for (i = 0; i < DBG_MAX_REG_NUM; i++) {1856 for (i = 0; i < DBG_MAX_REG_NUM; i++) {
1853 rsize = dbg_reg_def[i].size * 2;1857 rsize = dbg_reg_def[i].size * 2;
@@ -1889,12 +1893,7 @@ static int kdb_rd(int argc, const char **argv) · 35 unmodified lines
1889 }1893 }
1890 }1894 }
1891 kdb_printf("\n");1895 kdb_printf("\n");
1892#else
1893 if (len)
1894 return len;
1895 1896
1896 kdb_dumpregs(kdb_current_regs);
1897#endif
1898 return 0;1897 return 0;
1899}1898}
1900 1899
@@ -1928,9 +1927,8 @@ static int kdb_rm(int argc, const char **argv) · 27 unmodified lines
1928 if (diag)1927 if (diag)
1929 return diag;1928 return diag;
1930 1929
1931 diag = kdb_check_regs();1930 if (kdb_check_regs())
1932 if (diag)1931 return 0;
1933 return diag;
1934 1932
1935 diag = KDB_BADREG;1933 diag = KDB_BADREG;
1936 for (i = 0; i < DBG_MAX_REG_NUM; i++) {1934 for (i = 0; i < DBG_MAX_REG_NUM; i++) {