aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-10-22 10:58:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-10-22 10:58:43 +0200
commitbf8fd996b6651edcbb2235bbc6fae307a3638611 (patch)
treecaa0d3d1ff8f41a5454ccf979ea5a9a8f96953c5
parentb47a323f09f1f9ccece03ca4d84dbe7a47ff8177 (diff)
Add tracing to find_module() and import_module()
-rw-r--r--libbuild2/module.cxx21
1 files changed, 20 insertions, 1 deletions
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<names, const scope&> 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<file> ().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_<mod>_load() symbol name.
@@ -298,7 +308,7 @@ namespace build2
{
r = function_cast<module_load_function*> (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)