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: --validate-asm | |
6 | |
7 function testFunction() { | |
8 function generateAsmJs(stdlib, foreign, heap) { | |
9 'use asm'; | |
10 var debugger_fun = foreign.call_debugger; | |
11 function callDebugger() { | |
12 debugger_fun(); | |
13 } | |
14 function redirectFun() { | |
15 callDebugger(); | |
16 } | |
17 return redirectFun; | |
18 } | |
19 | |
20 function call_debugger() { | |
21 debugger; | |
22 } | |
23 | |
24 var fun = generateAsmJs(this, {'call_debugger': call_debugger}, undefined); | |
25 fun(); | |
26 } | |
27 | |
28 InspectorTest.addScript(testFunction.toString()); | |
29 | |
30 Protocol.Debugger.enable(); | |
31 Protocol.Debugger.oncePaused().then(handleDebuggerPaused); | |
32 Protocol.Runtime.evaluate({'expression': 'testFunction()'}); | |
33 | |
34 function locationToString(callFrame) { | |
35 var res = {functionName: callFrame.functionName}; | |
36 for (var attr in callFrame.functionLocation) { | |
37 if (attr == 'scriptId') continue; | |
38 res['function_'+attr] = callFrame.functionLocation[attr]; | |
39 } | |
40 for (var attr in callFrame.location) { | |
41 if (attr == 'scriptId') continue; | |
42 res[attr] = callFrame.location[attr]; | |
43 } | |
44 return JSON.stringify(res); | |
45 } | |
46 | |
47 function logStackTrace(messageObject) { | |
48 var frames = messageObject.params.callFrames; | |
49 InspectorTest.log('Number of frames: ' + frames.length); | |
50 for (var i = 0; i < frames.length; ++i) { | |
51 InspectorTest.log(' - [' + i + '] ' + locationToString(frames[i])); | |
52 } | |
53 } | |
54 | |
55 function handleDebuggerPaused(messageObject) | |
56 { | |
57 InspectorTest.log('Paused on \'debugger;\''); | |
58 logStackTrace(messageObject); | |
59 InspectorTest.log('Getting v8-generated stack trace...'); | |
60 var topFrameId = messageObject.params.callFrames[0].callFrameId; | |
61 Protocol.Debugger | |
62 .evaluateOnCallFrame({ | |
63 callFrameId: topFrameId, | |
64 expression: '(new Error("getting stack trace")).stack' | |
65 }) | |
66 .then(callbackEvaluate); | |
67 } | |
68 | |
69 function callbackEvaluate(response) | |
70 { | |
71 InspectorTest.log( | |
72 'Result of evaluate (' + response.result.result.type + '):'); | |
73 var result_lines = response.result.result.value.split("\n"); | |
74 // Skip the second line, containing the 'evaluate' position. | |
75 result_lines[1] = " -- skipped --"; | |
76 InspectorTest.log(result_lines.join('\n')); | |
77 InspectorTest.log('Finished!'); | |
78 InspectorTest.completeTest(); | |
79 } | |
OLD | NEW |