Module Name:    src
Committed By:   skrll
Date:           Sun Nov 24 19:41:18 UTC 2024

Modified Files:
        src/sys/arch/riscv/riscv: db_disasm.c

Log Message:
risc-v: don't KASSERT in the disassembler.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/riscv/riscv/db_disasm.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/riscv/riscv/db_disasm.c
diff -u src/sys/arch/riscv/riscv/db_disasm.c:1.12 src/sys/arch/riscv/riscv/db_disasm.c:1.13
--- src/sys/arch/riscv/riscv/db_disasm.c:1.12	Tue Sep 24 20:39:08 2024
+++ src/sys/arch/riscv/riscv/db_disasm.c	Sun Nov 24 19:41:18 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.12 2024/09/24 20:39:08 andvar Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.13 2024/11/24 19:41:18 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__RCSID("$NetBSD: db_disasm.c,v 1.12 2024/09/24 20:39:08 andvar Exp $");
+__RCSID("$NetBSD: db_disasm.c,v 1.13 2024/11/24 19:41:18 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -467,7 +467,6 @@ db_disasm_16(db_addr_t loc, uint32_t ins
 		break;
 	    default:
 		/* 0b11 marks 32-bit instructions and shouldn't come here */
-		KASSERT(INSN16_QUADRANT(insn) != 0b11);
 		return EINVAL;
 	}
 	return 0;
@@ -1004,7 +1003,6 @@ riscv_int_size(unsigned fpsize)
 	    case OPFP_LU: return ".lu";
 	    default:
 		/* matching should prevent it coming here */
-		KASSERT(0);
 		return ".?";
 	}
 }
@@ -1018,7 +1016,6 @@ riscv_fp_size(unsigned fpsize)
 	    case OPFP_Q: return ".q";
 	    default:
 		/* matching should prevent it coming here */
-		KASSERT(0);
 		return ".?";
 	}
 }
@@ -1051,7 +1048,6 @@ larger_f_i(unsigned sz1, unsigned sz2)
 		break;
 	    default:
 		/* matching should keep it from coming here */
-		KASSERT(0);
 		break;
 	}
 	return false;
@@ -1082,7 +1078,6 @@ larger_f_f(unsigned sz1, unsigned sz2)
 		break;
 	    default:
 		/* matching should keep it from coming here */
-		KASSERT(0);
 		break;
 	}
 	return false;
@@ -1100,7 +1095,6 @@ db_print_riscv_fpround(const char *sep, 
 	    case ROUND_DYN: break;
 	    default:
 		/* matching should prevent it coming here */
-		KASSERT(0);
 		db_printf("%s<unknown-rounding-mode>", sep);
 		break;
 	}
@@ -1242,8 +1236,6 @@ db_disasm_32(db_addr_t loc, uint32_t ins
 			bool suppress;
 
 			if (info->printflags & ISCVT) {
-				KASSERT(info->matchflags & F7SIZE);
-				KASSERT(info->matchflags & RS2_FSIZE);
 				if (info->matchflags & RS2SIZE_FIRST) {
 					/* convert to int */
 					suppress = false;
@@ -1341,7 +1333,6 @@ db_disasm_32(db_addr_t loc, uint32_t ins
 				db_print_riscv_fencebits(succ);
 			} else if (info->printflags & BRANCHIMM) {
 				/* should be B format and not come here */
-				KASSERT(0);
 			} else if (info->printflags & DECIMM) {
 				db_printf("%s%d", sep, (int32_t)imm);
 			} else {
@@ -1372,9 +1363,6 @@ db_disasm_32(db_addr_t loc, uint32_t ins
 			return EINVAL;
 		}
 
-		KASSERT((info->matchflags & (RS1_0 | RS2_0 | CHECK_RS2)) == 0);
-		KASSERT(info->printflags & MEMORYIMM);
-
 		/* name */
 		db_print_riscv_insnname(insn, info);
 		db_printf(" ");
@@ -1399,9 +1387,6 @@ db_disasm_32(db_addr_t loc, uint32_t ins
 			return EINVAL;
 		}
 
-		KASSERT((info->matchflags & (RS1_0 | RS2_0 | CHECK_RS2)) == 0);
-		KASSERT(info->printflags & BRANCHIMM);
-
 		/* name */
 		db_print_riscv_insnname(insn, info);
 		db_printf(" ");
@@ -1436,7 +1421,6 @@ db_disasm_32(db_addr_t loc, uint32_t ins
 		return EINVAL;
 	    case FMT_ASSERT:
 		/* shouldn't have come here */
-		KASSERTMSG(false, "db_disasm_32: non-32-bit instruction");
 		return EINVAL;
 	}
 	return 0;
@@ -1470,7 +1454,6 @@ db_disasm(db_addr_t loc, bool altfmt)
 	 */
 	db_read_bytes(loc, sizeof(insn[0]), (void *)&insn[0]);
 	n = INSN_HALFWORDS(insn[0]);
-	KASSERT(n > 0 && n <= 5);
 	for (i = 1; i < n; i++) {
 		db_read_bytes(loc + i * sizeof(insn[i]), sizeof(insn[i]),
 			      (void *)&insn[i]);

Reply via email to