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