Re: one problem about using kdb 'ss' command

Keith Owens <[email protected]>
Newsgroups gmane.linux.kernel.debugging
Message-ID <[email protected]>
Keith Owens (on Tue, 27 Feb 2007 00:42:54 +1100) wrote:
>"Zhou, Water" (on Mon, 26 Feb 2007 14:13:24 +0800) wrote:
>>    Entering kdb (current=3D0xc460b550, pid 1125) duo to Breakpoint @0xc016ca90
>>    kdb> ss
>>
>>    kdb_ss: pt_regs not available
>>
>>I think the problem is because of get_irq_regs() inline function
>>return NULL when the breakpoint is touched. I don't know why ?
>
>Correct, there are a couple of paths that do not call set_irq_regs().
>Could you try this patch, it is against kdb-v4.4-2.6.20-common-4 but
>should apply to 2.6.19 as well.  The patch compiles but I will not be
>able to test it for for several hours.

After testing, this is the correct patch.  It is included in
kdb-v4.4-2.6.20-common-5.

Index: linux/kdb/kdbmain.c
===================================================================
--- linux.orig/kdb/kdbmain.c	2007-02-27 10:51:18.403100729 +1100
+++ linux/kdb/kdbmain.c	2007-02-27 10:44:43.146860775 +1100
@@ -1735,7 +1735,8 @@ kdb(kdb_reason_t reason, int error, stru
 	kdb_intstate_t int_state;	/* Interrupt state */
 	kdb_reason_t reason2 = reason;
 	int result = 0;	/* Default is kdb did not handle it */
-	int ss_event;
+	int ss_event, old_regs_saved = 0;
+	struct pt_regs *old_regs = NULL;
 	kdb_dbtrap_t db_result=KDB_DB_NOBPT;
 	preempt_disable();
 	atomic_inc(&kdb_event);
@@ -1748,6 +1749,23 @@ kdb(kdb_reason_t reason, int error, stru
 	default:
 		break;
 	}
+	switch(reason) {
+	case KDB_REASON_ENTER:
+	case KDB_REASON_ENTER_SLAVE:
+	case KDB_REASON_BREAK:
+	case KDB_REASON_DEBUG:
+	case KDB_REASON_OOPS:
+	case KDB_REASON_SWITCH:
+	case KDB_REASON_KEYBOARD:
+	case KDB_REASON_NMI:
+		if (regs && regs != get_irq_regs()) {
+			old_regs = set_irq_regs(regs);
+			old_regs_saved = 1;
+		}
+		break;
+	default:
+		break;
+	}
 	if (kdb_continue_catastrophic > 2) {
 		kdb_printf("kdb_continue_catastrophic is out of range, setting to 2\n");
 		kdb_continue_catastrophic = 2;
@@ -2060,6 +2078,8 @@ kdb(kdb_reason_t reason, int error, stru
 	if (!(KDB_STATE(DOING_SS) || KDB_STATE(SSBPT) || KDB_STATE(RECURSE))) {
 		KDB_DEBUG_STATE("kdb 15", result);
 		kdb_bp_install_local(regs);
+		if (old_regs_saved)
+			set_irq_regs(old_regs);
 		KDB_STATE_CLEAR(KDB_CONTROL);
 	}
 

---------------------------
Use http://oss.sgi.com/ecartis to modify your settings or to unsubscribe.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.