Skip to content

Commit

Permalink
Improve logging/debugging related to dynamic linking/pthreads. NFC (#…
Browse files Browse the repository at this point in the history
…19446)

These are all the NFC parts of #19390.
  • Loading branch information
sbc100 authored May 25, 2023
1 parent e9d83ba commit 129567b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
16 changes: 12 additions & 4 deletions src/library_dylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,14 @@ var LibraryDylink = {
loadedLibsByName: {},
// handle -> dso; Used by dlsym
loadedLibsByHandle: {},
init: () => newDSO('__main__', {{{ cDefs.RTLD_DEFAULT }}}, wasmImports),
init: () => {
#if ASSERTIONS
// This function needs to run after the initial wasmImports object
// as been created.
assert(wasmImports);
#endif
newDSO('__main__', {{{ cDefs.RTLD_DEFAULT }}}, wasmImports);
},
},

$dlSetError__internal: true,
Expand Down Expand Up @@ -1040,9 +1047,6 @@ var LibraryDylink = {
$loadDylibs__internal: true,
$loadDylibs__deps: ['$loadDynamicLibrary', '$reportUndefinedSymbols'],
$loadDylibs: function() {
#if DYLINK_DEBUG
dbg(`loadDylibs: ${dynamicLibraries}`);
#endif
if (!dynamicLibraries.length) {
#if DYLINK_DEBUG
dbg('loadDylibs: no libraries to preload');
Expand All @@ -1051,6 +1055,10 @@ var LibraryDylink = {
return;
}

#if DYLINK_DEBUG
dbg(`loadDylibs: ${dynamicLibraries}`);
#endif

// Load binaries asynchronously
addRunDependency('loadDylibs');
dynamicLibraries.reduce((chain, lib) => {
Expand Down
2 changes: 1 addition & 1 deletion src/parseTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ function makeRemovedModuleAPIAssert(moduleName, localName) {
function checkReceiving(name) {
// ALL_INCOMING_MODULE_JS_API contains all valid incoming module API symbols
// so calling makeModuleReceive* with a symbol not in this list is an error
assert(ALL_INCOMING_MODULE_JS_API.has(name));
assert(ALL_INCOMING_MODULE_JS_API.has(name), `${name} is not part of INCOMING_MODULE_JS_API`);
}

// Make code to receive a value on the incoming Module object.
Expand Down
2 changes: 1 addition & 1 deletion src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var out = () => { throw 'out() is not defined in worker.js.'; }
#endif
var err = threadPrintErr;
self.alert = threadAlert;
#if RUNTIME_DEBUG
#if ASSERTIONS || RUNTIME_DEBUG
var dbg = threadPrintErr;
#endif

Expand Down
3 changes: 2 additions & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,8 @@ def test_undefined_symbols(self, action):
print('checking "%s" %s' % (args, value))
extra = ['-s', action + '_ON_UNDEFINED_SYMBOLS=%d' % value] if action else []
proc = self.run_process([EMXX, '-sUSE_SDL', 'main.cpp'] + extra + args, stderr=PIPE, check=False)
print(proc.stderr)
if common.EMTEST_VERBOSE:
print(proc.stderr)
if value or action is None:
# The default is that we error in undefined symbols
self.assertContained('undefined symbol: something', proc.stderr)
Expand Down

0 comments on commit 129567b

Please sign in to comment.