summaryrefslogtreecommitdiff
path: root/usr/src/cmd/bhyve/gdb.c
diff options
context:
space:
mode:
authorAndy Fiddaman <omnios@citrus-it.co.uk>2021-03-26 14:06:33 +0000
committerAndy Fiddaman <omnios@citrus-it.co.uk>2021-04-19 16:13:12 +0000
commit2b9481465d6ee67ac62c160dbf79c3ec3348c611 (patch)
tree3ccf049f86906940c8af478a621835fb29844b09 /usr/src/cmd/bhyve/gdb.c
parent2282d3b00bd23a5df4dfea0edd5ae737693bd4b7 (diff)
downloadillumos-joyent-2b9481465d6ee67ac62c160dbf79c3ec3348c611.tar.gz
13674 bhyve upstream sync 2021 March
Reviewed by: Patrick Mooney <pmooney@pfmooney.com> Reviewed by: Jorge Schrauwen <sjorge@blackdot.be> Reviewed by: Mike Zeller <mike.zeller@joyent.com> Reviewed by: C Fraire <cfraire@me.com> Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/cmd/bhyve/gdb.c')
-rw-r--r--usr/src/cmd/bhyve/gdb.c12
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;
}