From 7e3092b83516e720ef367e8172421266078ee7e6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 7 Aug 2019 08:27:11 +0200 Subject: Improve deadlock diagnostics (suppress stack trace, reword) --- libbuild2/function.test.cxx | 2 +- libbuild2/scheduler.cxx | 9 ++++----- libbuild2/test/script/parser.test.cxx | 2 +- libbuild2/utility.cxx | 9 ++++++--- libbuild2/utility.hxx | 8 +++++++- 5 files changed, 19 insertions(+), 11 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/function.test.cxx b/libbuild2/function.test.cxx index 5e442a3..a9326f4 100644 --- a/libbuild2/function.test.cxx +++ b/libbuild2/function.test.cxx @@ -39,7 +39,7 @@ namespace build2 // Fake build system driver, default verbosity. // init_diag (1); - init (argv[0]); + init (nullptr, argv[0]); reset (strings ()); // No command line variables. function_family f ("dummy"); diff --git a/libbuild2/scheduler.cxx b/libbuild2/scheduler.cxx index b261a82..37220c7 100644 --- a/libbuild2/scheduler.cxx +++ b/libbuild2/scheduler.cxx @@ -20,7 +20,6 @@ #endif #include -#include // std::terminate() #include @@ -861,12 +860,12 @@ namespace build2 // thing about abort is if this is not a dependency cycle, then we // have a core to examine). // - error << "detected deadlock that could be caused by a dependency " - << "cycle" << + error << "deadlock detected, aborting" << + info << "deadlocks are normally caused by dependency cycles" << info << "re-run with -s to diagnose dependency cycles" << - info << "if not a dependency cycle, please report"; + info << "if not a dependency cycle, please report as a bug"; - std::terminate (); + terminate (false /* trace */); } } } diff --git a/libbuild2/test/script/parser.test.cxx b/libbuild2/test/script/parser.test.cxx index 8702e18..ab1f295 100644 --- a/libbuild2/test/script/parser.test.cxx +++ b/libbuild2/test/script/parser.test.cxx @@ -154,7 +154,7 @@ namespace build2 // Fake build system driver, default verbosity. // init_diag (1); - init (argv[0]); + init (nullptr, argv[0]); sched.startup (1); // Serial execution. reset (strings ()); // No command line variables. diff --git a/libbuild2/utility.cxx b/libbuild2/utility.cxx index 396ce82..506e88e 100644 --- a/libbuild2/utility.cxx +++ b/libbuild2/utility.cxx @@ -69,6 +69,8 @@ namespace build2 // // // + void (*terminate) (bool); + process_path argv0; const standard_version build_version (LIBBUILD2_VERSION_STR); @@ -486,12 +488,13 @@ namespace build2 } void - init (const char* a0, + init (void (*t) (bool), + const char* a0, bool kg, bool dr, optional mc, optional cs, optional cg) { - // Build system driver process path. - // + terminate = t; + argv0 = process::path_search (a0, true); keep_going = kg; diff --git a/libbuild2/utility.hxx b/libbuild2/utility.hxx index 9598208..c251b64 100644 --- a/libbuild2/utility.hxx +++ b/libbuild2/utility.hxx @@ -119,13 +119,19 @@ namespace build2 // Default values are for unit tests. // LIBBUILD2_SYMEXPORT void - init (const char* argv0, + init (void (*terminate) (bool), + const char* argv0, bool keep_going = false, bool dry_run = false, optional mtime_check = nullopt, optional config_sub = nullopt, optional config_guess = nullopt); + // Terminate function. If trace is false, then printing of the stack trace, + // if any, should be omitted. + // + LIBBUILD2_SYMEXPORT extern void (*terminate) (bool trace); + // Build system driver process path (argv0.initial is argv[0]). // LIBBUILD2_SYMEXPORT extern process_path argv0; -- cgit v1.1