From bf8fd996b6651edcbb2235bbc6fae307a3638611 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 22 Oct 2019 10:58:43 +0200 Subject: Add tracing to find_module() and import_module() --- libbuild2/module.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libbuild2/module.cxx b/libbuild2/module.cxx index 11e0b4f..a55a1a6 100644 --- a/libbuild2/module.cxx +++ b/libbuild2/module.cxx @@ -62,6 +62,8 @@ namespace build2 bool boot, bool opt) { + tracer trace ("import_module"); + // Take care of core modules that are bundled with libbuild2 in case they // are not pre-loaded by the driver. // @@ -139,6 +141,8 @@ namespace build2 { // We found the module as a target in a project. Now we need to update // the target (which will also give us the shared library path). + // + l5 ([&]{trace << "found " << ir.first << " in " << ir.second;}); // Create the build context if necessary. // @@ -192,6 +196,8 @@ namespace build2 // pair lr (import_load (ctx, move (ir), loc)); + l5 ([&]{trace << "loaded " << lr.first;}); + // When happens next depends on whether this is a top-level or nested // module update. // @@ -254,6 +260,8 @@ namespace build2 fail (loc) << "wrong export from build system module " << mod; lib = l.as ().path (); + + l5 ([&]{trace << "updated " << lib;}); } } else @@ -279,6 +287,8 @@ namespace build2 #endif lib = path (pfx + mod + '-' + build_version_interface + sfx); + + l5 ([&]{trace << "system-default search for " << lib;}); } // The build2__load() symbol name. @@ -298,7 +308,7 @@ namespace build2 { r = function_cast (dlsym (h, sym.c_str ())); - // I don't think we should ignore this even if optional. + // I don't think we should ignore this even if the module is optional. // if (r == nullptr) fail (loc) << "unable to lookup " << sym << " in build system module " @@ -307,6 +317,8 @@ namespace build2 else if (!opt) dr << fail (loc) << "unable to load build system module " << mod << " (" << lib << "): " << dlerror (); + else + l5 ([&]{trace << "unable to load " << lib << ": " << dlerror ();}); #else if (HMODULE h = LoadLibrary (lib.string ().c_str ())) { @@ -320,6 +332,9 @@ namespace build2 else if (!opt) dr << fail (loc) << "unable to load build system module " << mod << " (" << lib << "): " << win32::last_error_msg (); + else + l5 ([&]{trace << "unable to load " << lib << ": " + << win32::last_error_msg ();}); #endif // Add a suggestion similar to import phase 2. @@ -340,6 +355,8 @@ namespace build2 bool boot, bool opt) { + tracer trace ("find_module"); + // Optional modules and submodules sure make this logic convoluted. So we // divide it into two parts: (1) find or insert an entry (for submodule // or, failed that, for the main module, the latter potentially NULL) and @@ -369,6 +386,8 @@ namespace build2 { const string& n (j->name); + l5 ([&]{trace << "registering " << n;}); + auto p (loaded_modules.emplace (n, j)); if (!p.second) -- cgit v1.1