Changes between Version 23 and Version 24 of JavascriptDebugging
- Timestamp:
- Jan 4, 2014, 9:33:46 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
JavascriptDebugging
v23 v24 1 1 [[TOC]] 2 3 {{{ 4 #!html 5 <h1 style="color: red"> 6 The JS debugger is temporarily disabled during the SpiderMonkey upgrade (check ticket #2348 for details) 7 </h1> 8 }}} 2 9 3 10 == Introduction == … … 32 39 The following sections describe all these panels in more detail. 33 40 34 35 41 === Files (1) === 36 42 This is a list of all .js files currently loaded into the vfs by the engine. You can type something in the search field and it will only display those files that match the pattern. Double-clicking a file will open it in the file panel in the middle. … … 44 50 45 51 === Actions (3) === 46 47 The actions are basically the same as with other debuggers. 48 You don't change anything at the code or what happens when it's executed. 49 These actions are just commands to stop and continue the execution in a certain way. 52 The actions are basically the same as with other debuggers. You don't change anything at the code or what happens when it's executed. These actions are just commands to stop and continue the execution in a certain way. 50 53 51 54 Be aware that the debugger is only capable of stepping through JS code and has no control over native (c++) code. 52 55 53 ==== Step ==== 54 Step (or step over) continues the execution until the next line of code is reached. 55 If there is a function call on the current line, it does not stop the execution after it entered the function (it steps over it). 56 ==== Step ==== 57 Step (or step over) continues the execution until the next line of code is reached. If there is a function call on the current line, it does not stop the execution after it entered the function (it steps over it). 56 58 57 58 ==== Step into ==== 59 If there is a function call on the current line, it steps into that function and stops the execution at the first line of that function. 60 Otherwise it just stops the execution at the next line of code. 59 ==== Step into ==== 60 If there is a function call on the current line, it steps into that function and stops the execution at the first line of that function. Otherwise it just stops the execution at the next line of code. 61 61 62 62 ==== Step out ==== 63 Continues until the current function is completed and then stops the execution in the parent function. 63 Continues until the current function is completed and then stops the execution in the parent function. 64 64 65 ==== Continue ==== 65 ==== Continue ==== 66 66 Continue the execution of all threads. 67 67 68 ==== Continue thread ==== 68 ==== Continue thread ==== 69 69 Continue the execution of the currently selected thread. 70 70 … … 72 72 Stop the execution of each thread as soon as possible (basically as soon as the next JS code is executed). 73 73 74 75 74 === Threads (4) === 76 Actually the term "thread" is not quite accurate. 77 All ScriptInterface instances are listed there. A ScriptInterface represents a JS runtime and a JS context. 78 Multiple ScriptInterface instances can be used in one or more threads. 79 Important to know is that stopping one thread will sometimes make it impossible to stop another one without continuing the first again. 80 However, if two threads are really running in parallel and independent from each other, the debugger will try to stop the second thread too if you stopped the fist one. 75 Actually the term "thread" is not quite accurate. All ScriptInterface instances are listed there. A ScriptInterface represents a JS runtime and a JS context. Multiple ScriptInterface instances can be used in one or more threads. Important to know is that stopping one thread will sometimes make it impossible to stop another one without continuing the first again. However, if two threads are really running in parallel and independent from each other, the debugger will try to stop the second thread too if you stopped the fist one. 81 76 82 77 If one thread is in break state, you can double-click on it to switch to that thread. The debugger will try to open the file the thread is currently executing and it will display the associated callstack and variables. 83 78 84 79 === Call stack (5) === 85 86 80 [[Image(callstack_and_values.gif, 25%)]] 87 81 88 If you look at this example, keywordTestOR is the innermost function which got called by an anonymous function, which got called by "testFilter" etc... 89 Often the debugger will only show anonymous functions because we are working with prototypes a lot and don't use named functions often. 82 If you look at this example, keywordTestOR is the innermost function which got called by an anonymous function, which got called by "testFilter" etc... Often the debugger will only show anonymous functions because we are working with prototypes a lot and don't use named functions often. 90 83 91 84 You can double-click on one function name to display the variables of that scope. … … 94 87 There are three main types of values that can be displayed. 95 88 96 1. Locals 97 Locals are locals variables in the current scope. 98 2. This 99 This is Javascript's "this" object. If you are a Javascript developer you should know what it is, it's quite difficult to explain. 100 Note that we are using the "strict" mode which means that sometimes the "this" object will be empty. 101 3. Global 89 1. Locals 90 91 Locals are locals variables in the current scope. 92 93 2. This 94 95 This is Javascript's "this" object. If you are a Javascript developer you should know what it is, it's quite difficult to explain. Note that we are using the "strict" mode which means that sometimes the "this" object will be empty. 96 97 3. Global 98 102 99 This is the current global object. 103 100 104 Sometimes retrieving these values from the game via JSON can take quite a while (in rare cases up to 15 seconds). 105 If you want to quickly step through code you should collapse all root nodes (or at least the ones with a lot of values) because their content is only loaded when they are expanded. This will make stepping a lot faster. 101 Sometimes retrieving these values from the game via JSON can take quite a while (in rare cases up to 15 seconds). If you want to quickly step through code you should collapse all root nodes (or at least the ones with a lot of values) because their content is only loaded when they are expanded. This will make stepping a lot faster. 106 102 107 The web GUI remembers expanded nodes and they will stay expanded the next time values are loaded from the service. 108 Sub nodes will not be collapsed if you collapse their parent node (they will become invisible but they will be in expanded state if you expand the parent again). 103 The web GUI remembers expanded nodes and they will stay expanded the next time values are loaded from the service. Sub nodes will not be collapsed if you collapse their parent node (they will become invisible but they will be in expanded state if you expand the parent again). 109 104 110 105 === Breakpoints from code === 111 106 You can use this code to trigger breakpoints from JS code: 112 107 113 {{{ 108 {{{ 114 109 throw "Breakpoint"; 115 110 }}} 116 117 The debugger will clear the exception and stop the execution as if you used "break" or set a breakpoint in the debugger's web GUI. 118 However, these code breakpoints will have to be removed again for final versions of code because the exception will not be cleared if the debugger is not enabled! 119 Maybe we will add this to some kind of "assert" function which will not affect release builds. 111 The debugger will clear the exception and stop the execution as if you used "break" or set a breakpoint in the debugger's web GUI. However, these code breakpoints will have to be removed again for final versions of code because the exception will not be cleared if the debugger is not enabled! Maybe we will add this to some kind of "assert" function which will not affect release builds. 120 112 121 113 === Debugger settings === 122 The debugger supports some settings that allow you to change its behaviour. 123 These settings are not included in the web GUI at the moment and you have to type some URLs in your browser manually to change them. 114 The debugger supports some settings that allow you to change its behaviour. These settings are not included in the web GUI at the moment and you have to type some URLs in your browser manually to change them. 124 115 125 116 ==== Simultaneous thread break ==== 126 It's enabled by default and means that if one thread stops (because of a breakpoint for example), the debugger will try to stop all other threads too. 127 Note: Setting it to false should work but isn't very well tested. 117 It's enabled by default and means that if one thread stops (because of a breakpoint for example), the debugger will try to stop all other threads too. Note: Setting it to false should work but isn't very well tested. 118 128 119 {{{ 129 120 http://127.0.0.1:9000/SetSettingSimultaneousThreadBreak?Enabled=false 130 121 }}} 122 ==== Break on exception ==== 123 It's enabled by default and means that the debugger will stop script execution if any exception is thrown. Even if you disable it, the debugger will still trigger breakpoints exceptions with the message "Breakpoint". 131 124 132 ==== Break on exception ====133 It's enabled by default and means that the debugger will stop script execution if any exception is thrown.134 Even if you disable it, the debugger will still trigger breakpoints exceptions with the message "Breakpoint".135 125 {{{ 136 126 http://127.0.0.1:9000/SetSettingBreakOnException?Enabled=false