| OLD | NEW | 
|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| 11 //       with the distribution. | 11 //       with the distribution. | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
| 27 | 27 | 
| 28 // Flags: --expose-debug-as debug | 28 // Flags: --expose-debug-as debug | 
| 29 // Get the Debug object exposed from the debug context global object. | 29 // Get the Debug object exposed from the debug context global object. | 
| 30 Debug = debug.Debug | 30 Debug = debug.Debug | 
| 31 var breaks = 0; | 31 var breaks = 0; | 
|  | 32 var exception = false; | 
| 32 | 33 | 
| 33 function sendCommand(state, cmd) { | 34 function sendCommand(state, cmd) { | 
| 34   // Get the debug command processor in paused state. | 35   // Get the debug command processor in paused state. | 
| 35   var dcp = state.debugCommandProcessor(false); | 36   var dcp = state.debugCommandProcessor(false); | 
| 36   var request = JSON.stringify(cmd); | 37   var request = JSON.stringify(cmd); | 
| 37   var response = dcp.processDebugJSONRequest(request); | 38   var response = dcp.processDebugJSONRequest(request); | 
| 38 } | 39 } | 
| 39 | 40 | 
| 40 function listener(event, exec_state, event_data, data) { | 41 function listener(event, exec_state, event_data, data) { | 
| 41   try { | 42   try { | 
| 42     if (event == Debug.DebugEvent.Break) { | 43     if (event == Debug.DebugEvent.Break) { | 
| 43       var line = event_data.sourceLineText(); | 44       var line = event_data.sourceLineText(); | 
| 44       print('break: ' + line); | 45       print('break: ' + line); | 
| 45 | 46 | 
| 46       assertEquals(-1, line.indexOf('NOBREAK'), | 47       assertEquals(-1, line.indexOf('NOBREAK'), | 
| 47                    "should not break on unexpected lines") | 48                    "should not break on unexpected lines") | 
| 48       assertEquals('BREAK ' + breaks, line.substr(-7)); | 49       assertEquals('BREAK ' + breaks, line.substr(-7)); | 
| 49       breaks++; | 50       breaks++; | 
| 50       sendCommand(exec_state, { | 51       if (breaks < 4) { | 
| 51         seq: 0, | 52         sendCommand(exec_state, { | 
| 52         type: "request", | 53           seq: 0, | 
| 53         command: "continue", | 54           type: "request", | 
| 54         arguments: { stepaction: "next" } | 55           command: "continue", | 
| 55       }); | 56           arguments: { stepaction: "next" } | 
|  | 57         }); | 
|  | 58       } | 
| 56     } | 59     } | 
| 57   } catch (e) { | 60   } catch (e) { | 
| 58     print(e); | 61     print(e); | 
|  | 62     exception = true; | 
| 59   } | 63   } | 
| 60 } | 64 } | 
| 61 | 65 | 
| 62 // Add the debug event listener. | 66 // Add the debug event listener. | 
| 63 Debug.setListener(listener); | 67 Debug.setListener(listener); | 
| 64 | 68 | 
| 65 function a(f) { | 69 function a(f) { | 
| 66   if (f) {  // NOBREAK: should not break here! | 70   if (f) {  // NOBREAK: should not break here! | 
| 67     try { | 71     try { | 
| 68       f(); | 72       f(); | 
| 69     } catch(e) { | 73     } catch(e) { | 
| 70     } | 74     } | 
| 71   } | 75   } | 
| 72 }  // BREAK 2 | 76 }  // BREAK 2 | 
| 73 | 77 | 
| 74 function b() { | 78 function b() { | 
| 75   c();  // BREAK 0 | 79   c();  // BREAK 0 | 
| 76 }  // BREAK 1 | 80 }  // BREAK 1 | 
| 77 | 81 | 
| 78 function c() { | 82 function c() { | 
| 79   a(); | 83   a(); | 
| 80 } | 84 } | 
| 81 | 85 | 
| 82 // Set a break point and call to invoke the debug event listener. | 86 // Set a break point and call to invoke the debug event listener. | 
| 83 Debug.setBreakPoint(b, 0, 0); | 87 Debug.setBreakPoint(b, 0, 0); | 
| 84 a(b); | 88 a(b); | 
| 85 // BREAK 3 | 89 a(); // BREAK 3 | 
|  | 90 | 
|  | 91 assertFalse(exception); | 
| OLD | NEW | 
|---|