aboutsummaryrefslogtreecommitdiff
path: root/tests/emscripten_log
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2014-02-27 19:43:32 +0200
committerJukka Jylänki <jujjyl@gmail.com>2014-02-27 19:44:36 +0200
commit13fd9405aa4ede0d0713cb08ed0840bc753e1828 (patch)
treea6373be3924dc7c5204f53a3c8a4ee481e061093 /tests/emscripten_log
parent2a43c14b8458f4e5c4e7ee5b8e28d52be5f472bb (diff)
Fix bug that caused emscripten_get_callstack to not truncate the output buffer. Add test. Closes #2171.
Diffstat (limited to 'tests/emscripten_log')
-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)