aboutsummaryrefslogtreecommitdiff
path: root/tests/emscripten_log/emscripten_log.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/emscripten_log/emscripten_log.cpp')
-rw-r--r--tests/emscripten_log/emscripten_log.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/emscripten_log/emscripten_log.cpp b/tests/emscripten_log/emscripten_log.cpp
index d7cfe484..5973e94c 100644
--- a/tests/emscripten_log/emscripten_log.cpp
+++ b/tests/emscripten_log/emscripten_log.cpp
@@ -99,6 +99,14 @@ void __attribute__((noinline)) bar(int = 0, char * = 0, double = 0) // Arbitrary
char str[1024];
emscripten_get_callstack(EM_LOG_NO_PATHS | EM_LOG_JS_STACK, str, 1024);
+ // Test that obtaining a truncated callstack works. (https://github.com/kripken/emscripten/issues/2171)
+ char *buffer = new char[21];
+ buffer[20] = 0x01; // Magic sentinel that should not change its value.
+ emscripten_get_callstack(EM_LOG_C_STACK | EM_LOG_DEMANGLE | EM_LOG_NO_PATHS | EM_LOG_FUNC_PARAMS, buffer, 20);
+ MYASSERT(!!strstr(buffer, "at bar(int,"), "Truncated callstack was %s!", buffer);
+ MYASSERT(buffer[20] == 0x01);
+ delete[] buffer;
+
/* With EM_LOG_JS_STACK, the callstack will be
at __Z3bariPcd (src.cpp.o.js:5394:12)
at __Z3FooIiEvv (src.cpp.o.js:5417:4)