From: Douglas Anderson <dianders@chromium.org>
To: Paul Burton <paul.burton@mips.com>,
Jason Wessel <jason.wessel@windriver.com>,
Daniel Thompson <daniel.thompson@linaro.org>
Cc: qiaochong@loongson.cn, kgdb-bugreport@lists.sourceforge.net,
ralf@linux-mips.org, Douglas Anderson <dianders@chromium.org>,
Chuhong Yuan <hslester96@gmail.com>,
Christophe Leroy <christophe.leroy@c-s.fr>,
linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
Nicholas Mc Guire <hofrat@osadl.org>,
Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH 5/5] kdb: Get rid of confusing diag msg from "rd" if current task has no regs
Date: Sat, 9 Nov 2019 11:16:44 -0800 [thread overview]
Message-ID: <20191109111624.5.I121f4c6f0c19266200bf6ef003de78841e5bfc3d@changeid> (raw)
In-Reply-To: <20191109191644.191766-1-dianders@chromium.org>
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 <dianders@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
next prev parent reply other threads:[~2019-11-09 19:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-09 19:16 [PATCH 0/5] kdb: Don't implicitly change tasks; plus misc fixups Douglas Anderson
2019-11-09 19:16 ` [PATCH 1/5] MIPS: kdb: Remove old workaround for backtracing on other CPUs Douglas Anderson
2019-11-14 10:51 ` Daniel Thompson
2019-11-14 16:10 ` Doug Anderson
2019-11-15 0:30 ` Paul Burton
2019-11-09 19:16 ` [PATCH 2/5] kdb: kdb_current_regs should be private Douglas Anderson
2019-11-09 19:16 ` [PATCH 3/5] kdb: kdb_current_task shouldn't be exported Douglas Anderson
2019-11-09 19:16 ` [PATCH 4/5] kdb: Gid rid of implicit setting of the current task / regs Douglas Anderson
2019-11-09 19:16 ` Douglas Anderson [this message]
2020-01-28 16:59 ` [PATCH 0/5] kdb: Don't implicitly change tasks; plus misc fixups Doug Anderson
2020-01-29 1:42 ` Andrew Morton
2020-01-29 15:23 ` Daniel Thompson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191109111624.5.I121f4c6f0c19266200bf6ef003de78841e5bfc3d@changeid \
--to=dianders@chromium.org \
--cc=christophe.leroy@c-s.fr \
--cc=dan.carpenter@oracle.com \
--cc=daniel.thompson@linaro.org \
--cc=gustavo@embeddedor.com \
--cc=hofrat@osadl.org \
--cc=hslester96@gmail.com \
--cc=jason.wessel@windriver.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=paul.burton@mips.com \
--cc=qiaochong@loongson.cn \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).