#ifdef USE_OVM_DEBUGGER
void wasm_config_enable_debug(wasm_config_t *config, int value);
wasm_config_enable_debug(wasm_config, debug_enabled);
+
+ #if defined(_BH_LINUX) || defined(_BH_DARWIN)
+ char *env_path = getenv("ONYX_PATH");
+ char *socket_path = bh_aprintf(bh_heap_allocator(), "%s/debug.0000", env_path);
+
+ void wasm_config_set_listen_path(wasm_config_t *config, char *listen_path);
+ wasm_config_set_listen_path(wasm_config, socket_path);
+ #endif
#endif
#ifndef USE_OVM_DEBUGGER
func(data);
__flush_stdio();
+
+ core.thread.__exited(id);
}
_thread_exit :: (id: i32) {
- raw_free(alloc.heap_allocator, __tls_base);
- core.thread.__exited(id);
+ // raw_free(alloc.heap_allocator, __tls_base);
+ // core.thread.__exited(id);
}
}
__exited :: (id: i32) {
sync.scoped_mutex(&thread_mutex);
- thread := thread_map->get(id)?;
+ thread := thread_map->get(id) ?? null;
if thread != null {
thread.alive = false;
#if runtime.platform.Supports_Futexes {
b32 started;
i32 run_count;
- sem_t wait_semaphore;
+ sem_t* wait_semaphore;
bool pause_at_next_line;
i32 pause_within;
new_thread->state = debug_state_starting;
new_thread->ovm_state = ovm_state;
new_thread->run_count = 0; // Start threads in stopped state.
- sem_init(&new_thread->wait_semaphore, 0, 0);
u32 id = debug->next_thread_id++;
new_thread->id = id;
+ char name_buf[256];
+ bh_bprintf(name_buf, 256, "/ovm_thread_%d", new_thread->id);
+ new_thread->wait_semaphore = sem_open(name_buf, O_CREAT, 0664, 0);
+
new_thread->state_change_write_fd = debug->state_change_pipes[1];
bh_arr_push(debug->threads, new_thread);
static void resume_thread(debug_thread_state_t *thread) {
thread->run_count = -1;
- sem_post(&thread->wait_semaphore);
+ sem_post(thread->wait_semaphore);
}
static void resume_thread_slow(debug_thread_state_t *thread) {
- sem_post(&thread->wait_semaphore);
+ sem_post(thread->wait_semaphore);
}
static u32 get_stack_frame_instruction_pointer(debug_state_t *debug, debug_thread_state_t *thread, ovm_stack_frame_t *frame) {
local_addr.sun_family = AF_UNIX;
strcpy(local_addr.sun_path, debug->listen_path); // TODO: Make this dynamic so mulitple servers can exist at a time.
unlink(local_addr.sun_path); // TODO: Remove this line for the same reason.
- int len = strlen(local_addr.sun_path) + sizeof(local_addr.sun_family);
+ int len = strlen(local_addr.sun_path) + 1 + sizeof(local_addr.sun_family);
bind(debug->listen_socket_fd, (struct sockaddr *)&local_addr, len);
//
state->debug->pause_reason = debug_pause_exception;
assert(write(state->debug->state_change_write_fd, "1", 1));
- sem_wait(&state->debug->wait_semaphore);
+ sem_wait(state->debug->wait_semaphore);
}
}
should_wait:
assert(write(state->debug->state_change_write_fd, "1", 1));
- sem_wait(&state->debug->wait_semaphore);
+ sem_wait(state->debug->wait_semaphore);
state->debug->state = debug_state_running;
shouldnt_wait: