Module Name:    src
Committed By:   uwe
Date:           Sat Dec 24 14:47:47 UTC 2022

Modified Files:
        src/sys/arch/amd64/amd64: db_machdep.c
        src/sys/arch/i386/i386: db_machdep.c

Log Message:
{amd64,i386}/db_machdep.c: Don't bury a function call in an if condition

db_frame_info has many arguments and requires contorted line wrapping
that obscures the condition.  The same object code is generated
(modulo a local variable moved closer to its only use site).


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/amd64/amd64/db_machdep.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/i386/db_machdep.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/arch/amd64/amd64/db_machdep.c
diff -u src/sys/arch/amd64/amd64/db_machdep.c:1.14 src/sys/arch/amd64/amd64/db_machdep.c:1.15
--- src/sys/arch/amd64/amd64/db_machdep.c:1.14	Sat Dec 24 14:32:42 2022
+++ src/sys/arch/amd64/amd64/db_machdep.c	Sat Dec 24 14:47:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.14 2022/12/24 14:32:42 uwe Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.15 2022/12/24 14:47:47 uwe Exp $	*/
 
 /*
  * Mach Operating System
@@ -26,7 +26,7 @@
  * rights to redistribute these changes.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.14 2022/12/24 14:32:42 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.15 2022/12/24 14:47:47 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -111,7 +111,7 @@ db_nextframe(long **nextframe, long **re
 	struct trapframe *tf;
 	struct x86_64_frame *fp;
 	struct intrframe *ifp;
-	int traptype, trapno, err, i;
+	int trapno, err, i;
 	db_expr_t syscallno;
 
 	switch (is_trap) {
@@ -175,9 +175,10 @@ db_nextframe(long **nextframe, long **re
 	 * a frame can be recognized by always having
 	 * err 0 or IREENT_MAGIC and trapno T_ASTFLT.
 	 */
-	if (db_frame_info(*nextframe, (db_addr_t)*ip, NULL, NULL, &traptype,
-	    NULL) != DB_SYM_NULL
-	    && traptype == INTERRUPT) {
+	int traptype = NONE;
+	db_sym_t sym = db_frame_info(*nextframe, (db_addr_t)*ip,
+				     NULL, NULL, &traptype, NULL);
+	if (sym != DB_SYM_NULL && traptype == INTERRUPT) {
 		for (i = 0; i < 4; i++) {
 			ifp = (struct intrframe *)(argp + i);
 			err = db_get_value((long)&ifp->if_tf.tf_err,

Index: src/sys/arch/i386/i386/db_machdep.c
diff -u src/sys/arch/i386/i386/db_machdep.c:1.9 src/sys/arch/i386/i386/db_machdep.c:1.10
--- src/sys/arch/i386/i386/db_machdep.c:1.9	Sat Dec 24 14:32:42 2022
+++ src/sys/arch/i386/i386/db_machdep.c	Sat Dec 24 14:47:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.9 2022/12/24 14:32:42 uwe Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.10 2022/12/24 14:47:47 uwe Exp $	*/
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.9 2022/12/24 14:32:42 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.10 2022/12/24 14:47:47 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -128,7 +128,6 @@ db_nextframe(long **nextframe, long **re
 	static struct trapframe tf;
 	static struct i386tss tss;
 	struct i386_frame *fp;
-	int traptype;
 	uintptr_t ptr;
 
 	switch (is_trap) {
@@ -207,9 +206,10 @@ db_nextframe(long **nextframe, long **re
 	 * a frame can be recognized by always having
 	 * err 0 or IREENT_MAGIC and trapno T_ASTFLT.
 	 */
-	if (db_frame_info(*nextframe, (db_addr_t)*ip, NULL, NULL, &traptype,
-	    NULL) != DB_SYM_NULL
-	    && traptype == INTERRUPT) {
+	int traptype = NONE;
+	db_sym_t sym = db_frame_info(*nextframe, (db_addr_t)*ip,
+				     NULL, NULL, &traptype, NULL);
+	if (sym != DB_SYM_NULL && traptype == INTERRUPT) {
 		struct intrframe *ifp;
 		int trapno;
 		int err;

Reply via email to