git: f0a7df4a6cc9 - main - ddb: make db_error reliably no-return

From: Ryan Libby <rlibby_at_FreeBSD.org>
Date: Tue, 09 Jul 2024 18:45:18 UTC
The branch main has been updated by rlibby:

URL: https://cgit.FreeBSD.org/src/commit/?id=f0a7df4a6cc9a795680d580fcabd993379e22ae5

commit f0a7df4a6cc9a795680d580fcabd993379e22ae5
Author:     Ryan Libby <rlibby@FreeBSD.org>
AuthorDate: 2024-07-09 17:59:27 +0000
Commit:     Ryan Libby <rlibby@FreeBSD.org>
CommitDate: 2024-07-09 17:59:27 +0000

    ddb: make db_error reliably no-return
    
    Most code assumes db_error does not return, but according to
    kdb_reenter_silent, there may be cases where it could.  Instead, panic
    if kdb_reenter_silent returns and mark the routine as __dead2.  This
    addresses gcc warnings.
    
    Reported by:    GCC -Wmaybe-uninitialized
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D45918
---
 sys/ddb/db_command.c | 1 +
 sys/ddb/ddb.h        | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c
index f621bd614ca2..1043f7091085 100644
--- a/sys/ddb/db_command.c
+++ b/sys/ddb/db_command.c
@@ -580,6 +580,7 @@ db_error(const char *s)
 	    db_printf("%s", s);
 	db_flush_lex();
 	kdb_reenter_silent();
+	panic("%s: did not reenter debugger", __func__);
 }
 
 static void
diff --git a/sys/ddb/ddb.h b/sys/ddb/ddb.h
index ab7dab1daa45..8088226c6939 100644
--- a/sys/ddb/ddb.h
+++ b/sys/ddb/ddb.h
@@ -233,7 +233,7 @@ void		db_check_interrupt(void);
 void		db_clear_watchpoints(void);
 db_addr_t	db_disasm(db_addr_t loc, bool altfmt);
 				/* instruction disassembler */
-void		db_error(const char *s);
+void		db_error(const char *s) __dead2;
 int		db_expression(db_expr_t *valuep);
 int		db_getc(void);
 int		db_get_variable(db_expr_t *valuep);