source: trunk/src/scripttools/debugging/scripts/commands/tbreak.qs@ 342

Last change on this file since 342 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.9 KB
Line 
1name = "tbreak";
2
3group = "breakpoints";
4
5shortDescription = "Set a temporary breakpoint";
6
7longDescription = "The same as the \"break\" command, except that the breakpoint is automatically deleted as soon as it is triggered.";
8
9seeAlso = [ "break", "ignore" ];
10
11argumentTypes = [ "script-filename" ];
12
13// ### merge with break.qs: only difference is the "singleShot: true" in call to scheduleSetBreakpoint()
14// ### maybe an include() function so commands can share code?
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, singleShot: true });
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, singleShot: true });
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.