git: ca2cda98d265 - main - bhyve: Make gdb support optional
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 04 Oct 2023 16:54:12 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=ca2cda98d265ef5d80b7cd0705697a1af27fb808
commit ca2cda98d265ef5d80b7cd0705697a1af27fb808
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-10-04 16:26:36 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-04 16:53:17 +0000
bhyve: Make gdb support optional
Add a BHYVE_GDB_SUPPORT make variable that can be set by per-arch
makefiles. When set, BHYVE_GDB is defined and can be used as a
preprocessor predicate. Use it to guard gdb stub calls in MI code.
The arm64 bhyve port currently does not have a functional gdb stub, but
that's not critical to landing the port, so this mechanism slightly
reduces the friction of adding support for a new platform.
Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40986
---
usr.sbin/bhyve/Makefile | 13 ++++++++-----
usr.sbin/bhyve/amd64/Makefile.inc | 2 ++
usr.sbin/bhyve/bhyverun.c | 10 ++++++++++
3 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile
index 7c0750fae7d7..1a8191f9fd3f 100644
--- a/usr.sbin/bhyve/Makefile
+++ b/usr.sbin/bhyve/Makefile
@@ -28,7 +28,6 @@ SRCS= \
crc16.c \
ctl_scsi_all.c \
ctl_util.c \
- gdb.c \
hda_codec.c \
iov.c \
mem.c \
@@ -67,6 +66,14 @@ SRCS+= snapshot.c
.include "${MACHINE_CPUARCH}/Makefile.inc"
+.if defined(BHYVE_GDB_SUPPORT)
+SRCS+= gdb.c
+CFLAGS+= -DBHYVE_GDB
+.ifdef GDB_LOG
+CFLAGS+=-DGDB_LOG
+.endif
+.endif
+
CFLAGS+=-I${.CURDIR} \
-I${.CURDIR}/../../contrib/lib9p \
-I${SRCTOP}/sys
@@ -102,10 +109,6 @@ CFLAGS+= -I${SRCTOP}/contrib/libucl/include
CFLAGS+= -DBHYVE_SNAPSHOT
.endif
-.ifdef GDB_LOG
-CFLAGS+=-DGDB_LOG
-.endif
-
# Disable thread safety analysis since it only finds very simple bugs and
# yields many false positives.
NO_WTHREAD_SAFETY=
diff --git a/usr.sbin/bhyve/amd64/Makefile.inc b/usr.sbin/bhyve/amd64/Makefile.inc
index 96aaecafae4c..bc0ffa720d31 100644
--- a/usr.sbin/bhyve/amd64/Makefile.inc
+++ b/usr.sbin/bhyve/amd64/Makefile.inc
@@ -1,3 +1,5 @@
+BHYVE_GDB_SUPPORT=
+
SRCS+= \
atkbdc.c \
e820.c \
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index 0c8eba3e4a6b..d054ec1301f7 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -86,7 +86,9 @@
#include "amd64/e820.h"
#include "amd64/fwctl.h"
#endif
+#ifdef BHYVE_GDB
#include "gdb.h"
+#endif
#ifdef __amd64__
#include "amd64/ioapic.h"
#include "amd64/kernemu_dev.h"
@@ -463,7 +465,9 @@ fbsdrun_start_thread(void *param)
#ifdef BHYVE_SNAPSHOT
checkpoint_cpu_add(vi->vcpuid);
#endif
+#ifdef BHYVE_GDB
gdb_cpu_add(vi->vcpu);
+#endif
vm_loop(vi->ctx, vi->vcpu);
@@ -757,6 +761,7 @@ parse_simple_config_file(const char *path)
fclose(fp);
}
+#ifdef BHYVE_GDB
static void
parse_gdb_options(const char *opt)
{
@@ -780,6 +785,7 @@ parse_gdb_options(const char *opt)
set_config_value("gdb.port", sport);
}
+#endif
static void
set_defaults(void)
@@ -852,9 +858,11 @@ main(int argc, char *argv[])
errx(EX_USAGE, "invalid fwcfg item '%s'", optarg);
}
break;
+#ifdef BHYVE_GDB
case 'G':
parse_gdb_options(optarg);
break;
+#endif
case 'k':
parse_simple_config_file(optarg);
break;
@@ -1091,7 +1099,9 @@ main(int argc, char *argv[])
if (get_config_bool("acpi_tables"))
vmgenc_init(ctx);
+#ifdef BHYVE_GDB
init_gdb(ctx);
+#endif
#ifdef __amd64__
if (lpc_bootrom()) {