diff options
Diffstat (limited to 'usr/src/cmd/bhyve/gdb.c')
-rw-r--r-- | usr/src/cmd/bhyve/gdb.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/usr/src/cmd/bhyve/gdb.c b/usr/src/cmd/bhyve/gdb.c index 720a55c58b..60b3b8ab6d 100644 --- a/usr/src/cmd/bhyve/gdb.c +++ b/usr/src/cmd/bhyve/gdb.c @@ -135,6 +135,7 @@ static int cur_fd = -1; static TAILQ_HEAD(, breakpoint) breakpoints; static struct vcpu_state *vcpu_state; static int cur_vcpu, stopped_vcpu; +static bool gdb_active = false; const int gdb_regset[] = { VM_REG_GUEST_RAX, @@ -753,6 +754,8 @@ static void _gdb_cpu_suspend(int vcpu, bool report_stop) { + if (!gdb_active) + return; debug("$vCPU %d suspending\n", vcpu); CPU_SET(vcpu, &vcpus_waiting); if (report_stop && CPU_CMP(&vcpus_waiting, &vcpus_suspended) == 0) @@ -771,6 +774,8 @@ void gdb_cpu_add(int vcpu) { + if (!gdb_active) + return; debug("$vCPU %d starting\n", vcpu); pthread_mutex_lock(&gdb_lock); assert(vcpu < guest_ncpus); @@ -852,6 +857,8 @@ gdb_cpu_mtrap(int vcpu) { struct vcpu_state *vs; + if (!gdb_active) + return; debug("$vCPU %d MTRAP\n", vcpu); pthread_mutex_lock(&gdb_lock); vs = &vcpu_state[vcpu]; @@ -892,6 +899,10 @@ gdb_cpu_breakpoint(int vcpu, struct vm_exit *vmexit) uint64_t gpa; int error; + if (!gdb_active) { + fprintf(stderr, "vm_loop: unexpected VMEXIT_DEBUG\n"); + exit(4); + } pthread_mutex_lock(&gdb_lock); error = guest_vaddr2paddr(vcpu, vmexit->rip, &gpa); assert(error == 1); @@ -1931,4 +1942,5 @@ init_gdb(struct vmctx *_ctx, int sport, bool wait) limit_gdb_socket(s); #endif mevent_add(s, EVF_READ, new_connection, NULL); + gdb_active = true; } |