Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: test/cctest/wasm/test-wasm-stack.cc

Issue 1909353002: [wasm] Make wasm info available on the stack trace (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-offset-table-3
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/wasm/wasm-macro-gen.h" 5 #include "src/wasm/wasm-macro-gen.h"
6 6
7 #include "test/cctest/cctest.h" 7 #include "test/cctest/cctest.h"
8 #include "test/cctest/compiler/value-helper.h" 8 #include "test/cctest/compiler/value-helper.h"
9 #include "test/cctest/wasm/test-signatures.h" 9 #include "test/cctest/wasm/test-signatures.h"
10 #include "test/cctest/wasm/wasm-run-utils.h" 10 #include "test/cctest/wasm/wasm-run-utils.h"
11 11
12 using namespace v8::base; 12 using namespace v8::base;
13 using namespace v8::internal; 13 using namespace v8::internal;
14 using namespace v8::internal::compiler; 14 using namespace v8::internal::compiler;
15 using namespace v8::internal::wasm; 15 using namespace v8::internal::wasm;
16 16
17 using v8::Local; 17 using v8::Local;
18 using v8::Utils; 18 using v8::Utils;
19 19
20 namespace { 20 namespace {
21 21
22 #define CHECK_CSTREQ(exp, found) \ 22 #define CHECK_CSTREQ(exp, found) \
23 do { \ 23 do { \
24 const char* exp_ = (exp); \ 24 const char* exp_ = (exp); \
25 const char* found_ = (found); \ 25 const char* found_ = (found); \
26 if (V8_UNLIKELY(strcmp(exp_, found_) != 0)) { \ 26 DCHECK_NOT_NULL(exp); \
27 if (V8_UNLIKELY(found_ == nullptr || strcmp(exp_, found_) != 0)) { \
27 V8_Fatal(__FILE__, __LINE__, \ 28 V8_Fatal(__FILE__, __LINE__, \
28 "Check failed: (%s) != (%s) ('%s' vs '%s').", #exp, #found, \ 29 "Check failed: (%s) != (%s) ('%s' vs '%s').", #exp, #found, \
29 exp_, found_); \ 30 exp_, found_ ? found_ : "<null>"); \
30 } \ 31 } \
31 } while (0) 32 } while (0)
32 33
33 void PrintStackTrace(v8::Local<v8::StackTrace> stack) { 34 void PrintStackTrace(v8::Local<v8::StackTrace> stack) {
34 printf("Stack Trace (length %d):\n", stack->GetFrameCount()); 35 printf("Stack Trace (length %d):\n", stack->GetFrameCount());
35 for (int i = 0, e = stack->GetFrameCount(); i != e; ++i) { 36 for (int i = 0, e = stack->GetFrameCount(); i != e; ++i) {
36 v8::Local<v8::StackFrame> frame = stack->GetFrame(i); 37 v8::Local<v8::StackFrame> frame = stack->GetFrame(i);
37 v8::Local<v8::String> script = frame->GetScriptName();
38 v8::Local<v8::String> func = frame->GetFunctionName(); 38 v8::Local<v8::String> func = frame->GetFunctionName();
39 printf("[%d] (%s) %s:%d:%d\n", i, 39 if (frame->IsWasm()) {
40 script.IsEmpty() ? "<null>" : *v8::String::Utf8Value(script), 40 printf("[%d] (<WASM>) %s:%d\n", i,
41 func.IsEmpty() ? "<null>" : *v8::String::Utf8Value(func), 41 func.IsEmpty() ? "<null>" : *v8::String::Utf8Value(func),
42 frame->GetLineNumber(), frame->GetColumn()); 42 frame->GetWasmByteOffset());
43 } else {
44 v8::Local<v8::String> script = frame->GetScriptName();
45 printf("[%d] (%s) %s:%d:%d\n", i,
46 script.IsEmpty() ? "<null>" : *v8::String::Utf8Value(script),
47 func.IsEmpty() ? "<null>" : *v8::String::Utf8Value(func),
48 frame->GetLineNumber(), frame->GetColumn());
49 }
43 } 50 }
44 } 51 }
45 52
46 struct ExceptionInfo { 53 struct ExceptionInfo {
47 const char* funcName; 54 const char* funcName;
48 int lineNr; 55 int lineNr;
49 }; 56 };
50 57
51 template <int N> 58 template <int N>
52 void CheckExceptionInfos(Isolate* isolate, Handle<Object> exc, 59 void CheckExceptionInfos(Isolate* isolate, Handle<Object> exc,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 v8::StackTrace::kOverview); 108 v8::StackTrace::kOverview);
102 Handle<Object> global(isolate->context()->global_object(), isolate); 109 Handle<Object> global(isolate->context()->global_object(), isolate);
103 MaybeHandle<Object> maybe_exc; 110 MaybeHandle<Object> maybe_exc;
104 Handle<Object> args[] = {js_wasm_wrapper}; 111 Handle<Object> args[] = {js_wasm_wrapper};
105 MaybeHandle<Object> returnObjMaybe = 112 MaybeHandle<Object> returnObjMaybe =
106 Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc); 113 Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc);
107 CHECK(returnObjMaybe.is_null()); 114 CHECK(returnObjMaybe.is_null());
108 115
109 // Line number is 1-based, with 0 == kNoLineNumberInfo. 116 // Line number is 1-based, with 0 == kNoLineNumberInfo.
110 ExceptionInfo expected_exceptions[] = { 117 ExceptionInfo expected_exceptions[] = {
111 {"a", 3}, // Comment to prevent clang-format complaints 118 {"a", 3}, // Prevent clang-format changes.
112 {"js", 4}, // - 119 {"js", 4}, // -
113 {"<WASM>", 0}, // - 120 {"<WASM UNNAMED>", 0}, // -
114 {"<WASM>", 0}, // - 121 {"<WASM UNNAMED>", 0}, // -
115 {"callFn", 1}}; 122 {"callFn", 1}};
116 CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(), 123 CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(),
117 expected_exceptions); 124 expected_exceptions);
118 } 125 }
119 126
120 // Trigger a trap in WASM, stack should be JS -> WASM -> WASM. 127 // Trigger a trap in WASM, stack should be JS -> WASM -> WASM.
121 TEST(CollectDetailedWasmStack_WasmError) { 128 TEST(CollectDetailedWasmStack_WasmError) {
122 TestSignatures sigs; 129 TestSignatures sigs;
123 TestingModule module; 130 TestingModule module;
124 131
(...skipping 20 matching lines...) Expand all
145 v8::StackTrace::kOverview); 152 v8::StackTrace::kOverview);
146 Handle<Object> global(isolate->context()->global_object(), isolate); 153 Handle<Object> global(isolate->context()->global_object(), isolate);
147 MaybeHandle<Object> maybe_exc; 154 MaybeHandle<Object> maybe_exc;
148 Handle<Object> args[] = {js_wasm_wrapper}; 155 Handle<Object> args[] = {js_wasm_wrapper};
149 MaybeHandle<Object> maybe_return_obj = 156 MaybeHandle<Object> maybe_return_obj =
150 Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc); 157 Execution::TryCall(isolate, js_trampoline, global, 1, args, &maybe_exc);
151 CHECK(maybe_return_obj.is_null()); 158 CHECK(maybe_return_obj.is_null());
152 159
153 // Line number is 1-based, with 0 == kNoLineNumberInfo. 160 // Line number is 1-based, with 0 == kNoLineNumberInfo.
154 ExceptionInfo expected_exceptions[] = { 161 ExceptionInfo expected_exceptions[] = {
155 {"<WASM>", 0}, // Comment to prevent clang-format complaints. 162 {"exec_unreachable", 0}, // Prevent clang-format changes.
156 {"<WASM>", 0}, 163 {"call_exec_unreachable", 0}, // -
157 {"callFn", 1}}; 164 {"callFn", 1}};
158 CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(), 165 CheckExceptionInfos(isolate, maybe_exc.ToHandleChecked(),
159 expected_exceptions); 166 expected_exceptions);
160 } 167 }
OLDNEW
« src/api.cc ('K') | « src/runtime/runtime-function.cc ('k') | test/mjsunit/wasm/stack.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698