OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --expose-wasm --validate-asm | |
6 | |
7 Debug = debug.Debug | |
8 | |
9 // Initialized in setup(). | |
10 var exception; | |
11 var break_count; | |
12 var num_wasm_scripts; | |
13 var module; | |
14 | |
15 var filename = '(?:[^ ]+/)?test/mjsunit/wasm/asm-debug.js'; | |
16 filename = filename.replace(/\//g, '[/\\\\]'); | |
17 | |
18 var expected_stack_entries = []; | |
19 | |
20 function listener(event, exec_state, event_data, data) { | |
21 try { | |
22 if (event == Debug.DebugEvent.Break) { | |
23 ++break_count; | |
24 // Request frame details. | |
25 var num_frames = exec_state.frameCount(); | |
26 assertEquals( | |
27 expected_stack_entries.length, num_frames, 'number of frames'); | |
28 print('Stack Trace (length ' + num_frames + '):'); | |
29 for (var i = 0; i < num_frames; ++i) { | |
30 var frame = exec_state.frame(i); | |
31 var script = frame.script(); | |
32 assertNotNull(script); | |
33 var line = frame.sourceLine() + 1; | |
34 var column = frame.sourceColumn() + 1; | |
35 var funcName = frame.func().name(); | |
36 var name = script.name(); | |
37 print( | |
38 ' [' + i + '] ' + funcName + ' (' + name + ':' + line + ':' + | |
39 column + ')'); | |
40 assertMatches(filename, name, 'name'); | |
41 assertEquals( | |
42 expected_stack_entries[i][0], funcName, 'function name at ' + i); | |
43 assertEquals(expected_stack_entries[i][1], line, 'line at ' + i); | |
44 assertEquals(expected_stack_entries[i][2], column, 'column at ' + i); | |
45 } | |
46 } | |
47 } catch (e) { | |
48 print('exception: ' + e); | |
49 exception = e; | |
50 } | |
51 }; | |
52 | |
53 function generateWasmFromAsmJs(stdlib, foreign, heap) { | |
54 'use asm'; | |
55 var debugger_fun = foreign.call_debugger; | |
56 function callDebugger() { | |
57 debugger_fun(); | |
58 } | |
59 function redirectFun() { | |
60 callDebugger(); | |
61 } | |
62 return redirectFun; | |
63 } | |
64 | |
65 function call_debugger() { | |
66 debugger; | |
67 } | |
68 | |
69 function setup() { | |
70 exception = null; | |
71 break_count = 0; | |
72 } | |
73 | |
74 (function FrameInspection() { | |
75 setup(); | |
76 var fun = | |
77 generateWasmFromAsmJs(this, {'call_debugger': call_debugger}, undefined); | |
78 expected_stack_entries = [ | |
79 ['call_debugger', 66, 3], // -- | |
80 ['callDebugger', 57, 5], // -- | |
81 ['redirectFun', 60, 5], // -- | |
82 ['FrameInspection', 86, 3], // -- | |
83 ['', 89, 3] | |
84 ]; | |
85 Debug.setListener(listener); | |
86 fun(); | |
87 Debug.setListener(null); | |
88 assertEquals(1, break_count); | |
89 })(); | |
OLD | NEW |