Module Name:    src
Committed By:   uwe
Date:           Wed Apr 20 19:06:35 UTC 2022

Modified Files:
        src/sys/ddb: db_command.c

Log Message:
ddb: guard invocation of db_cmd_on_enter properly.

db_command_loop - do not ignore the return value from setjmp used to
guard db_cmd_on_enter.  We do not want to re-execute the enter command
if it fails.  Note that "fails" includes e.g. aborting long output
from the enter command with "q" at the --db more-- prompt, which is
quite likely as the default enter command is "bt".

While here, don't even bother with the whole song and dance if the
enter command is not set.


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 src/sys/ddb/db_command.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ddb/db_command.c
diff -u src/sys/ddb/db_command.c:1.179 src/sys/ddb/db_command.c:1.180
--- src/sys/ddb/db_command.c:1.179	Sun Oct 10 18:08:12 2021
+++ src/sys/ddb/db_command.c	Wed Apr 20 19:06:35 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_command.c,v 1.179 2021/10/10 18:08:12 thorpej Exp $	*/
+/*	$NetBSD: db_command.c,v 1.180 2022/04/20 19:06:35 uwe Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009, 2019
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.179 2021/10/10 18:08:12 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.180 2022/04/20 19:06:35 uwe Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_aio.h"
@@ -597,15 +597,16 @@ db_command_loop(void)
 	/* save context for return from ddb */
 	savejmp = db_recover;
 	db_recover = &db_jmpbuf;
-	(void) setjmp(&db_jmpbuf);
 
 	/*
 	 * Execute default ddb start commands only if this is the
 	 * first entry into DDB, in case the start commands fault
 	 * and we recurse into here.
 	 */
-	if (!savejmp)
-		db_execute_commandlist(db_cmd_on_enter);
+	if (savejmp == NULL && db_cmd_on_enter[0] != '\0') {
+		if (setjmp(&db_jmpbuf) == 0)
+			db_execute_commandlist(db_cmd_on_enter);
+	}
 
 	(void) setjmp(&db_jmpbuf);
 	while (!db_cmd_loop_done) {

Reply via email to