Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/gdb.c
Show First 20 Lines • Show All 725 Lines • ▼ Show 20 Lines | |||||
* vCPU threads invoke this function whenever the vCPU enters the | * vCPU threads invoke this function whenever the vCPU enters the | ||||
* debug server to pause or report an event. vCPU threads wait here | * debug server to pause or report an event. vCPU threads wait here | ||||
* as long as the debug server keeps them suspended. | * as long as the debug server keeps them suspended. | ||||
*/ | */ | ||||
static void | static void | ||||
_gdb_cpu_suspend(int vcpu, bool report_stop) | _gdb_cpu_suspend(int vcpu, bool report_stop) | ||||
{ | { | ||||
if (!gdb_active) | |||||
return; | |||||
debug("$vCPU %d suspending\n", vcpu); | debug("$vCPU %d suspending\n", vcpu); | ||||
CPU_SET(vcpu, &vcpus_waiting); | CPU_SET(vcpu, &vcpus_waiting); | ||||
if (report_stop && CPU_CMP(&vcpus_waiting, &vcpus_suspended) == 0) | if (report_stop && CPU_CMP(&vcpus_waiting, &vcpus_suspended) == 0) | ||||
gdb_finish_suspend_vcpus(); | gdb_finish_suspend_vcpus(); | ||||
while (CPU_ISSET(vcpu, &vcpus_suspended)) | while (CPU_ISSET(vcpu, &vcpus_suspended)) | ||||
pthread_cond_wait(&idle_vcpus, &gdb_lock); | pthread_cond_wait(&idle_vcpus, &gdb_lock); | ||||
CPU_CLR(vcpu, &vcpus_waiting); | CPU_CLR(vcpu, &vcpus_waiting); | ||||
debug("$vCPU %d resuming\n", vcpu); | debug("$vCPU %d resuming\n", vcpu); | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Handler for VM_EXITCODE_DEBUG used to suspend a vCPU when the guest | * Handler for VM_EXITCODE_DEBUG used to suspend a vCPU when the guest | ||||
* has been suspended due to an event on different vCPU or in response | * has been suspended due to an event on different vCPU or in response | ||||
* to a guest-wide suspend such as Ctrl-C or the stop on attach. | * to a guest-wide suspend such as Ctrl-C or the stop on attach. | ||||
*/ | */ | ||||
void | void | ||||
gdb_cpu_suspend(int vcpu) | gdb_cpu_suspend(int vcpu) | ||||
{ | { | ||||
if (!gdb_active) | |||||
return; | |||||
pthread_mutex_lock(&gdb_lock); | pthread_mutex_lock(&gdb_lock); | ||||
_gdb_cpu_suspend(vcpu, true); | _gdb_cpu_suspend(vcpu, true); | ||||
gdb_cpu_resume(vcpu); | gdb_cpu_resume(vcpu); | ||||
pthread_mutex_unlock(&gdb_lock); | pthread_mutex_unlock(&gdb_lock); | ||||
} | } | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 1,058 Lines • Show Last 20 Lines |