public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrei Warkentin <andreiw@vmware.com>
To: kgdb-bugreport@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, jason.wessel@windriver.com,
	andreiw@vmware.com
Subject: [PATCH 1/2] KDB: Make LINES an internal variable.
Date: Fri, 17 Feb 2012 21:07:15 -0500	[thread overview]
Message-ID: <1329530836-23958-2-git-send-email-andreiw@vmware.com> (raw)
In-Reply-To: <1329530836-23958-1-git-send-email-andreiw@vmware.com>

1) If you run 'dumpall', LINES will remain set to
   10000, and you might wonder why dmesg now doesn't
   page.
2) If you run any command that sets LINES, you will
   eventually exhaust the heap.

To address (1), you can save and restore across
calls to "defcmd" commands, which might contain
"set LINES". This becomes awkward with keeping
LINES in env, but there is no real reason why
LINES cannot be treated as an internal variable.
Additionally, you get rid of the (small) kdb heap
usage for LINES.

Signed-off-by: Andrei Warkentin <andreiw@vmware.com>
---
 kernel/debug/kdb/kdb_io.c      |    4 ++--
 kernel/debug/kdb/kdb_main.c    |   29 ++++++++++++++++++++++++++---
 kernel/debug/kdb/kdb_private.h |    1 +
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 4802eb5..5eb7e23 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -580,8 +580,8 @@ int vkdb_printf(const char *fmt, va_list ap)
 		__acquire(kdb_printf_lock);
 	}
 
-	diag = kdbgetintenv("LINES", &linecount);
-	if (diag || linecount <= 1)
+	linecount = kdb_lines;
+	if (linecount <= 1)
 		linecount = 24;
 
 	diag = kdbgetintenv("LOGGING", &logging);
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 63786e7..37f9d45 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -60,6 +60,7 @@ atomic_t kdb_event;
 int kdb_initial_cpu = -1;	/* cpu number that owns kdb */
 int kdb_nextline = 1;
 int kdb_state;			/* General KDB state */
+int kdb_lines = 0;		/* Lines displayed at once */
 
 struct task_struct *kdb_current_task;
 EXPORT_SYMBOL(kdb_current_task);
@@ -386,6 +387,18 @@ int kdb_set(int argc, const char **argv)
 			| (debugflags << KDB_DEBUG_FLAG_SHIFT);
 
 		return 0;
+	} else if (strcmp(argv[1], "LINES") == 0) {
+		int lines;
+		char *cp;
+
+		lines = simple_strtol(argv[2], &cp, 0);
+		if (cp == argv[2]) {
+			kdb_printf("kdb: illegal LINES value '%s'\n",
+				   argv[2]);
+			return 0;
+		}
+		kdb_lines = lines;
+		return 0;
 	}
 
 	/*
@@ -721,8 +734,11 @@ static int kdb_defcmd(int argc, const char **argv)
  */
 static int kdb_exec_defcmd(int argc, const char **argv)
 {
-	int i, ret;
+	int i;
+	int oldlines;
 	struct defcmd_set *s;
+	int ret = 0;
+
 	if (argc != 0)
 		return KDB_ARGCOUNT;
 	for (s = defcmd_set, i = 0; i < defcmd_set_count; ++i, ++s) {
@@ -734,6 +750,9 @@ static int kdb_exec_defcmd(int argc, const char **argv)
 			   argv[0]);
 		return KDB_NOTIMP;
 	}
+
+	/* command might have overridden LINES */
+	oldlines = kdb_lines;
 	for (i = 0; i < s->count; ++i) {
 		/* Recursive use of kdb_parse, do not use argv after
 		 * this point */
@@ -741,9 +760,10 @@ static int kdb_exec_defcmd(int argc, const char **argv)
 		kdb_printf("[%s]kdb> %s\n", s->name, s->command[i]);
 		ret = kdb_parse(s->command[i]);
 		if (ret)
-			return ret;
+			break;
 	}
-	return 0;
+	kdb_lines = oldlines;
+	return ret;
 }
 
 /* Command history */
@@ -2026,6 +2046,9 @@ static int kdb_env(int argc, const char **argv)
 	if (KDB_DEBUG(MASK))
 		kdb_printf("KDBFLAGS=0x%x\n", kdb_flags);
 
+	if (kdb_lines)
+		kdb_printf("LINES=%d\n", kdb_lines);
+
 	return 0;
 }
 
diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h
index e381d10..41a221f 100644
--- a/kernel/debug/kdb/kdb_private.h
+++ b/kernel/debug/kdb/kdb_private.h
@@ -154,6 +154,7 @@ extern int kdb_state;
 #define KDB_STATE_CLEAR(flag) ((void)(kdb_state &= ~KDB_STATE_##flag))
 
 extern int kdb_nextline; /* Current number of lines displayed */
+extern int kdb_lines;    /* Limit on number of lines displayed at once. */
 
 typedef struct _kdb_bp {
 	unsigned long	bp_addr;	/* Address breakpoint is present at */
-- 
1.7.4.1


  reply	other threads:[~2012-02-18  2:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-18  2:07 Usability non-serial console sessions Andrei Warkentin
2012-02-18  2:07 ` Andrei Warkentin [this message]
2012-02-25  3:17   ` [PATCH 1/2] KDB: Make LINES an internal variable Andrei Warkentin
2012-02-18  2:07 ` [PATCH 2/2] KDB: Overide LINES for custom commands Andrei Warkentin

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=1329530836-23958-2-git-send-email-andreiw@vmware.com \
    --to=andreiw@vmware.com \
    --cc=jason.wessel@windriver.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.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