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

Side by Side Diff: test/inspector/debugger/asm-js-breakpoint-during-exec.js

Issue 2457433002: Fix detection of BUILTIN functions (Closed)
Patch Set: Fix expected output Created 4 years, 1 month 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
(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 --allow-natives-syntax
6
7 InspectorTest.log(
8 'This test runs asm.js which calls back to JS. JS triggers a break, on ' +
9 'pause we set breakpoints in the asm.js code.');
10
11 function testFunction() {
12 function generateAsmJs(stdlib, foreign, heap) {
13 'use asm';
14 var debugger_fun = foreign.call_debugger;
15 function callDebugger() {
16 debugger_fun();
17 }
18 function redirectFun() {
19 callDebugger();
20 }
21 return redirectFun;
22 }
23
24 function call_debugger() {
25 debugger;
26 }
27
28 %OptimizeFunctionOnNextCall(generateAsmJs);
29 var fun = generateAsmJs(this, {'call_debugger': call_debugger}, undefined);
30 fun();
31
32 var finished = 'finished';
33 debugger;
34 }
35
36 Protocol.Debugger.onPaused(handleDebuggerPaused);
37 Protocol.Debugger.onScriptParsed(handleScriptParsed);
38
39 function printResultAndContinue(next, message) {
40 if (message.result && message.result.exceptionDetails)
41 InspectorTest.logMessage(message.result.exceptionDetails);
42 else if (message.error)
43 InspectorTest.logMessage(message.error);
44 else if (message.result && message.result.type !== undefined)
45 InspectorTest.logMessage(message.result);
46 if (next) next();
47 }
48
49 InspectorTest.runTestSuite([
50 function enableDebugger(next) {
51 Protocol.Debugger.enable().then(next);
52 },
53
54 function addScript(next) {
55 afterScriptParsedCallback = next;
56 InspectorTest.addScript(testFunction.toString());
57 },
58
59 function runTestFunction(next) {
60 afterFinishedTestFunctionCallback = next;
61 Protocol.Runtime.evaluate({'expression': 'testFunction()'})
62 .then(printResultAndContinue.bind(null, null));
63 },
64
65 function finished(next) {
66 InspectorTest.log('Finished TestSuite.');
67 next();
68 },
69 ]);
70
71 function locationToString(callFrame) {
72 var res = {functionName: callFrame.functionName};
73 for (var attr in callFrame.functionLocation) {
74 if (attr == 'scriptId') continue;
75 res['function_' + attr] = callFrame.functionLocation[attr];
76 }
77 for (var attr in callFrame.location) {
78 if (attr == 'scriptId') continue;
79 res[attr] = callFrame.location[attr];
80 }
81 return JSON.stringify(res);
82 }
83
84 function logStackTrace(messageObject) {
85 var frames = messageObject.params.callFrames;
86 for (var i = 0; i < frames.length; ++i) {
87 InspectorTest.log(' - [' + i + '] ' + locationToString(frames[i]));
88 }
89 }
90
91 var numPaused = 0;
92 var parsedScriptParams;
93
94 function handleDebuggerPaused(messageObject)
95 {
96 ++numPaused;
97 InspectorTest.log('Paused #' + numPaused);
98 logStackTrace(messageObject);
99
100 function cont() {
101 var topFrameId = messageObject.params.callFrames[0].callFrameId;
102 Protocol.Debugger
103 .evaluateOnCallFrame({
104 callFrameId: topFrameId,
105 expression: 'typeof finished'
106 })
107 .then(callbackEvaluate);
108 function callbackEvaluate(message) {
109 var finished = message.result && message.result.result &&
110 message.result.result.value === 'string';
111
112 InspectorTest.log('Resuming...');
113 Protocol.Debugger.resume();
114
115 if (finished)
116 afterFinishedTestFunctionCallback();
117 }
118 }
119
120 if (numPaused > 1) {
121 cont();
122 return;
123 }
124
125 InspectorTest.log('First time paused, setting breakpoints!');
126
127 var startLine = parsedScriptParams.startLine;
128 var endLine = parsedScriptParams.endLine;
129 InspectorTest.log(
130 'Flooding script with breakpoints for all lines (' + startLine + ' - ' +
131 endLine + ')...');
132 var currentLine = startLine;
133 function setNextBreakpoint(message) {
134 if (message) InspectorTest.logMessage('error: ' + message.error);
135 if (currentLine == endLine) {
136 cont();
137 return;
138 }
139 var thisLine = currentLine;
140 currentLine += 1;
141 InspectorTest.log('Setting breakpoint on line ' + thisLine);
142 Protocol.Debugger
143 .setBreakpoint({
144 'location': {
145 'scriptId': parsedScriptParams.scriptId,
146 'lineNumber': thisLine
147 }
148 })
149 .then(setNextBreakpoint);
150 }
151 setNextBreakpoint();
152 }
153
154 var numScripts = 0;
155
156 function handleScriptParsed(messageObject)
157 {
158 var scriptId = messageObject.params.scriptId;
159 ++numScripts;
160 InspectorTest.log('Script nr ' + numScripts + ' parsed!');
161 if (numScripts == 1) {
162 parsedScriptParams = JSON.parse(JSON.stringify(messageObject.params));
163 afterScriptParsedCallback();
164 }
165 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698