From 128d8a8639a5b5d5b75b2069fe21d6cbed314a11 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Wed, 3 Jan 2024 13:54:27 +0800 Subject: [PATCH 01/67] add -attach for linux.infloop --- suite/tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index 3b1f860e30..399a92a6c5 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -1412,7 +1412,7 @@ function(torun test key source native standalone_dr dr_ops exe_ops added_out pas set(exe_ops "${exe_ops};-v;-attach") endif () if ("${runall}" MATCHES "") - set(exe_ops "${exe_ops};-v;") + set(exe_ops "${exe_ops};-v;-attach") endif () if ("${runall}" MATCHES "") set(exe_ops "${exe_ops};-block") From 83f71f01aee8c514fa34d34a53b4e107038804a1 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Wed, 3 Jan 2024 16:42:24 +0800 Subject: [PATCH 02/67] delete detach test --- suite/tests/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index 399a92a6c5..cfd5267f1f 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -1411,9 +1411,6 @@ function(torun test key source native standalone_dr dr_ops exe_ops added_out pas # is failing). set(exe_ops "${exe_ops};-v;-attach") endif () - if ("${runall}" MATCHES "") - set(exe_ops "${exe_ops};-v;-attach") - endif () if ("${runall}" MATCHES "") set(exe_ops "${exe_ops};-block") endif () @@ -2577,7 +2574,7 @@ endif (ANNOTATIONS AND NOT ARM) if (NOT ANDROID) # TODO i#38: Port test to Android. tobuild_ci(client.attach_test client-interface/attach_test.runall "" "" "") - if ((LINUX OR WIN32) AND NOT RISCV64) + if (WIN32) tobuild_ci(client.detach_test client-interface/detach_test.runall "" "" "") endif () if (UNIX) From b0de67f994f1ecedd86b6d987bb14362b26c7b36 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Wed, 3 Jan 2024 17:39:58 +0800 Subject: [PATCH 03/67] add tobuild_ci condition --- suite/tests/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index cfd5267f1f..399a92a6c5 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -1411,6 +1411,9 @@ function(torun test key source native standalone_dr dr_ops exe_ops added_out pas # is failing). set(exe_ops "${exe_ops};-v;-attach") endif () + if ("${runall}" MATCHES "") + set(exe_ops "${exe_ops};-v;-attach") + endif () if ("${runall}" MATCHES "") set(exe_ops "${exe_ops};-block") endif () @@ -2574,7 +2577,7 @@ endif (ANNOTATIONS AND NOT ARM) if (NOT ANDROID) # TODO i#38: Port test to Android. tobuild_ci(client.attach_test client-interface/attach_test.runall "" "" "") - if (WIN32) + if ((LINUX OR WIN32) AND NOT RISCV64) tobuild_ci(client.detach_test client-interface/detach_test.runall "" "" "") endif () if (UNIX) From b7b440c1a7555e74624e8d606d3adce990b11c2f Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Wed, 3 Jan 2024 19:21:08 +0800 Subject: [PATCH 04/67] debug kill_background_process --- suite/tests/CMakeLists.txt | 4 +--- suite/tests/runall.cmake | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index 399a92a6c5..8137e7826d 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -2577,9 +2577,7 @@ endif (ANNOTATIONS AND NOT ARM) if (NOT ANDROID) # TODO i#38: Port test to Android. tobuild_ci(client.attach_test client-interface/attach_test.runall "" "" "") - if ((LINUX OR WIN32) AND NOT RISCV64) - tobuild_ci(client.detach_test client-interface/detach_test.runall "" "" "") - endif () + tobuild_ci(client.detach_test client-interface/detach_test.runall "" "" "") if (UNIX) # Test attaching during a blocking syscall. torunonly_ci(client.attach_blocking linux.infloop client.attach_test.dll diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 08eea9ed4d..e1d4a919d0 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -154,8 +154,9 @@ if (pidfile) do_sleep(0.1) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - kill_background_process(ON) message(FATAL_ERROR "Timed out waiting for ${pidfile}") + kill_background_process(ON) + #message(FATAL_ERROR "Timed out waiting for ${pidfile}") endif () endwhile () file(READ "${pidfile}" pid) @@ -164,8 +165,9 @@ if (pidfile) do_sleep(0.1) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) + message(FATAL_ERROR "Timed out waiting for ${pidfile} content") kill_background_process(ON) - message(FATAL_ERROR "Timed out waiting for ${pidfile} content") + #message(FATAL_ERROR "Timed out waiting for ${pidfile} content") endif () file(READ "${pidfile}" pid) endwhile () @@ -177,6 +179,7 @@ while (NOT EXISTS "${out}") do_sleep(0.1) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) + message(FATAL_ERROR "Timed out waiting for ${out}") kill_background_process(ON) message(FATAL_ERROR "Timed out waiting for ${out}") endif () @@ -189,8 +192,9 @@ while (NOT "${output}" MATCHES "\n") file(READ "${out}" output) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - kill_background_process(ON) message(FATAL_ERROR "Timed out waiting for newline") + kill_background_process(ON) + #message(FATAL_ERROR "Timed out waiting for newline") endif () endwhile() @@ -215,8 +219,9 @@ elseif ("${nudge}" MATCHES "") # combine out and err set(nudge_err "${nudge_out}${nudge_err}") if (nudge_result) - kill_background_process(ON) message(FATAL_ERROR "*** ${nudge_cmd} failed (${nudge_result}): ${nudge_err}***\n") + kill_background_process(ON) + #message(FATAL_ERROR "*** ${nudge_cmd} failed (${nudge_result}): ${nudge_err}***\n") endif (nudge_result) elseif ("${nudge}" MATCHES "") set(nudge_cmd run_in_bg) @@ -232,8 +237,9 @@ elseif ("${nudge}" MATCHES "") # Combine out and err. set(nudge_err "${nudge_out}${nudge_err}") if (nudge_result) - kill_background_process(ON) message(FATAL_ERROR "*** ${nudge_cmd} failed (${nudge_result}): ${nudge_err}***\n") + kill_background_process(ON) + #message(FATAL_ERROR "*** ${nudge_cmd} failed (${nudge_result}): ${nudge_err}***\n") endif (nudge_result) else () # drnudgeunix and drconfig have different syntax: @@ -269,8 +275,9 @@ if ("${orig_nudge}" MATCHES "-client") string(LENGTH "${output}" new_outlen) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - kill_background_process(ON) message(FATAL_ERROR "Timed out waiting for more output") + kill_background_process(ON) + #message(FATAL_ERROR "Timed out waiting for more output") endif () endwhile() elseif ("${orig_nudge}" MATCHES "" OR "${orig_nudge}" MATCHES "") @@ -281,8 +288,9 @@ elseif ("${orig_nudge}" MATCHES "" OR "${orig_nudge}" MATCHES "" file(READ "${out}" output) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) + message(FATAL_ERROR "Timed out waiting for thread init") kill_background_process(ON) - message(FATAL_ERROR "Timed out waiting for thread init") + #message(FATAL_ERROR "Timed out waiting for thread init") endif () endwhile() else () @@ -308,12 +316,13 @@ if ("${orig_nudge}" MATCHES "") file(READ "${out}" output) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - kill_background_process(ON) message(FATAL_ERROR "Timed out waiting for detach") + kill_background_process(ON) +# message(FATAL_ERROR "Timed out waiting for detach") endif () endwhile() endif () - +message(FATAL_ERROR "kill_background_process(OFF) fail") kill_background_process(OFF) if (NOT "${fail_msg}" STREQUAL "") From ac172f16de548abb4e617ae192812b4d5a68055b Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Wed, 3 Jan 2024 19:24:01 +0800 Subject: [PATCH 05/67] debug kill_background_process --- suite/tests/runall.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index e1d4a919d0..54d25cc49c 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -165,7 +165,7 @@ if (pidfile) do_sleep(0.1) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - message(FATAL_ERROR "Timed out waiting for ${pidfile} content") + message(FATAL_ERROR "Timed out waiting for ${pidfile} content") kill_background_process(ON) #message(FATAL_ERROR "Timed out waiting for ${pidfile} content") endif () From 089e761fb0354a6ac9f3a814ec59284c1931249a Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Wed, 3 Jan 2024 19:25:57 +0800 Subject: [PATCH 06/67] debug kill_background_process --- suite/tests/runall.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 54d25cc49c..11f96d4828 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -288,7 +288,7 @@ elseif ("${orig_nudge}" MATCHES "" OR "${orig_nudge}" MATCHES "" file(READ "${out}" output) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - message(FATAL_ERROR "Timed out waiting for thread init") + message(FATAL_ERROR "Timed out waiting for thread init") kill_background_process(ON) #message(FATAL_ERROR "Timed out waiting for thread init") endif () From 22be424b66e068e0a4a8f87d2bfed2090e4fc597 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Wed, 3 Jan 2024 20:31:46 +0800 Subject: [PATCH 07/67] debug kill_background_process --- suite/tests/runall.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 11f96d4828..130f190b77 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -322,7 +322,8 @@ if ("${orig_nudge}" MATCHES "") endif () endwhile() endif () -message(FATAL_ERROR "kill_background_process(OFF) fail") +file(READ "${out}" output) +message(FATAL_ERROR ${output}) kill_background_process(OFF) if (NOT "${fail_msg}" STREQUAL "") From 4042be97e94b15821508c933bc851b24fc0ffc2f Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Wed, 3 Jan 2024 21:16:01 +0800 Subject: [PATCH 08/67] output results before kill_background_process(OFF) --- suite/tests/runall.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 130f190b77..3a42525554 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -323,7 +323,7 @@ if ("${orig_nudge}" MATCHES "") endwhile() endif () file(READ "${out}" output) -message(FATAL_ERROR ${output}) +message("${output}") kill_background_process(OFF) if (NOT "${fail_msg}" STREQUAL "") From 11c5e4a36fcca728c9997cebeb35861aa2c15328 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Wed, 3 Jan 2024 22:10:17 +0800 Subject: [PATCH 09/67] delete thread init --- suite/tests/runall.cmake | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 3a42525554..3ff1b5a515 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -280,26 +280,26 @@ if ("${orig_nudge}" MATCHES "-client") #message(FATAL_ERROR "Timed out waiting for more output") endif () endwhile() -elseif ("${orig_nudge}" MATCHES "" OR "${orig_nudge}" MATCHES "") - # Wait until thread init. - set(iters 0) - while (NOT "${output}" MATCHES "thread init\n") - do_sleep(0.1) - file(READ "${out}" output) - math(EXPR iters "${iters}+1") - if (${iters} GREATER ${MAX_ITERS}) - message(FATAL_ERROR "Timed out waiting for thread init") - kill_background_process(ON) - #message(FATAL_ERROR "Timed out waiting for thread init") - endif () - endwhile() +#elseif ("${orig_nudge}" MATCHES "" OR "${orig_nudge}" MATCHES "") +# # Wait until thread init. +# set(iters 0) +# while (NOT "${output}" MATCHES "thread init\n") +# do_sleep(0.1) +# file(READ "${out}" output) +# math(EXPR iters "${iters}+1") +# if (${iters} GREATER ${MAX_ITERS}) +# message(FATAL_ERROR "Timed out waiting for thread init") +# kill_background_process(ON) +# #message(FATAL_ERROR "Timed out waiting for thread init") +# endif () +# endwhile() else () # for reset or other DR tests there won't be further output # so we have to guess how long to wait. # FIXME: should we instead turn on stderr_mask? do_sleep(0.5) endif () - +do_sleep(5) if ("${orig_nudge}" MATCHES "") execute_process(COMMAND "${toolbindir}/${detach_cmd}" "-detach" ${pid} RESULT_VARIABLE detach_result From 62843be7545c40596e1899702ab000ebb5a79f35 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 10:04:06 +0800 Subject: [PATCH 10/67] add attach output --- suite/tests/client-interface/detach_test.dll.c | 1 + 1 file changed, 1 insertion(+) diff --git a/suite/tests/client-interface/detach_test.dll.c b/suite/tests/client-interface/detach_test.dll.c index a6d4cc9c3c..b07eef1b47 100644 --- a/suite/tests/client-interface/detach_test.dll.c +++ b/suite/tests/client-interface/detach_test.dll.c @@ -96,6 +96,7 @@ event_post_attach(void) { // We do not print here as the ordering is non-deterministic vs thread init. saw_attach_event = true; + dr_fprintf(STDERR, "attach\n"); } static void From fd06dc0c5f03a233c5fefacfa02e124483676da9 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 10:57:31 +0800 Subject: [PATCH 11/67] add attach output --- suite/tests/client-interface/attach_test.dll.c | 1 + 1 file changed, 1 insertion(+) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index ceeefb9a6f..f5ccf48b9e 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -96,6 +96,7 @@ event_post_attach(void) { // We do not print here as the ordering is non-deterministic vs thread init. saw_attach_event = true; + dr_fprintf(STDERR, "attach\n"); } DR_EXPORT From 20f6e8cb917e14cb3e2e23164418a477e6c65282 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 15:29:10 +0800 Subject: [PATCH 12/67] add done in dll.c --- suite/tests/client-interface/attach_test.dll.c | 8 ++++---- suite/tests/client-interface/detach_test.dll.c | 9 +++++---- suite/tests/linux/infloop.c | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index f5ccf48b9e..d662f05879 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -46,11 +46,11 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); -#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); -#else - /* The app prints 'done' for us. */ -#endif +//#ifdef WINDOWS +//#else +// /* The app prints 'done' for us. */ +//#endif } static void diff --git a/suite/tests/client-interface/detach_test.dll.c b/suite/tests/client-interface/detach_test.dll.c index b07eef1b47..866a6aa172 100644 --- a/suite/tests/client-interface/detach_test.dll.c +++ b/suite/tests/client-interface/detach_test.dll.c @@ -46,11 +46,12 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); -#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); -#else - /* The app prints 'done' for us. */ -#endif +//#ifdef WINDOWS +// dr_fprintf(STDERR, "done\n"); +//#else +// /* The app prints 'done' for us. */ +//#endif } static void diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index d85c8a75b0..062875338b 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ static void signal_handler(int sig) { - if (sig == SIGTERM) { + if (sig == SIGTERM && !for_attach) { print("done\n"); } exit(1); From d4d5783ff3d79c55af7c9d38392b935d546a8fd3 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 15:31:07 +0800 Subject: [PATCH 13/67] add done in dll.c --- suite/tests/client-interface/attach_test.dll.c | 8 ++++---- suite/tests/client-interface/detach_test.dll.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index d662f05879..841d130dd1 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -47,10 +47,10 @@ dr_exit(void) if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); dr_fprintf(STDERR, "done\n"); -//#ifdef WINDOWS -//#else -// /* The app prints 'done' for us. */ -//#endif + //#ifdef WINDOWS + //#else + // /* The app prints 'done' for us. */ + //#endif } static void diff --git a/suite/tests/client-interface/detach_test.dll.c b/suite/tests/client-interface/detach_test.dll.c index 866a6aa172..dd0cea1803 100644 --- a/suite/tests/client-interface/detach_test.dll.c +++ b/suite/tests/client-interface/detach_test.dll.c @@ -47,11 +47,11 @@ dr_exit(void) if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); dr_fprintf(STDERR, "done\n"); -//#ifdef WINDOWS -// dr_fprintf(STDERR, "done\n"); -//#else -// /* The app prints 'done' for us. */ -//#endif + //#ifdef WINDOWS + // dr_fprintf(STDERR, "done\n"); + //#else + // /* The app prints 'done' for us. */ + //#endif } static void From 308faa5faa696c36d25bc6f28dfbaee0a80d0c90 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 15:46:33 +0800 Subject: [PATCH 14/67] add done in dll.c --- suite/tests/linux/infloop.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index 062875338b..912c15fbe5 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -44,7 +44,7 @@ #include #include #include - +bool for_attach = false, block = false; static void signal_handler(int sig) { @@ -59,7 +59,6 @@ main(int argc, const char *argv[]) { int arg_offs = 1; long long counter = 0; - bool for_attach = false, block = false; while (arg_offs < argc && argv[arg_offs][0] == '-') { if (strcmp(argv[arg_offs], "-v") == 0) { /* enough verbosity to satisfy runall.cmake: needs an initial and a From 4b3f9cec5a067872456cd50b6847e5e41a6fbe25 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 16:10:18 +0800 Subject: [PATCH 15/67] resume runall.cmake --- suite/tests/runall.cmake | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 3ff1b5a515..a85a2a33b8 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -156,7 +156,6 @@ if (pidfile) if (${iters} GREATER ${MAX_ITERS}) message(FATAL_ERROR "Timed out waiting for ${pidfile}") kill_background_process(ON) - #message(FATAL_ERROR "Timed out waiting for ${pidfile}") endif () endwhile () file(READ "${pidfile}" pid) @@ -167,7 +166,6 @@ if (pidfile) if (${iters} GREATER ${MAX_ITERS}) message(FATAL_ERROR "Timed out waiting for ${pidfile} content") kill_background_process(ON) - #message(FATAL_ERROR "Timed out waiting for ${pidfile} content") endif () file(READ "${pidfile}" pid) endwhile () @@ -181,7 +179,6 @@ while (NOT EXISTS "${out}") if (${iters} GREATER ${MAX_ITERS}) message(FATAL_ERROR "Timed out waiting for ${out}") kill_background_process(ON) - message(FATAL_ERROR "Timed out waiting for ${out}") endif () endwhile () file(READ "${out}" output) @@ -194,7 +191,6 @@ while (NOT "${output}" MATCHES "\n") if (${iters} GREATER ${MAX_ITERS}) message(FATAL_ERROR "Timed out waiting for newline") kill_background_process(ON) - #message(FATAL_ERROR "Timed out waiting for newline") endif () endwhile() @@ -221,7 +217,6 @@ elseif ("${nudge}" MATCHES "") if (nudge_result) message(FATAL_ERROR "*** ${nudge_cmd} failed (${nudge_result}): ${nudge_err}***\n") kill_background_process(ON) - #message(FATAL_ERROR "*** ${nudge_cmd} failed (${nudge_result}): ${nudge_err}***\n") endif (nudge_result) elseif ("${nudge}" MATCHES "") set(nudge_cmd run_in_bg) @@ -239,7 +234,6 @@ elseif ("${nudge}" MATCHES "") if (nudge_result) message(FATAL_ERROR "*** ${nudge_cmd} failed (${nudge_result}): ${nudge_err}***\n") kill_background_process(ON) - #message(FATAL_ERROR "*** ${nudge_cmd} failed (${nudge_result}): ${nudge_err}***\n") endif (nudge_result) else () # drnudgeunix and drconfig have different syntax: @@ -277,29 +271,27 @@ if ("${orig_nudge}" MATCHES "-client") if (${iters} GREATER ${MAX_ITERS}) message(FATAL_ERROR "Timed out waiting for more output") kill_background_process(ON) - #message(FATAL_ERROR "Timed out waiting for more output") endif () endwhile() -#elseif ("${orig_nudge}" MATCHES "" OR "${orig_nudge}" MATCHES "") -# # Wait until thread init. -# set(iters 0) -# while (NOT "${output}" MATCHES "thread init\n") -# do_sleep(0.1) -# file(READ "${out}" output) -# math(EXPR iters "${iters}+1") -# if (${iters} GREATER ${MAX_ITERS}) -# message(FATAL_ERROR "Timed out waiting for thread init") -# kill_background_process(ON) -# #message(FATAL_ERROR "Timed out waiting for thread init") -# endif () -# endwhile() +elseif ("${orig_nudge}" MATCHES "" OR "${orig_nudge}" MATCHES "") + # Wait until thread init. + set(iters 0) + while (NOT "${output}" MATCHES "thread init\n") + do_sleep(0.1) + file(READ "${out}" output) + math(EXPR iters "${iters}+1") + if (${iters} GREATER ${MAX_ITERS}) + message(FATAL_ERROR "Timed out waiting for thread init") + kill_background_process(ON) + endif () + endwhile() else () # for reset or other DR tests there won't be further output # so we have to guess how long to wait. # FIXME: should we instead turn on stderr_mask? do_sleep(0.5) endif () -do_sleep(5) + if ("${orig_nudge}" MATCHES "") execute_process(COMMAND "${toolbindir}/${detach_cmd}" "-detach" ${pid} RESULT_VARIABLE detach_result @@ -318,12 +310,10 @@ if ("${orig_nudge}" MATCHES "") if (${iters} GREATER ${MAX_ITERS}) message(FATAL_ERROR "Timed out waiting for detach") kill_background_process(ON) -# message(FATAL_ERROR "Timed out waiting for detach") endif () endwhile() endif () -file(READ "${out}" output) -message("${output}") + kill_background_process(OFF) if (NOT "${fail_msg}" STREQUAL "") From 4887bf9e0797401f4f36e50faee854aae9c584bb Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 16:13:35 +0800 Subject: [PATCH 16/67] resume runall.cmake --- suite/tests/runall.cmake | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index a85a2a33b8..08eea9ed4d 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -154,8 +154,8 @@ if (pidfile) do_sleep(0.1) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - message(FATAL_ERROR "Timed out waiting for ${pidfile}") kill_background_process(ON) + message(FATAL_ERROR "Timed out waiting for ${pidfile}") endif () endwhile () file(READ "${pidfile}" pid) @@ -164,8 +164,8 @@ if (pidfile) do_sleep(0.1) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - message(FATAL_ERROR "Timed out waiting for ${pidfile} content") kill_background_process(ON) + message(FATAL_ERROR "Timed out waiting for ${pidfile} content") endif () file(READ "${pidfile}" pid) endwhile () @@ -177,8 +177,8 @@ while (NOT EXISTS "${out}") do_sleep(0.1) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - message(FATAL_ERROR "Timed out waiting for ${out}") kill_background_process(ON) + message(FATAL_ERROR "Timed out waiting for ${out}") endif () endwhile () file(READ "${out}" output) @@ -189,8 +189,8 @@ while (NOT "${output}" MATCHES "\n") file(READ "${out}" output) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - message(FATAL_ERROR "Timed out waiting for newline") kill_background_process(ON) + message(FATAL_ERROR "Timed out waiting for newline") endif () endwhile() @@ -215,8 +215,8 @@ elseif ("${nudge}" MATCHES "") # combine out and err set(nudge_err "${nudge_out}${nudge_err}") if (nudge_result) - message(FATAL_ERROR "*** ${nudge_cmd} failed (${nudge_result}): ${nudge_err}***\n") kill_background_process(ON) + message(FATAL_ERROR "*** ${nudge_cmd} failed (${nudge_result}): ${nudge_err}***\n") endif (nudge_result) elseif ("${nudge}" MATCHES "") set(nudge_cmd run_in_bg) @@ -232,8 +232,8 @@ elseif ("${nudge}" MATCHES "") # Combine out and err. set(nudge_err "${nudge_out}${nudge_err}") if (nudge_result) - message(FATAL_ERROR "*** ${nudge_cmd} failed (${nudge_result}): ${nudge_err}***\n") kill_background_process(ON) + message(FATAL_ERROR "*** ${nudge_cmd} failed (${nudge_result}): ${nudge_err}***\n") endif (nudge_result) else () # drnudgeunix and drconfig have different syntax: @@ -269,8 +269,8 @@ if ("${orig_nudge}" MATCHES "-client") string(LENGTH "${output}" new_outlen) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - message(FATAL_ERROR "Timed out waiting for more output") kill_background_process(ON) + message(FATAL_ERROR "Timed out waiting for more output") endif () endwhile() elseif ("${orig_nudge}" MATCHES "" OR "${orig_nudge}" MATCHES "") @@ -281,8 +281,8 @@ elseif ("${orig_nudge}" MATCHES "" OR "${orig_nudge}" MATCHES "" file(READ "${out}" output) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - message(FATAL_ERROR "Timed out waiting for thread init") kill_background_process(ON) + message(FATAL_ERROR "Timed out waiting for thread init") endif () endwhile() else () @@ -308,8 +308,8 @@ if ("${orig_nudge}" MATCHES "") file(READ "${out}" output) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - message(FATAL_ERROR "Timed out waiting for detach") kill_background_process(ON) + message(FATAL_ERROR "Timed out waiting for detach") endif () endwhile() endif () From 8dba978d5cf8692cb91a1eebd950d0c78b24171f Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 16:38:50 +0800 Subject: [PATCH 17/67] delete attach --- suite/tests/client-interface/attach_test.dll.c | 2 +- suite/tests/client-interface/detach_test.dll.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index 841d130dd1..930a7300fa 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -96,7 +96,7 @@ event_post_attach(void) { // We do not print here as the ordering is non-deterministic vs thread init. saw_attach_event = true; - dr_fprintf(STDERR, "attach\n"); +// dr_fprintf(STDERR, "attach\n"); } DR_EXPORT diff --git a/suite/tests/client-interface/detach_test.dll.c b/suite/tests/client-interface/detach_test.dll.c index dd0cea1803..f36cee6009 100644 --- a/suite/tests/client-interface/detach_test.dll.c +++ b/suite/tests/client-interface/detach_test.dll.c @@ -97,7 +97,7 @@ event_post_attach(void) { // We do not print here as the ordering is non-deterministic vs thread init. saw_attach_event = true; - dr_fprintf(STDERR, "attach\n"); +// dr_fprintf(STDERR, "attach\n"); } static void From 04afb2b40d1e8f14194f63df37469c4ef52738cc Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 16:44:07 +0800 Subject: [PATCH 18/67] delete attach --- suite/tests/client-interface/attach_test.dll.c | 2 +- suite/tests/client-interface/detach_test.dll.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index 930a7300fa..7b88ea17bb 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -96,7 +96,7 @@ event_post_attach(void) { // We do not print here as the ordering is non-deterministic vs thread init. saw_attach_event = true; -// dr_fprintf(STDERR, "attach\n"); + // dr_fprintf(STDERR, "attach\n"); } DR_EXPORT diff --git a/suite/tests/client-interface/detach_test.dll.c b/suite/tests/client-interface/detach_test.dll.c index f36cee6009..f60e268781 100644 --- a/suite/tests/client-interface/detach_test.dll.c +++ b/suite/tests/client-interface/detach_test.dll.c @@ -97,7 +97,7 @@ event_post_attach(void) { // We do not print here as the ordering is non-deterministic vs thread init. saw_attach_event = true; -// dr_fprintf(STDERR, "attach\n"); + // dr_fprintf(STDERR, "attach\n"); } static void From 2f3931b6e583d3c851c16101ca07a4af1e70409c Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 17:20:29 +0800 Subject: [PATCH 19/67] add output --- suite/tests/runall.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 08eea9ed4d..04c41fec07 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -313,6 +313,7 @@ if ("${orig_nudge}" MATCHES "") endif () endwhile() endif () +message("${output}") kill_background_process(OFF) From 9a4959bbd7544cc6238bf19675067befe9327e68 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 18:18:32 +0800 Subject: [PATCH 20/67] rm output --- suite/tests/runall.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 04c41fec07..521b763a0e 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -313,7 +313,7 @@ if ("${orig_nudge}" MATCHES "") endif () endwhile() endif () -message("${output}") +#message("${output}") kill_background_process(OFF) From 9da12f4341ce551e6646a262a7e4acf144297dbd Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 18:53:03 +0800 Subject: [PATCH 21/67] do not kill detach process --- suite/tests/runall.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 521b763a0e..94268fc410 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -314,8 +314,9 @@ if ("${orig_nudge}" MATCHES "") endwhile() endif () #message("${output}") - -kill_background_process(OFF) +if (NOT "${orig_nudge}" MATCHES "") + kill_background_process(OFF) +endif () if (NOT "${fail_msg}" STREQUAL "") message(FATAL_ERROR "${fail_msg}") From 0e410facca0e6571382a78da9d9a7f5536c120e1 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 22:14:17 +0800 Subject: [PATCH 22/67] disable assert --- core/stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/stats.c b/core/stats.c index a76a1bcf1f..7681a159fd 100644 --- a/core/stats.c +++ b/core/stats.c @@ -358,8 +358,8 @@ kstat_thread_exit(dcontext_t *dcontext) return; LOG(THREAD, LOG_ALL, 2, "kstat_thread_exit: kstats stack is:\n"); DOLOG(2, LOG_STATS, { kstats_dump_stack(dcontext); }); - KSTOP_DC(dcontext, thread_measured); - ASSERT(old_thread_kstats->stack_kstats.depth == 1); + //KSTOP_DC(dcontext, thread_measured); + //ASSERT(old_thread_kstats->stack_kstats.depth == 1); dump_thread_kstats(dcontext); /* a good time to combine all of these with the global statistics */ From 2a7e3c1622a00844407853c5eb0f6e8239aabde5 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 22:17:05 +0800 Subject: [PATCH 23/67] disable assert --- core/stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/stats.c b/core/stats.c index 7681a159fd..65589efb29 100644 --- a/core/stats.c +++ b/core/stats.c @@ -358,8 +358,8 @@ kstat_thread_exit(dcontext_t *dcontext) return; LOG(THREAD, LOG_ALL, 2, "kstat_thread_exit: kstats stack is:\n"); DOLOG(2, LOG_STATS, { kstats_dump_stack(dcontext); }); - //KSTOP_DC(dcontext, thread_measured); - //ASSERT(old_thread_kstats->stack_kstats.depth == 1); + // KSTOP_DC(dcontext, thread_measured); + // ASSERT(old_thread_kstats->stack_kstats.depth == 1); dump_thread_kstats(dcontext); /* a good time to combine all of these with the global statistics */ From 497e315b818819a82f2d654d92c0b1e3635a7709 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 5 Jan 2024 22:41:33 +0800 Subject: [PATCH 24/67] resume: disable assert --- core/stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/stats.c b/core/stats.c index 65589efb29..a76a1bcf1f 100644 --- a/core/stats.c +++ b/core/stats.c @@ -358,8 +358,8 @@ kstat_thread_exit(dcontext_t *dcontext) return; LOG(THREAD, LOG_ALL, 2, "kstat_thread_exit: kstats stack is:\n"); DOLOG(2, LOG_STATS, { kstats_dump_stack(dcontext); }); - // KSTOP_DC(dcontext, thread_measured); - // ASSERT(old_thread_kstats->stack_kstats.depth == 1); + KSTOP_DC(dcontext, thread_measured); + ASSERT(old_thread_kstats->stack_kstats.depth == 1); dump_thread_kstats(dcontext); /* a good time to combine all of these with the global statistics */ From 7a18837be15108b8eac6e395ab5ac99676b5afab Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sat, 6 Jan 2024 15:45:01 +0800 Subject: [PATCH 25/67] Update runall.cmake --- suite/tests/runall.cmake | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 94268fc410..6aed176bda 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -313,10 +313,11 @@ if ("${orig_nudge}" MATCHES "") endif () endwhile() endif () -#message("${output}") -if (NOT "${orig_nudge}" MATCHES "") - kill_background_process(OFF) -endif () +message("${output}") +kill_background_process(OFF) +#if (NOT "${orig_nudge}" MATCHES "") +# kill_background_process(OFF) +#endif () if (NOT "${fail_msg}" STREQUAL "") message(FATAL_ERROR "${fail_msg}") From f30e10c7857671826c1e475a7e8807dc8141aeb5 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sat, 6 Jan 2024 17:02:26 +0800 Subject: [PATCH 26/67] Update runall.cmake --- suite/tests/runall.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 6aed176bda..12334cc0b9 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -308,12 +308,13 @@ if ("${orig_nudge}" MATCHES "") file(READ "${out}" output) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) + message("Detach does not be successful.") kill_background_process(ON) message(FATAL_ERROR "Timed out waiting for detach") endif () endwhile() endif () -message("${output}") +message("${out}") kill_background_process(OFF) #if (NOT "${orig_nudge}" MATCHES "") # kill_background_process(OFF) From d3d602563a81d0cdd72224ad29a8f3683aab439d Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sat, 6 Jan 2024 17:32:45 +0800 Subject: [PATCH 27/67] Update runall.cmake --- suite/tests/runall.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 12334cc0b9..06d8ed2c3d 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -314,8 +314,8 @@ if ("${orig_nudge}" MATCHES "") endif () endwhile() endif () -message("${out}") -kill_background_process(OFF) +#message("${out}") +#kill_background_process(OFF) #if (NOT "${orig_nudge}" MATCHES "") # kill_background_process(OFF) #endif () From b6ca286eaf60a4b1a26a20a6a7f1d279694b5b0b Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 09:42:55 +0800 Subject: [PATCH 28/67] Update stats.c --- core/stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/stats.c b/core/stats.c index a76a1bcf1f..7681a159fd 100644 --- a/core/stats.c +++ b/core/stats.c @@ -358,8 +358,8 @@ kstat_thread_exit(dcontext_t *dcontext) return; LOG(THREAD, LOG_ALL, 2, "kstat_thread_exit: kstats stack is:\n"); DOLOG(2, LOG_STATS, { kstats_dump_stack(dcontext); }); - KSTOP_DC(dcontext, thread_measured); - ASSERT(old_thread_kstats->stack_kstats.depth == 1); + //KSTOP_DC(dcontext, thread_measured); + //ASSERT(old_thread_kstats->stack_kstats.depth == 1); dump_thread_kstats(dcontext); /* a good time to combine all of these with the global statistics */ From ff3d5a0668961651600bd0d33e5c1e3d2f4993d0 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 09:44:27 +0800 Subject: [PATCH 29/67] Update stats.c --- core/stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/stats.c b/core/stats.c index 7681a159fd..65589efb29 100644 --- a/core/stats.c +++ b/core/stats.c @@ -358,8 +358,8 @@ kstat_thread_exit(dcontext_t *dcontext) return; LOG(THREAD, LOG_ALL, 2, "kstat_thread_exit: kstats stack is:\n"); DOLOG(2, LOG_STATS, { kstats_dump_stack(dcontext); }); - //KSTOP_DC(dcontext, thread_measured); - //ASSERT(old_thread_kstats->stack_kstats.depth == 1); + // KSTOP_DC(dcontext, thread_measured); + // ASSERT(old_thread_kstats->stack_kstats.depth == 1); dump_thread_kstats(dcontext); /* a good time to combine all of these with the global statistics */ From 82126faf2da668f9a60d955d1600be138275c8d5 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 10:43:10 +0800 Subject: [PATCH 30/67] Update runall.cmake --- suite/tests/runall.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 06d8ed2c3d..8b730c27f9 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -315,7 +315,7 @@ if ("${orig_nudge}" MATCHES "") endwhile() endif () #message("${out}") -#kill_background_process(OFF) +kill_background_process(OFF) #if (NOT "${orig_nudge}" MATCHES "") # kill_background_process(OFF) #endif () From a24c6a4e063af43d7404be4fd9283d66b4c3e63a Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 14:30:31 +0800 Subject: [PATCH 31/67] Update CMakeLists.txt --- suite/tests/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index fe0656b93d..2964482d43 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -1412,7 +1412,7 @@ function(torun test key source native standalone_dr dr_ops exe_ops added_out pas set(exe_ops "${exe_ops};-v;-attach") endif () if ("${runall}" MATCHES "") - set(exe_ops "${exe_ops};-v;-attach") + set(exe_ops "${exe_ops};-v") endif () if ("${runall}" MATCHES "") set(exe_ops "${exe_ops};-block") @@ -2577,7 +2577,9 @@ endif (ANNOTATIONS AND NOT ARM) if (NOT ANDROID) # TODO i#38: Port test to Android. tobuild_ci(client.attach_test client-interface/attach_test.runall "" "" "") - tobuild_ci(client.detach_test client-interface/detach_test.runall "" "" "") + if ((LINUX OR WIN32) AND NOT RISCV64) + tobuild_ci(client.detach_test client-interface/detach_test.runall "" "" "") + endif () if (UNIX) # Test attaching during a blocking syscall. torunonly_ci(client.attach_blocking linux.infloop client.attach_test.dll From 98e6fe84d4d98614ee0b3cb7eaa394769ecc8a3b Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 14:32:32 +0800 Subject: [PATCH 32/67] Update detach_test.dll.c --- suite/tests/client-interface/detach_test.dll.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/suite/tests/client-interface/detach_test.dll.c b/suite/tests/client-interface/detach_test.dll.c index f60e268781..00abb453a8 100644 --- a/suite/tests/client-interface/detach_test.dll.c +++ b/suite/tests/client-interface/detach_test.dll.c @@ -46,12 +46,12 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); + //dr_fprintf(STDERR, "done\n"); +#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); - //#ifdef WINDOWS - // dr_fprintf(STDERR, "done\n"); - //#else - // /* The app prints 'done' for us. */ - //#endif +#else + /* The app prints 'done' for us. */ +#endif } static void From b26a75d7a03bb44e1069070f6d2f01e3213d8c54 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 14:33:00 +0800 Subject: [PATCH 33/67] Update detach_test.dll.c --- suite/tests/client-interface/detach_test.dll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/client-interface/detach_test.dll.c b/suite/tests/client-interface/detach_test.dll.c index 00abb453a8..3c77f40520 100644 --- a/suite/tests/client-interface/detach_test.dll.c +++ b/suite/tests/client-interface/detach_test.dll.c @@ -50,7 +50,7 @@ dr_exit(void) #ifdef WINDOWS dr_fprintf(STDERR, "done\n"); #else - /* The app prints 'done' for us. */ + /* The app prints 'done' for us. */ #endif } From d1cd313e74440d80d4cf883935a2ff1b7376cdf7 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 14:40:44 +0800 Subject: [PATCH 34/67] Update detach_test.dll.c --- suite/tests/client-interface/detach_test.dll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/client-interface/detach_test.dll.c b/suite/tests/client-interface/detach_test.dll.c index 3c77f40520..66250766d4 100644 --- a/suite/tests/client-interface/detach_test.dll.c +++ b/suite/tests/client-interface/detach_test.dll.c @@ -46,7 +46,7 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); - //dr_fprintf(STDERR, "done\n"); + // dr_fprintf(STDERR, "done\n"); #ifdef WINDOWS dr_fprintf(STDERR, "done\n"); #else From b57033f00759d6671a6051a292550d4ba79be229 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 15:29:16 +0800 Subject: [PATCH 35/67] Update stats.c --- core/stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/stats.c b/core/stats.c index 65589efb29..a76a1bcf1f 100644 --- a/core/stats.c +++ b/core/stats.c @@ -358,8 +358,8 @@ kstat_thread_exit(dcontext_t *dcontext) return; LOG(THREAD, LOG_ALL, 2, "kstat_thread_exit: kstats stack is:\n"); DOLOG(2, LOG_STATS, { kstats_dump_stack(dcontext); }); - // KSTOP_DC(dcontext, thread_measured); - // ASSERT(old_thread_kstats->stack_kstats.depth == 1); + KSTOP_DC(dcontext, thread_measured); + ASSERT(old_thread_kstats->stack_kstats.depth == 1); dump_thread_kstats(dcontext); /* a good time to combine all of these with the global statistics */ From 84738b5c2de3f6c82f729c74d1262e58279bb23d Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 16:14:59 +0800 Subject: [PATCH 36/67] Update runall.cmake --- suite/tests/runall.cmake | 5 ----- 1 file changed, 5 deletions(-) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index 8b730c27f9..db3d881a6d 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -308,17 +308,12 @@ if ("${orig_nudge}" MATCHES "") file(READ "${out}" output) math(EXPR iters "${iters}+1") if (${iters} GREATER ${MAX_ITERS}) - message("Detach does not be successful.") kill_background_process(ON) message(FATAL_ERROR "Timed out waiting for detach") endif () endwhile() endif () -#message("${out}") kill_background_process(OFF) -#if (NOT "${orig_nudge}" MATCHES "") -# kill_background_process(OFF) -#endif () if (NOT "${fail_msg}" STREQUAL "") message(FATAL_ERROR "${fail_msg}") From db19c64a586fcb158363528474f210f9c127382e Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 16:16:25 +0800 Subject: [PATCH 37/67] Update CMakeLists.txt --- suite/tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index 2964482d43..f920b0d3f7 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -1412,7 +1412,7 @@ function(torun test key source native standalone_dr dr_ops exe_ops added_out pas set(exe_ops "${exe_ops};-v;-attach") endif () if ("${runall}" MATCHES "") - set(exe_ops "${exe_ops};-v") + set(exe_ops "${exe_ops};-v;") endif () if ("${runall}" MATCHES "") set(exe_ops "${exe_ops};-block") From 99c0ff266318f5faed2043a822bf5fb8d81e5d25 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 16:17:55 +0800 Subject: [PATCH 38/67] Update runall.cmake --- suite/tests/runall.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/suite/tests/runall.cmake b/suite/tests/runall.cmake index db3d881a6d..08eea9ed4d 100644 --- a/suite/tests/runall.cmake +++ b/suite/tests/runall.cmake @@ -313,6 +313,7 @@ if ("${orig_nudge}" MATCHES "") endif () endwhile() endif () + kill_background_process(OFF) if (NOT "${fail_msg}" STREQUAL "") From 2bac40b499a507069429258d0d370d3d4b4662f3 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 16:20:55 +0800 Subject: [PATCH 39/67] Update detach_test.dll.c --- suite/tests/client-interface/detach_test.dll.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/suite/tests/client-interface/detach_test.dll.c b/suite/tests/client-interface/detach_test.dll.c index 66250766d4..a6d4cc9c3c 100644 --- a/suite/tests/client-interface/detach_test.dll.c +++ b/suite/tests/client-interface/detach_test.dll.c @@ -46,7 +46,6 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); - // dr_fprintf(STDERR, "done\n"); #ifdef WINDOWS dr_fprintf(STDERR, "done\n"); #else @@ -97,7 +96,6 @@ event_post_attach(void) { // We do not print here as the ordering is non-deterministic vs thread init. saw_attach_event = true; - // dr_fprintf(STDERR, "attach\n"); } static void From dd33c53519371b8624eed77892a710bd5568a723 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 16:23:40 +0800 Subject: [PATCH 40/67] Update attach_test.dll.c --- suite/tests/client-interface/attach_test.dll.c | 1 - 1 file changed, 1 deletion(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index 7b88ea17bb..5c1d8fc650 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -96,7 +96,6 @@ event_post_attach(void) { // We do not print here as the ordering is non-deterministic vs thread init. saw_attach_event = true; - // dr_fprintf(STDERR, "attach\n"); } DR_EXPORT From f8c71aae7a5da12783862abfc5299625f1c9b088 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 17:31:35 +0800 Subject: [PATCH 41/67] Update attach_test.dll.c --- suite/tests/client-interface/attach_test.dll.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index 5c1d8fc650..0b15ddd608 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -46,7 +46,12 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); +#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); +#else + /* The app prints 'done' for us. */ +#endif + //dr_fprintf(STDERR, "done\n"); //#ifdef WINDOWS //#else // /* The app prints 'done' for us. */ From df0c2e4206fa138ca486c36eb8ac1e9c41e7e21d Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 17:32:40 +0800 Subject: [PATCH 42/67] Update infloop.c --- suite/tests/linux/infloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index 912c15fbe5..41fcfcf0c1 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ bool for_attach = false, block = false; static void signal_handler(int sig) { - if (sig == SIGTERM && !for_attach) { + if (sig == SIGTERM) {// && !for_attach print("done\n"); } exit(1); From aa128587df2b6e89949e8230d6243312852347fc Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 17:34:08 +0800 Subject: [PATCH 43/67] Update infloop.c --- suite/tests/linux/infloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index 41fcfcf0c1..0b14eb0791 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ bool for_attach = false, block = false; static void signal_handler(int sig) { - if (sig == SIGTERM) {// && !for_attach + if (sig == SIGTERM) { // && !for_attach print("done\n"); } exit(1); From bdf9d5c4756292eab950aeac8c77380a426cfaef Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 17:36:49 +0800 Subject: [PATCH 44/67] Update attach_test.dll.c --- suite/tests/client-interface/attach_test.dll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index 0b15ddd608..134199ae43 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -51,7 +51,7 @@ dr_exit(void) #else /* The app prints 'done' for us. */ #endif - //dr_fprintf(STDERR, "done\n"); + // dr_fprintf(STDERR, "done\n"); //#ifdef WINDOWS //#else // /* The app prints 'done' for us. */ From 4ae32782a0fed9bb92ddbdecb6760e226d2aba56 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 20:16:00 +0800 Subject: [PATCH 45/67] print "done" in attach_test.dll.c --- suite/tests/linux/infloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index 0b14eb0791..e4b0db42c3 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ bool for_attach = false, block = false; static void signal_handler(int sig) { - if (sig == SIGTERM) { // && !for_attach + if (sig == SIGTERM && !for_attach) { // && !for_attach print("done\n"); } exit(1); From 1f0bf0f074c596ce1ef5cf5817ef495004c0e223 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 20:16:56 +0800 Subject: [PATCH 46/67] print "done" in attach_test.dll.c --- suite/tests/client-interface/attach_test.dll.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index 134199ae43..f13c82ccaa 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -46,16 +46,8 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); -#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); -#else - /* The app prints 'done' for us. */ -#endif // dr_fprintf(STDERR, "done\n"); - //#ifdef WINDOWS - //#else - // /* The app prints 'done' for us. */ - //#endif } static void From 1e14495f1625c70a3067206d822d11872e24f3e8 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 21:40:54 +0800 Subject: [PATCH 47/67] print "done" in infloop.c --- suite/tests/linux/infloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index e4b0db42c3..0b14eb0791 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ bool for_attach = false, block = false; static void signal_handler(int sig) { - if (sig == SIGTERM && !for_attach) { // && !for_attach + if (sig == SIGTERM) { // && !for_attach print("done\n"); } exit(1); From 881c55cb105824974b41aa89a6a92e492f22ae87 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Sun, 7 Jan 2024 21:42:11 +0800 Subject: [PATCH 48/67] print "done" in infloop.c --- suite/tests/client-interface/attach_test.dll.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index f13c82ccaa..6d2e7f2619 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -46,7 +46,11 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); +#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); +#else + /* The app prints 'done' for us. */ +#endif // dr_fprintf(STDERR, "done\n"); } From bc5574d905f7d63d76cba32818ff2b30067d4355 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Mon, 8 Jan 2024 09:28:37 +0800 Subject: [PATCH 49/67] print done in attach_test.dll.c --- suite/tests/client-interface/attach_test.dll.c | 4 ---- suite/tests/linux/infloop.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index 6d2e7f2619..f13c82ccaa 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -46,11 +46,7 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); -#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); -#else - /* The app prints 'done' for us. */ -#endif // dr_fprintf(STDERR, "done\n"); } diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index 0b14eb0791..e4b0db42c3 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ bool for_attach = false, block = false; static void signal_handler(int sig) { - if (sig == SIGTERM) { // && !for_attach + if (sig == SIGTERM && !for_attach) { // && !for_attach print("done\n"); } exit(1); From 452077193e7a4a729a5d71b014f8eff790ccdfc5 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Mon, 8 Jan 2024 11:49:35 +0800 Subject: [PATCH 50/67] print done in infloop.c --- suite/tests/client-interface/attach_test.dll.c | 4 ++++ suite/tests/linux/infloop.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index f13c82ccaa..6d2e7f2619 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -46,7 +46,11 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); +#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); +#else + /* The app prints 'done' for us. */ +#endif // dr_fprintf(STDERR, "done\n"); } diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index e4b0db42c3..0b14eb0791 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ bool for_attach = false, block = false; static void signal_handler(int sig) { - if (sig == SIGTERM && !for_attach) { // && !for_attach + if (sig == SIGTERM) { // && !for_attach print("done\n"); } exit(1); From 231aa274efd4c53e3aa50bd66730ce49eb3930d0 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Mon, 8 Jan 2024 12:02:39 +0800 Subject: [PATCH 51/67] print done in attach_test.dll.c --- suite/tests/client-interface/attach_test.dll.c | 5 ----- suite/tests/linux/infloop.c | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index 6d2e7f2619..6a7e64ba49 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -46,12 +46,7 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); -#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); -#else - /* The app prints 'done' for us. */ -#endif - // dr_fprintf(STDERR, "done\n"); } static void diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index 0b14eb0791..e4b0db42c3 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ bool for_attach = false, block = false; static void signal_handler(int sig) { - if (sig == SIGTERM) { // && !for_attach + if (sig == SIGTERM && !for_attach) { // && !for_attach print("done\n"); } exit(1); From 5b45d6dcdedc5b54acd0c622d42072f349d8fb25 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Mon, 8 Jan 2024 12:11:51 +0800 Subject: [PATCH 52/67] print done in infloop.c --- suite/tests/client-interface/attach_test.dll.c | 5 +++++ suite/tests/linux/infloop.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index 6a7e64ba49..6d2e7f2619 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -46,7 +46,12 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); +#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); +#else + /* The app prints 'done' for us. */ +#endif + // dr_fprintf(STDERR, "done\n"); } static void diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index e4b0db42c3..0b14eb0791 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ bool for_attach = false, block = false; static void signal_handler(int sig) { - if (sig == SIGTERM && !for_attach) { // && !for_attach + if (sig == SIGTERM) { // && !for_attach print("done\n"); } exit(1); From 5b75a05409e9d7f49425cc26447cb7de525018ca Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Mon, 8 Jan 2024 15:41:12 +0800 Subject: [PATCH 53/67] print done in attach_test.dll.c --- suite/tests/client-interface/attach_test.dll.c | 5 ----- suite/tests/linux/infloop.c | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index 6d2e7f2619..6a7e64ba49 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -46,12 +46,7 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); -#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); -#else - /* The app prints 'done' for us. */ -#endif - // dr_fprintf(STDERR, "done\n"); } static void diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index 0b14eb0791..e4b0db42c3 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ bool for_attach = false, block = false; static void signal_handler(int sig) { - if (sig == SIGTERM) { // && !for_attach + if (sig == SIGTERM && !for_attach) { // && !for_attach print("done\n"); } exit(1); From 43246c405e9f0358ce286defe4a9eb0d67945054 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Mon, 8 Jan 2024 20:01:13 +0800 Subject: [PATCH 54/67] print done in infloop.c --- suite/tests/client-interface/attach_test.dll.c | 4 ++++ suite/tests/linux/infloop.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index 6a7e64ba49..ceeefb9a6f 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -46,7 +46,11 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); +#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); +#else + /* The app prints 'done' for us. */ +#endif } static void diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index e4b0db42c3..0b14eb0791 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ bool for_attach = false, block = false; static void signal_handler(int sig) { - if (sig == SIGTERM && !for_attach) { // && !for_attach + if (sig == SIGTERM) { // && !for_attach print("done\n"); } exit(1); From ec29e2e44a25ca21549f8ce94a3afb28df8ac37a Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Mon, 8 Jan 2024 20:28:27 +0800 Subject: [PATCH 55/67] print done in attach_test.dll.c --- suite/tests/client-interface/attach_test.dll.c | 4 ---- suite/tests/linux/infloop.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index ceeefb9a6f..6a7e64ba49 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -46,11 +46,7 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); -#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); -#else - /* The app prints 'done' for us. */ -#endif } static void diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index 0b14eb0791..e4b0db42c3 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ bool for_attach = false, block = false; static void signal_handler(int sig) { - if (sig == SIGTERM) { // && !for_attach + if (sig == SIGTERM && !for_attach) { // && !for_attach print("done\n"); } exit(1); From 385661d436772aea240831b52d16e03a0a4f052e Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Tue, 9 Jan 2024 16:53:10 +0800 Subject: [PATCH 56/67] print done in detach_test.dll.c --- suite/tests/CMakeLists.txt | 2 +- suite/tests/client-interface/detach_test.dll.c | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index f920b0d3f7..26c3487467 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -1412,7 +1412,7 @@ function(torun test key source native standalone_dr dr_ops exe_ops added_out pas set(exe_ops "${exe_ops};-v;-attach") endif () if ("${runall}" MATCHES "") - set(exe_ops "${exe_ops};-v;") + set(exe_ops "${exe_ops};-v;-attach") endif () if ("${runall}" MATCHES "") set(exe_ops "${exe_ops};-block") diff --git a/suite/tests/client-interface/detach_test.dll.c b/suite/tests/client-interface/detach_test.dll.c index a6d4cc9c3c..fca44f9571 100644 --- a/suite/tests/client-interface/detach_test.dll.c +++ b/suite/tests/client-interface/detach_test.dll.c @@ -46,11 +46,7 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); -#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); -#else - /* The app prints 'done' for us. */ -#endif } static void From c8dc42138db9f17f685508cedc9ad2dc220d511c Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Tue, 9 Jan 2024 17:14:15 +0800 Subject: [PATCH 57/67] delete the comments --- suite/tests/linux/infloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index e4b0db42c3..912c15fbe5 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ bool for_attach = false, block = false; static void signal_handler(int sig) { - if (sig == SIGTERM && !for_attach) { // && !for_attach + if (sig == SIGTERM && !for_attach) { print("done\n"); } exit(1); From a6fc9261252856b56ad5b21d53ccdd1446c15de6 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Wed, 10 Jan 2024 09:24:01 +0800 Subject: [PATCH 58/67] enable attach/detach test on AArch64 --- suite/runsuite_wrapper.pl | 2 -- 1 file changed, 2 deletions(-) diff --git a/suite/runsuite_wrapper.pl b/suite/runsuite_wrapper.pl index 74b94720ab..e5a5f88037 100755 --- a/suite/runsuite_wrapper.pl +++ b/suite/runsuite_wrapper.pl @@ -339,8 +339,6 @@ 'code_api|linux.fib-conflict-early' => 1, 'code_api|linux.mangle_asynch' => 1, 'code_api,tracedump_text,tracedump_origins,syntax_intel|common.loglevel' => 1, # i#1807 - 'code_api|client.attach_test' => 1, # i#5740 - 'code_api|client.detach_test' => 1, # i#5740 'code_api|client.attach_blocking' => 1, # i#5740 'code_api|tool.drcacheoff.rseq' => 1, # i#5734 'code_api|tool.drcacheoff.windows-zlib' => 1, # i#5507 From 1082eaca9081372fa0474602c140f1c6246b5a3d Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 12 Jan 2024 10:21:57 +0800 Subject: [PATCH 59/67] resume --- suite/tests/CMakeLists.txt | 2 +- suite/tests/client-interface/attach_test.dll.c | 4 ++++ suite/tests/client-interface/detach_test.dll.c | 4 ++++ suite/tests/linux/infloop.c | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index 5e11549ece..c44716f36e 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -1416,7 +1416,7 @@ function(torun test key source native standalone_dr dr_ops exe_ops added_out pas set(exe_ops "${exe_ops};-v;-attach") endif () if ("${runall}" MATCHES "") - set(exe_ops "${exe_ops};-v;-attach") + set(exe_ops "${exe_ops};-v") endif () if ("${runall}" MATCHES "") set(exe_ops "${exe_ops};-block") diff --git a/suite/tests/client-interface/attach_test.dll.c b/suite/tests/client-interface/attach_test.dll.c index 6a7e64ba49..ceeefb9a6f 100644 --- a/suite/tests/client-interface/attach_test.dll.c +++ b/suite/tests/client-interface/attach_test.dll.c @@ -46,7 +46,11 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); +#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); +#else + /* The app prints 'done' for us. */ +#endif } static void diff --git a/suite/tests/client-interface/detach_test.dll.c b/suite/tests/client-interface/detach_test.dll.c index fca44f9571..a6d4cc9c3c 100644 --- a/suite/tests/client-interface/detach_test.dll.c +++ b/suite/tests/client-interface/detach_test.dll.c @@ -46,7 +46,11 @@ dr_exit(void) { if (!saw_attach_event) dr_fprintf(STDERR, "Error: never saw attach event!\n"); +#ifdef WINDOWS dr_fprintf(STDERR, "done\n"); +#else + /* The app prints 'done' for us. */ +#endif } static void diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index 912c15fbe5..8d9f3083df 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -48,7 +48,7 @@ bool for_attach = false, block = false; static void signal_handler(int sig) { - if (sig == SIGTERM && !for_attach) { + if (sig == SIGTERM) { print("done\n"); } exit(1); From fdbb5b46cdbbe7aa77194c1b1a2ccf02907fbe93 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Fri, 12 Jan 2024 10:54:09 +0800 Subject: [PATCH 60/67] resume --- suite/runsuite_wrapper.pl | 1 - suite/tests/CMakeLists.txt | 2 +- suite/tests/linux/infloop.c | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/suite/runsuite_wrapper.pl b/suite/runsuite_wrapper.pl index e5a5f88037..d14a813be6 100755 --- a/suite/runsuite_wrapper.pl +++ b/suite/runsuite_wrapper.pl @@ -339,7 +339,6 @@ 'code_api|linux.fib-conflict-early' => 1, 'code_api|linux.mangle_asynch' => 1, 'code_api,tracedump_text,tracedump_origins,syntax_intel|common.loglevel' => 1, # i#1807 - 'code_api|client.attach_blocking' => 1, # i#5740 'code_api|tool.drcacheoff.rseq' => 1, # i#5734 'code_api|tool.drcacheoff.windows-zlib' => 1, # i#5507 ); diff --git a/suite/tests/CMakeLists.txt b/suite/tests/CMakeLists.txt index c44716f36e..a9351d182f 100644 --- a/suite/tests/CMakeLists.txt +++ b/suite/tests/CMakeLists.txt @@ -1416,7 +1416,7 @@ function(torun test key source native standalone_dr dr_ops exe_ops added_out pas set(exe_ops "${exe_ops};-v;-attach") endif () if ("${runall}" MATCHES "") - set(exe_ops "${exe_ops};-v") + set(exe_ops "${exe_ops};-v;") endif () if ("${runall}" MATCHES "") set(exe_ops "${exe_ops};-block") diff --git a/suite/tests/linux/infloop.c b/suite/tests/linux/infloop.c index 8d9f3083df..d85c8a75b0 100644 --- a/suite/tests/linux/infloop.c +++ b/suite/tests/linux/infloop.c @@ -44,7 +44,7 @@ #include #include #include -bool for_attach = false, block = false; + static void signal_handler(int sig) { @@ -59,6 +59,7 @@ main(int argc, const char *argv[]) { int arg_offs = 1; long long counter = 0; + bool for_attach = false, block = false; while (arg_offs < argc && argv[arg_offs][0] == '-') { if (strcmp(argv[arg_offs], "-v") == 0) { /* enough verbosity to satisfy runall.cmake: needs an initial and a From e6da298524806b14e1019629cfd417d91089e799 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Wed, 24 Jan 2024 16:58:29 +0800 Subject: [PATCH 61/67] Update runsuite_wrapper.pl --- suite/runsuite_wrapper.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/suite/runsuite_wrapper.pl b/suite/runsuite_wrapper.pl index d14a813be6..74b94720ab 100755 --- a/suite/runsuite_wrapper.pl +++ b/suite/runsuite_wrapper.pl @@ -339,6 +339,9 @@ 'code_api|linux.fib-conflict-early' => 1, 'code_api|linux.mangle_asynch' => 1, 'code_api,tracedump_text,tracedump_origins,syntax_intel|common.loglevel' => 1, # i#1807 + 'code_api|client.attach_test' => 1, # i#5740 + 'code_api|client.detach_test' => 1, # i#5740 + 'code_api|client.attach_blocking' => 1, # i#5740 'code_api|tool.drcacheoff.rseq' => 1, # i#5734 'code_api|tool.drcacheoff.windows-zlib' => 1, # i#5507 ); From 13798e12c31107c0ba494d873d88a399c1dd69ea Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Wed, 24 Jan 2024 17:05:38 +0800 Subject: [PATCH 62/67] Update signal.c --- core/unix/signal.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/core/unix/signal.c b/core/unix/signal.c index 04ba562ebc..0a4d3491e0 100644 --- a/core/unix/signal.c +++ b/core/unix/signal.c @@ -3169,7 +3169,7 @@ void thread_set_self_context(void *cxt, bool is_detach_external) { #ifdef X86 - if (!INTERNAL_OPTION(use_sigreturn_setcontext) || is_detach_external) { + if (!INTERNAL_OPTION(use_sigreturn_setcontext)) { sigcontext_t *sc = (sigcontext_t *)cxt; dr_jmp_buf_t buf; buf.xbx = sc->SC_XBX; @@ -3212,19 +3212,9 @@ thread_set_self_context(void *cxt, bool is_detach_external) #endif memset(&frame, 0, sizeof(frame)); #if defined(X86) - dcontext_t *dcontext = get_thread_private_dcontext(); -#endif -#ifdef LINUX -# ifdef X86 - byte *xstate = get_and_initialize_xstate_buffer(dcontext); - frame.uc.uc_mcontext.fpstate = &((kernel_xstate_t *)xstate)->fpstate; -# endif /* X86 */ - frame.uc.uc_mcontext = *sc; -#endif + frame.uc.uc_mcontext.fpstate = sc->fpstate; +#endif IF_ARM(ASSERT_NOT_TESTED()); -#if defined(X86) - save_fpstate(dcontext, &frame); -#endif /* The kernel calls do_sigaltstack on sys_rt_sigreturn primarily to ensure * the frame is ok, but the side effect is we can mess up our own altstack * settings if we're not careful. Having invalid ss_size looks good for From 3e4179c8246f90e4d95b2425e2e03f5ebc5cb828 Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Wed, 24 Jan 2024 17:10:22 +0800 Subject: [PATCH 63/67] Update signal.c --- core/unix/signal.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/unix/signal.c b/core/unix/signal.c index 0a4d3491e0..e93b13329b 100644 --- a/core/unix/signal.c +++ b/core/unix/signal.c @@ -3211,9 +3211,12 @@ thread_set_self_context(void *cxt, bool is_detach_external) ASSERT_NOT_IMPLEMENTED(false); /* PR 405694: can't use regular sigreturn! */ #endif memset(&frame, 0, sizeof(frame)); -#if defined(X86) +#ifdef LINUX +# ifdef X86 frame.uc.uc_mcontext.fpstate = sc->fpstate; -#endif +# endif /* X86 */ + frame.uc.uc_mcontext = *sc; +#endif IF_ARM(ASSERT_NOT_TESTED()); /* The kernel calls do_sigaltstack on sys_rt_sigreturn primarily to ensure * the frame is ok, but the side effect is we can mess up our own altstack From 3e0b2464430b3c3d3a2c3142d8046e8f5bea5ead Mon Sep 17 00:00:00 2001 From: Wenlong Mu Date: Wed, 24 Jan 2024 17:12:35 +0800 Subject: [PATCH 64/67] Update signal.c --- core/unix/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/unix/signal.c b/core/unix/signal.c index e93b13329b..bb260ea31c 100644 --- a/core/unix/signal.c +++ b/core/unix/signal.c @@ -3213,7 +3213,7 @@ thread_set_self_context(void *cxt, bool is_detach_external) memset(&frame, 0, sizeof(frame)); #ifdef LINUX # ifdef X86 - frame.uc.uc_mcontext.fpstate = sc->fpstate; + frame.uc.uc_mcontext.fpstate = sc->fpstate; # endif /* X86 */ frame.uc.uc_mcontext = *sc; #endif From 669f0968f6e9e294187382ac5b8727c3d7eb4d08 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Wed, 24 Jan 2024 18:44:46 +0800 Subject: [PATCH 65/67] remove is_detach_external --- core/os_shared.h | 4 ++-- core/unix/signal.c | 6 +++--- core/win32/os.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/os_shared.h b/core/os_shared.h index 5b828e6625..09aae11c53 100644 --- a/core/os_shared.h +++ b/core/os_shared.h @@ -215,10 +215,10 @@ thread_set_mcontext(thread_record_t *tr, priv_mcontext_t *mc); /* Takes an os-specific context. Does not return. */ void -thread_set_self_context(void *cxt, bool is_detach_external); +thread_set_self_context(void *cxt); /* Only sets the priv_mcontext_t state. Does not return. */ void -thread_set_self_mcontext(priv_mcontext_t *mc, bool is_detach_external); +thread_set_self_mcontext(priv_mcontext_t *mc); /* Assumes target thread is suspended */ bool diff --git a/core/unix/signal.c b/core/unix/signal.c index bb260ea31c..9fb3ea331e 100644 --- a/core/unix/signal.c +++ b/core/unix/signal.c @@ -3166,7 +3166,7 @@ translate_sigcontext(dcontext_t *dcontext, kernel_ucontext_t *uc, bool avoid_fai /* Takes an os-specific context */ void -thread_set_self_context(void *cxt, bool is_detach_external) +thread_set_self_context(void *cxt) { #ifdef X86 if (!INTERNAL_OPTION(use_sigreturn_setcontext)) { @@ -3304,7 +3304,7 @@ thread_set_segment_registers(sigcontext_t *sc) /* Takes a priv_mcontext_t */ void -thread_set_self_mcontext(priv_mcontext_t *mc, bool is_detach_external) +thread_set_self_mcontext(priv_mcontext_t *mc) { kernel_ucontext_t ucxt; sig_full_cxt_t sc_full; @@ -3318,7 +3318,7 @@ thread_set_self_mcontext(priv_mcontext_t *mc, bool is_detach_external) IF_ARM( set_pc_mode_in_cpsr(sc_full.sc, dr_get_isa_mode(get_thread_private_dcontext()))); /* thread_set_self_context will fill in the real fp/simd state for x86 */ - thread_set_self_context((void *)sc_full.sc, is_detach_external); + thread_set_self_context((void *)sc_full.sc); ASSERT_NOT_REACHED(); } diff --git a/core/win32/os.c b/core/win32/os.c index 2f294643ef..432db00d32 100644 --- a/core/win32/os.c +++ b/core/win32/os.c @@ -5201,7 +5201,7 @@ thread_set_context(thread_record_t *tr, CONTEXT *context) /* Takes an os-specific context */ void -thread_set_self_context(void *cxt, bool is_detach_external) +thread_set_self_context(void *cxt) { /* We use NtContinue to avoid privilege issues with NtSetContext */ nt_continue((CONTEXT *)cxt); @@ -5210,7 +5210,7 @@ thread_set_self_context(void *cxt, bool is_detach_external) /* Takes a priv_mcontext_t */ void -thread_set_self_mcontext(priv_mcontext_t *mc, bool is_detach_external) +thread_set_self_mcontext(priv_mcontext_t *mc) { /* We can't use heap for our CONTEXT as we have no opportunity to free it. * We assume call paths can handle a large stack buffer as size something From f1efa93194030115319c233878e1b003b47eddc9 Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Wed, 24 Jan 2024 18:50:03 +0800 Subject: [PATCH 66/67] remove is_detach_external --- core/synch.c | 6 +++--- core/win32/os.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/synch.c b/core/synch.c index 3af5add4af..999c333b8a 100644 --- a/core/synch.c +++ b/core/synch.c @@ -761,9 +761,9 @@ check_wait_at_safe_spot(dcontext_t *dcontext, thread_synch_permission_t cur_stat * being at the synch point vs in the cache. */ if (set_mcontext) - thread_set_self_mcontext((priv_mcontext_t *)cxt, false); + thread_set_self_mcontext((priv_mcontext_t *)cxt); else - thread_set_self_context((void *)cxt, false); + thread_set_self_context((void *)cxt); ASSERT_NOT_REACHED(); } } @@ -2435,6 +2435,6 @@ detach_externally_on_new_stack() LOG(GLOBAL, LOG_ALL, 1, "Detach: Entering final cleanup and unload\n"); SYSLOG_INTERNAL_INFO("Detaching from process, entering final cleanup"); detach_cleanup_helper(my_tr); - thread_set_self_mcontext(&my_mcontext, true); + thread_set_self_mcontext(&my_mcontext); } #endif diff --git a/core/win32/os.c b/core/win32/os.c index 432db00d32..b5dc3b3793 100644 --- a/core/win32/os.c +++ b/core/win32/os.c @@ -2795,7 +2795,7 @@ thread_attach_setup(priv_mcontext_t *mc) * sets the context back). */ mc->pc = data->continuation_pc; - thread_set_self_mcontext(mc, false); + thread_set_self_mcontext(mc); ASSERT_NOT_REACHED(); } /* Preclude double takeover if we become suspended while in ntdll */ @@ -5232,7 +5232,7 @@ thread_set_self_mcontext(priv_mcontext_t *mc) cxt = nt_initialize_context(buf, bufsz, cxt_flags); /* need ss and cs for setting my own context */ mcontext_to_context(cxt, mc, true /* set_cur_seg */); - thread_set_self_context(cxt, false); + thread_set_self_context(cxt); ASSERT_NOT_REACHED(); } From 6f2f4230e109d2452d277878d7b7f6f0144f8f5d Mon Sep 17 00:00:00 2001 From: wenlongmu Date: Wed, 24 Jan 2024 19:22:05 +0800 Subject: [PATCH 67/67] reserve original method --- core/unix/signal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/unix/signal.c b/core/unix/signal.c index 9fb3ea331e..c6e5b8766d 100644 --- a/core/unix/signal.c +++ b/core/unix/signal.c @@ -3211,11 +3211,17 @@ thread_set_self_context(void *cxt) ASSERT_NOT_IMPLEMENTED(false); /* PR 405694: can't use regular sigreturn! */ #endif memset(&frame, 0, sizeof(frame)); +#if defined(X86) + dcontext_t *dcontext = get_thread_private_dcontext(); +#endif #ifdef LINUX # ifdef X86 frame.uc.uc_mcontext.fpstate = sc->fpstate; # endif /* X86 */ frame.uc.uc_mcontext = *sc; +#endif +#if defined(X86) + save_fpstate(dcontext, &frame); #endif IF_ARM(ASSERT_NOT_TESTED()); /* The kernel calls do_sigaltstack on sys_rt_sigreturn primarily to ensure