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

Side by Side Diff: test/inspector/debugger/wasm-get-breakable-locations.js

Issue 2536763002: [inspector] [wasm] Implement GetPossibleBreakpoints (Closed)
Patch Set: Rebase Created 4 years 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 // Flags: --expose-wasm 5 // Flags: --expose-wasm
6 6
7 load('test/mjsunit/wasm/wasm-constants.js'); 7 load('test/mjsunit/wasm/wasm-constants.js');
8 load('test/mjsunit/wasm/wasm-module-builder.js'); 8 load('test/mjsunit/wasm/wasm-module-builder.js');
9 9
10 var builder = new WasmModuleBuilder(); 10 var builder = new WasmModuleBuilder();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 var instance = new WebAssembly.Instance(module, {'func': call_debugger}); 48 var instance = new WebAssembly.Instance(module, {'func': call_debugger});
49 49
50 instance.exports.main(1); 50 instance.exports.main(1);
51 } 51 }
52 52
53 InspectorTest.addScript(testFunction.toString()); 53 InspectorTest.addScript(testFunction.toString());
54 InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes)); 54 InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes));
55 55
56 Protocol.Debugger.enable(); 56 Protocol.Debugger.enable();
57 Protocol.Debugger.onScriptParsed(handleScriptParsed); 57 Protocol.Debugger.onScriptParsed(handleScriptParsed);
58 Protocol.Debugger.onPaused(handlePaused);
58 InspectorTest.log('Running testFunction...'); 59 InspectorTest.log('Running testFunction...');
59 Protocol.Runtime.evaluate({'expression': 'testFunction(module_bytes)'}); 60 Protocol.Runtime.evaluate({'expression': 'testFunction(module_bytes)'});
60 61
61 var numScripts = 0; 62 var numScripts = 0;
63 var wasmScripts = [];
62 function handleScriptParsed(messageObject) { 64 function handleScriptParsed(messageObject) {
63 var scriptId = messageObject.params.scriptId; 65 var scriptId = messageObject.params.scriptId;
64 var url = messageObject.params.url; 66 var url = messageObject.params.url;
65 InspectorTest.log('Script nr ' + numScripts + ' parsed. URL: ' + url); 67 InspectorTest.log('Script nr ' + numScripts + ' parsed. URL: ' + url);
66 ++numScripts; 68 ++numScripts;
67 69
68 if (url.startsWith('wasm://')) { 70 if (url.startsWith('wasm://')) {
69 InspectorTest.log('This is a wasm script. Requesting breakable locations.'); 71 InspectorTest.log('This is a wasm script (nr ' + wasmScripts.length + ').');
70 Protocol.Debugger 72 wasmScripts.push(scriptId);
71 .getPossibleBreakpoints(
72 {start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}})
73 .then(InspectorTest.logMessage)
74 .then(InspectorTest.completeTest);
75 } 73 }
76 } 74 }
75
76 function printBreakableLocations(message, expectedScriptId, source) {
77 if (!message.result || !message.result.locations) {
78 InspectorTest.logMessage(message);
79 return;
80 }
81 var lines = source.split('\n');
82 var locations = message.result.locations;
83 InspectorTest.log(locations.length + ' breakable location(s):');
84 for (var i = 0; i < locations.length; ++i) {
85 if (locations[i].scriptId != expectedScriptId) {
86 InspectorTest.log(
87 'SCRIPT ID MISMATCH!! ' + locations[i].scriptId + ' != ' +
88 expectedScriptId);
89 }
90 var line = locations[i].lineNumber < lines.length ?
91 lines[locations[i].lineNumber] :
92 '<illegal line number>';
93 InspectorTest.log(
94 '[' + i + '] ' + locations[i].lineNumber + ':' +
95 locations[i].columnNumber + ' || ' + line);
96 }
97 }
98
99 function getSourceFromMessage(message) {
100 if (!message.result || !message.result.scriptSource) {
101 InspectorTest.logMessage(message);
102 return '';
103 }
104 return message.result.scriptSource;
105 }
106
107 function checkGetBreakableLocations(wasmScriptNr) {
kozy 2016/11/30 17:38:16 You can improve this test by adding two steps afte
Clemens Hammacher 2016/11/30 17:52:19 Breakpoint support is not there yet, but is a P1 f
108 InspectorTest.log(
109 'Requesting all breakable locations in wasm script ' + wasmScriptNr);
110 var scriptId = wasmScripts[wasmScriptNr];
111 var source;
112 return Protocol.Debugger.getScriptSource({scriptId: scriptId})
113 .then((message) => source = getSourceFromMessage(message))
114 .then(
115 () => Protocol.Debugger.getPossibleBreakpoints(
116 {start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}}))
117 .then((message) => printBreakableLocations(message, scriptId, source))
118 .then(
119 () =>
120 InspectorTest.log('Requesting breakable locations up to line 2'))
121 .then(() => Protocol.Debugger.getPossibleBreakpoints({
122 start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId},
123 end: {lineNumber: 3, columnNumber: 0, scriptId: scriptId}
124 }))
125 .then((message) => printBreakableLocations(message, scriptId, source))
126 .then(
127 () =>
128 InspectorTest.log('Requesting breakable locations in lines 3-4'))
129 .then(() => Protocol.Debugger.getPossibleBreakpoints({
130 start: {lineNumber: 3, columnNumber: 0, scriptId: scriptId},
131 end: {lineNumber: 5, columnNumber: 0, scriptId: scriptId}
132 }))
133 .then((message) => printBreakableLocations(message, scriptId, source));
134 }
135
136 function handlePaused() {
137 InspectorTest.log('Paused on \'debugger\'.');
138 var promise = Promise.resolve();
139 for (var wasmScriptNr = 0; wasmScriptNr < wasmScripts.length;
140 ++wasmScriptNr) {
141 promise = promise.then(checkGetBreakableLocations.bind(null, wasmScriptNr));
142 }
143 promise.then(() => InspectorTest.log('Finished!'))
144 .then(InspectorTest.completeTest);
145 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-objects.cc ('k') | test/inspector/debugger/wasm-get-breakable-locations-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698