source: trunk/src/scripttools/debugging/scripts/commands/break.qs@ 5

Last change on this file since 5 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 1.8 KB
Line 
1name = "break";
2
3group = "breakpoints";
4
5shortDescription = "Set a breakpoint at specified location";
6
7longDescription = "break <file>:<line> : Sets a breakpoint at the given location.";
8longDescription += "\nbreak <line> : Sets a breakpoint at the given line of the current file.";
9
10argumentTypes = [ "script-filename" ];
11
12aliases = [ "b" ];
13
14seeAlso = [ "condition", "delete", "disable", "tbreak" ];
15
16function execute() {
17 if (arguments.length == 0) {
18 message("Missing argument.");
19 return;
20 }
21 var arg = arguments[0];
22 var colonIndex = arg.lastIndexOf(':');
23 if (colonIndex == -1) {
24 lineNumber = parseInt(arg);
25 if (isNaN(lineNumber)) {
26 message("Breakpoint location must be of the form <file>:<line> or <line>.");
27 return;
28 }
29 var sid = getCurrentScriptId();
30 if (sid == -1) {
31 message("No script.");
32 return;
33 }
34 scheduleGetScriptData(sid);
35 scriptId = sid;
36 state = 1;
37 } else {
38 fileName = arg.slice(0, colonIndex);
39 lineNumber = parseInt(arg.slice(colonIndex+1));
40 // ### resolve the script to see if it's loaded or not? (e.g. so we can issue a warning)
41 scheduleSetBreakpoint({ fileName: fileName, lineNumber: lineNumber});
42 state = 2;
43 }
44}
45
46function handleResponse(resp) {
47 if (state == 1) {
48 fileName = resp.result.fileName;
49 if (fileName.length == 0)
50 fileName = "<anonymous script, id=" + scriptId + ">";
51 scheduleSetBreakpoint({ scriptId: scriptId, lineNumber: lineNumber});
52 state = 2;
53 } else if (state == 2) {
54 if (resp.error == 0) {
55 var id = resp.result;
56 message("Breakpoint " + id + ": " + fileName + ", line " + lineNumber + ".");
57 }
58 }
59}
Note: See TracBrowser for help on using the repository browser.