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.

Signed-off-by: Douglas Anderson <diand...@chromium.org>
---

 kernel/debug/kdb/kdb_main.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index ba12e9f4661e..b22292b649c4 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -543,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.
                 */
@@ -1836,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;
@@ -1846,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;
@@ -1889,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;
 }
 
@@ -1928,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++) {
-- 
2.24.0.432.g9d3f5f5b63-goog



_______________________________________________
Kgdb-bugreport mailing list
Kgdb-bugreport@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kgdb-bugreport

Reply via email to