Skip to content

Deprecate EM_LOG_FUNC_PARAMS flag to emscripten_log/emscripten_get_callstack #19820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.

3.1.44 (in development)
-----------------------
- The `EM_LOG_FUNC_PARAMS` flag to `emscripten_log`/`emscripten_get_callstack`
has been deprecated and no longer has any effect. It was based on a
long-deprecated JS API. (#19820)
- The internal `read_` and `readAsync` functions no longer handle date URIs.
This only effects builds that use `-sSINGLE_FILE` or `--memory-init-file`.
(#19792)
Expand Down
4 changes: 0 additions & 4 deletions site/source/docs/api_reference/emscripten.h.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1042,10 +1042,6 @@ Defines

If specified, the pathnames of the file information in the call stack will be omitted.

.. c:macro:: EM_LOG_FUNC_PARAMS

If specified, prints out the actual values of the parameters the functions were invoked with.


Functions
---------
Expand Down
2 changes: 0 additions & 2 deletions src/generated_struct_info32.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@
"EM_LOG_CONSOLE": 1,
"EM_LOG_C_STACK": 8,
"EM_LOG_DEBUG": 256,
"EM_LOG_DEMANGLE": 32,
"EM_LOG_ERROR": 4,
"EM_LOG_FUNC_PARAMS": 128,
"EM_LOG_INFO": 512,
"EM_LOG_JS_STACK": 16,
"EM_LOG_NO_PATHS": 64,
Expand Down
2 changes: 0 additions & 2 deletions src/generated_struct_info64.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@
"EM_LOG_CONSOLE": 1,
"EM_LOG_C_STACK": 8,
"EM_LOG_DEBUG": 256,
"EM_LOG_DEMANGLE": 32,
"EM_LOG_ERROR": 4,
"EM_LOG_FUNC_PARAMS": 128,
"EM_LOG_INFO": 512,
"EM_LOG_JS_STACK": 16,
"EM_LOG_NO_PATHS": 64,
Expand Down
59 changes: 1 addition & 58 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -2410,37 +2410,7 @@ mergeInto(LibraryManager.library, {
}
},

// Returns [parentFuncArguments, functionName, paramListName]
$traverseStack: (args) => {
if (!args || !args.callee || !args.callee.name) {
return [null, '', ''];
}

var funstr = args.callee.toString();
var funcname = args.callee.name;
var str = '(';
var first = true;
for (var i in args) {
var a = args[i];
if (!first) {
str += ", ";
}
first = false;
if (typeof a == 'number' || typeof a == 'string') {
str += a;
} else {
str += `(${typeof a}})`;
}
}
str += ')';
var caller = args.callee.caller;
args = caller ? caller.arguments : [];
if (first)
str = '';
return [args, funcname, str];
},

$getCallstack__deps: ['$traverseStack', '$jsStackTrace', '$warnOnce'],
$getCallstack__deps: ['$jsStackTrace', '$warnOnce'],
$getCallstack__docs: '/** @param {number=} flags */',
$getCallstack: function(flags) {
var callstack = jsStackTrace();
Expand All @@ -2453,10 +2423,6 @@ mergeInto(LibraryManager.library, {
var iNextLine = callstack.indexOf('\n', Math.max(iThisFunc, iThisFunc2))+1;
callstack = callstack.slice(iNextLine);

if (flags & {{{ cDefs.EM_LOG_DEMANGLE }}}) {
warnOnce('EM_LOG_DEMANGLE is deprecated; ignoring');
}

// If user requested to see the original source stack, but no source map
// information is available, just fall back to showing the JS stack.
if (flags & {{{ cDefs.EM_LOG_C_STACK }}} && typeof emscripten_source_map == 'undefined') {
Expand All @@ -2465,15 +2431,6 @@ mergeInto(LibraryManager.library, {
flags |= {{{ cDefs.EM_LOG_JS_STACK }}};
}

var stack_args = null;
if (flags & {{{ cDefs.EM_LOG_FUNC_PARAMS }}}) {
// To get the actual parameters to the functions, traverse the stack via
// the unfortunately deprecated 'arguments.callee' method, if it works:
stack_args = traverseStack(arguments);
while (stack_args[1].includes('_emscripten_'))
stack_args = traverseStack(stack_args[0]);
}

// Process all lines:
var lines = callstack.split('\n');
callstack = '';
Expand Down Expand Up @@ -2537,16 +2494,6 @@ mergeInto(LibraryManager.library, {
}
callstack += (haveSourceMap ? (` = ${symbolName}`) : (` at ${symbolName}`)) + ` (${file}:${lineno}:${column})\n`;
}

// If we are still keeping track with the callstack by traversing via
// 'arguments.callee', print the function parameters as well.
if (flags & {{{ cDefs.EM_LOG_FUNC_PARAMS }}} && stack_args[0]) {
if (stack_args[1] == symbolName && stack_args[2].length > 0) {
callstack = callstack.replace(/\s+$/, '');
callstack += ' with values: ' + stack_args[1] + stack_args[2] + '\n';
}
stack_args = traverseStack(stack_args[0]);
}
}
// Trim extra whitespace at the end of the output.
callstack = callstack.replace(/\s+$/, '');
Expand All @@ -2555,10 +2502,6 @@ mergeInto(LibraryManager.library, {

emscripten_get_callstack__deps: ['$getCallstack', '$lengthBytesUTF8', '$stringToUTF8'],
emscripten_get_callstack: function(flags, str, maxbytes) {
// Use explicit calls to from64 rather then using the __sig
// magic here. This is because the __sig wrapper uses arrow function
// notation which causes the inner call to traverseStack to fail.
{{{ from64('str') }}};
var callstack = getCallstack(flags);
// User can query the required amount of bytes to hold the callstack.
if (!str || maxbytes <= 0) {
Expand Down
2 changes: 0 additions & 2 deletions src/struct_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -978,9 +978,7 @@
"EM_LOG_ERROR",
"EM_LOG_C_STACK",
"EM_LOG_JS_STACK",
"EM_LOG_DEMANGLE",
"EM_LOG_NO_PATHS",
"EM_LOG_FUNC_PARAMS",
"EM_LOG_DEBUG",
"EM_LOG_INFO",
"EM_TIMING_SETTIMEOUT",
Expand Down
4 changes: 3 additions & 1 deletion system/include/emscripten/emscripten.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ char *emscripten_get_preloaded_image_data_from_FILE(FILE *file, int *w, int *h);
#define EM_LOG_C_STACK 8
#define EM_LOG_JS_STACK 16
#define EM_LOG_DEMANGLE 32 // deprecated
#pragma clang deprecated(EM_LOG_DEMANGLE)
#define EM_LOG_NO_PATHS 64
#define EM_LOG_FUNC_PARAMS 128
#define EM_LOG_FUNC_PARAMS 128 // deprecated
#pragma clang deprecated(EM_LOG_FUNC_PARAMS)
#define EM_LOG_DEBUG 256
#define EM_LOG_INFO 512

Expand Down
2 changes: 1 addition & 1 deletion test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def test_zzz_html_source_map(self):

def test_emscripten_log(self):
self.btest_exit(test_file('emscripten_log/emscripten_log.cpp'),
args=['--pre-js', path_from_root('src/emscripten-source-map.min.js'), '-gsource-map'])
args=['-Wno-deprecated-pragma', '--pre-js', path_from_root('src/emscripten-source-map.min.js'), '-gsource-map'])

@also_with_wasmfs
def test_preload_file(self):
Expand Down
2 changes: 1 addition & 1 deletion test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8035,7 +8035,7 @@ def test_emscripten_log(self):
self.set_setting('DEMANGLE_SUPPORT')
if '-g' not in self.emcc_args:
self.emcc_args.append('-g')
self.emcc_args += ['-DRUN_FROM_JS_SHELL']
self.emcc_args += ['-DRUN_FROM_JS_SHELL', '-Wno-deprecated-pragma']
self.do_run_in_out_file_test('emscripten_log/emscripten_log.cpp', interleaved_output=False)
# test closure compiler as well
if self.maybe_closure():
Expand Down