diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile --- a/usr.sbin/bhyve/Makefile +++ b/usr.sbin/bhyve/Makefile @@ -28,7 +28,6 @@ crc16.c \ ctl_scsi_all.c \ ctl_util.c \ - gdb.c \ hda_codec.c \ iov.c \ mem.c \ @@ -66,6 +65,14 @@ .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 @@ -101,10 +108,6 @@ 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 --- a/usr.sbin/bhyve/amd64/Makefile.inc +++ b/usr.sbin/bhyve/amd64/Makefile.inc @@ -1,5 +1,7 @@ .PATH: ${.CURDIR}/${MACHINE_CPUARCH} +BHYVE_GDB_SUPPORT= + SRCS+= \ atkbdc.c \ e820.c \ diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -90,7 +90,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" @@ -466,7 +468,9 @@ #ifdef BHYVE_SNAPSHOT checkpoint_cpu_add(vi->vcpuid); #endif +#ifdef BHYVE_GDB gdb_cpu_add(vi->vcpu); +#endif vm_loop(vi->ctx, vi->vcpu); @@ -760,6 +764,7 @@ fclose(fp); } +#ifdef BHYVE_GDB static void parse_gdb_options(const char *opt) { @@ -783,6 +788,7 @@ set_config_value("gdb.port", sport); } +#endif static void set_defaults(void) @@ -851,9 +857,11 @@ 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; @@ -1086,7 +1094,9 @@ if (get_config_bool("acpi_tables")) vmgenc_init(ctx); +#ifdef BHYVE_GDB init_gdb(ctx); +#endif #ifdef __amd64__ if (lpc_bootrom()) {