From fd9be359b0947f55e40188f1de9400380a3abcab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Mon, 31 Jan 2022 00:31:05 +0100 Subject: [PATCH 1/6] subprojects: bump boxfort revision Support macOS "debugserver" and fallback "idle" debug method --- subprojects/boxfort.wrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/boxfort.wrap b/subprojects/boxfort.wrap index b2f83619..04355472 100644 --- a/subprojects/boxfort.wrap +++ b/subprojects/boxfort.wrap @@ -1,4 +1,4 @@ [wrap-git] directory = boxfort url = https://github.com/Snaipe/BoxFort.git -revision = 46cfaebead74bd1d2898afb66a06ec6badce4326 +revision = fe06439edd619ef574cf897195f0976bb60e4781 From 5b0a4b52dbc26860601c1269da4bbe7154f6c866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Mon, 31 Jan 2022 00:32:27 +0100 Subject: [PATCH 2/6] core: fall back to "idle" debugging method when debugger can not be found This is done only when no specific debugger type is specified by the user. --- src/core/runner_coroutine.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/runner_coroutine.c b/src/core/runner_coroutine.c index fb79142e..b78150e5 100644 --- a/src/core/runner_coroutine.c +++ b/src/core/runner_coroutine.c @@ -325,6 +325,10 @@ static bxf_instance *run_test(struct run_next_context *ctx, default: break; } } + + if (criterion_options.debug == CR_DBG_NATIVE) + BXF_DBG_ENABLE_FALLBACK(debugger); + if (!debugger) cr_panic("Could not choose the debugger server for an " "unknown compiler"); @@ -347,7 +351,7 @@ static bxf_instance *run_test(struct run_next_context *ctx, if (rc < 0) { if (rc == -ENOENT && criterion_options.debug) { const char *dbgname = ""; - switch (sp.debug.debugger) { + switch (BXF_DBG_GET_DEBUGGER(sp.debug.debugger)) { case BXF_DBG_GDB: dbgname = "gdbserver"; break; case BXF_DBG_LLDB: dbgname = "lldb-server"; break; case BXF_DBG_WINDBG: dbgname = "windbg"; break; @@ -364,8 +368,12 @@ static bxf_instance *run_test(struct run_next_context *ctx, bxf_context_term(inst_ctx); + if (criterion_options.debug == CR_DBG_NATIVE && instance->status.stopped) { + criterion_pinfo(CRITERION_PREFIX_DEBUG, "Default debugger can not be found, falling back to \"idle\" mode\n"); + } + /* TODO: integrate this to the logger after refactor */ - if (criterion_options.debug == CR_DBG_IDLE) { + if (criterion_options.debug == CR_DBG_IDLE || instance->status.stopped) { criterion_pinfo(CRITERION_PREFIX_DEBUG, _(msg_print_pid), ctx->test->category, ctx->test->name, From 1b0e95c73033e880560f90f63316e98cd9c81675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Mon, 31 Jan 2022 01:33:04 +0100 Subject: [PATCH 3/6] doc: add debugging instructions for macOS --- doc/debug.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/debug.rst b/doc/debug.rst index 42a1c2f5..ef380da9 100644 --- a/doc/debug.rst +++ b/doc/debug.rst @@ -63,6 +63,27 @@ and run the test with ``continue`` To use a different port use ``--debug --debug-transport=:`` +Debugging on macOS +------------------ + +macOS has its own LLVM-based debugger called ``debugserver``. +Make sure the debugger server is available in your PATH (by default, it is not). + +You will probably need sudo privileges as well: + +.. code-block:: bash + + $ sudo ./test --debug + Listening to port 1234 for a connection from *... + +In another terminal, connect to the debug session: + +.. code-block:: bash + + $ sudo lldb ./test + (lldb) gdb-remote localhost:1234 + + Debugging with an unsupported debugger -------------------------------------- From e9728ea8c111e3a9ad5fba8eb07128d18235bc02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Sat, 12 Feb 2022 16:00:50 +0100 Subject: [PATCH 4/6] dependencies: temporarily use debugbreak fork The following contribution fixes a gcc compilation issue on macOS: https://github.com/scottt/debugbreak/pull/25 This commit replaces the upstream repo with a fork until the above PR gets integrated into the upstream master. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 77d80d84..88ddbb2d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://github.com/attractivechaos/klib.git [submodule "dependencies/debugbreak"] path = dependencies/debugbreak - url = https://github.com/scottt/debugbreak + url = https://github.com/MrAnno/debugbreak.git From 85b49a03312e56d9c764bb7b003c5008999a04fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Sat, 12 Feb 2022 16:02:48 +0100 Subject: [PATCH 5/6] dependencies: bump debugbreak revision Apple silicon support --- dependencies/debugbreak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/debugbreak b/dependencies/debugbreak index 6b79ec8d..83bf7e93 160000 --- a/dependencies/debugbreak +++ b/dependencies/debugbreak @@ -1 +1 @@ -Subproject commit 6b79ec8d8f8d4603111f580a0537f8f31c484c32 +Subproject commit 83bf7e933311b88613cbaadeced9c2e2c811054a From 1cc3911fe0029ca22ef07debde9fce0e36be2013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Sat, 12 Feb 2022 16:13:11 +0100 Subject: [PATCH 6/6] changelog: add latest changes --- ChangeLog | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 747cfa08..8878193b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -55,11 +55,14 @@ * Fix: fixed crash when passing an empty string to cr_log_info (Ersikan). * Fix: fixed compilation errors on macOS (Kare Nuorteva, László Várady). * Fix: fixed --debug flag aborting runner with gdbserver >= 8.3. + * Fix: fixed gdb stepping issue with '--debug' on macOS (Apple silicon). * Misc: various documentation fixes (Oleksii Vilchanskyi, Sam Zaydel, Karim - Dridi, Florent Poinsard, Tim Gates, László Várady). + Dridi, Florent Poinsard, Tim Gates, László Várady, Japroz Saini). * Misc: various updates to dependencies (László Várady). * Misc: various build system fixes (Tomasz Sieprawski, László Várady). * Misc: various fixes to the autotools example (Bruno Belany). + * Misc: from now on, --debug will fall back to the idle method in case no + debugger can be found. The full git changelog may be accessed with `git log v2.3.3..v2.4.0`.