Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support debugging multithreaded programs until they create threads #10594

Merged
merged 2 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions otherlibs/systhreads/st_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "caml/backtrace.h"
#include "caml/callback.h"
#include "caml/custom.h"
#include "caml/debugger.h"
#include "caml/domain.h"
#include "caml/fail.h"
#include "caml/io.h"
Expand Down Expand Up @@ -558,6 +559,10 @@ CAMLprim value caml_thread_new(value clos) /* ML */
caml_thread_t th;
st_retcode err;

#ifndef NATIVE_CODE
if (caml_debugger_in_use)
caml_fatal_error("ocamldebug does not support multithreaded programs");
#endif
/* Create a thread info block */
th = caml_thread_new_info();
if (th == NULL) caml_raise_out_of_memory();
Expand Down
8 changes: 3 additions & 5 deletions runtime/debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,9 @@ static void open_connection(void)
dbg_in = caml_open_descriptor_in(dbg_socket);
dbg_out = caml_open_descriptor_out(dbg_socket);
/* The code in this file does not bracket channel I/O operations with
Lock and Unlock, so fail if those are not no-ops. */
if (caml_channel_mutex_lock != NULL ||
caml_channel_mutex_unlock != NULL ||
caml_channel_mutex_unlock_exn != NULL)
caml_fatal_error("debugger does not support channel locks");
Lock and Unlock, but this is safe because the debugger only works
with single-threaded programs. The program being debugged
will abort when it creates a thread. */
if (!caml_debugger_in_use) caml_putword(dbg_out, -1); /* first connection */
#ifdef _WIN32
caml_putword(dbg_out, _getpid());
Expand Down