|
1 | 1 | --- |
2 | 2 | title: Debug user code with Just My Code |
3 | 3 | description: Just My Code is a debugging feature that automatically steps over calls to non-user code. Learn how to enable, disable, and use this feature. |
4 | | -ms.date: 08/23/2024 |
| 4 | +ms.date: 10/14/2024 |
5 | 5 | ms.topic: how-to |
6 | 6 | author: mikejo5000 |
7 | 7 | ms.author: mikejo |
@@ -123,7 +123,7 @@ If first chance exceptions are enabled for the exception, the calling user-code |
123 | 123 | Starting in Visual Studio 2017 version 15.8, Just My Code for code stepping is also supported. This feature also requires use of the [/JMC (Just my code debugging)](/cpp/build/reference/jmc) compiler switch. The switch is enabled by default in C++ projects. For **Call Stack** window and call stack support in Just My Code, the /JMC switch isn't required. |
124 | 124 |
|
125 | 125 | <a name="BKMK_CPP_User_and_non_user_code"></a> |
126 | | -To be classified as user code, the PDB for the binary containing the user code must be loaded by the debugger (use the **Modules** window to check this). |
| 126 | +To be classified as user code, the PDB for the binary containing the user code must be loaded by the debugger (use the **Modules** window to check loading status). |
127 | 127 |
|
128 | 128 | For call stack behavior, such as in the **Call Stack** window, Just My Code in C++ considers only these functions to be *non-user code*: |
129 | 129 |
|
@@ -249,111 +249,6 @@ A *.natstepfilter* file is an XML file with this syntax: |
249 | 249 | ## <a name="BKMK_JavaScript_Just_My_Code"></a> JavaScript Just My Code |
250 | 250 |
|
251 | 251 | <a name="BKMK_JS_User_and_non_user_code"></a> |
252 | | -JavaScript Just My Code controls stepping and call stack display by categorizing code in one of these classifications: |
| 252 | +For *.esproj* projects in Visual Studio 2022, Visual Studio Code uses a *launch.json* file to configure and customize the debugger. *launch.json* is a debugger configuration file. |
253 | 253 |
|
254 | | -|Classification|Description| |
255 | | -|-|-| |
256 | | -|**MyCode**|User code that you own and control.| |
257 | | -|**LibraryCode**|Non-user code from libraries that you use regularly and your app relies on to function correctly (for example, jQuery).| |
258 | | -|**UnrelatedCode**|Non-user code in your app that you don't own and your app doesn't rely on to function correctly. For example, an advertising SDK that displays ads could be UnrelatedCode.| |
259 | | - |
260 | | -The JavaScript debugger classifies code as user or non-user in this order: |
261 | | - |
262 | | -1. The default classifications. |
263 | | - - Script executed by passing a string to the host-provided `eval` function is **MyCode**. |
264 | | - - Script executed by passing a string to the `Function` constructor is **LibraryCode**. |
265 | | - - Script in a framework reference, such as WinJS or the Azure SDK, is **LibraryCode**. |
266 | | - - Script executed by passing a string to the `setTimeout`, `setImmediate`, or `setInterval` functions is **UnrelatedCode**. |
267 | | - |
268 | | -2. Classifications in the *mycode.json* file of the current project. |
269 | | - |
270 | | -Each classification step overrides the previous steps. |
271 | | - |
272 | | -All other code is classified as **MyCode**. |
273 | | - |
274 | | -You can modify the default classifications, and classify specific files and URLs as user or non-user code, by adding a *.json* file named *mycode.json* to the root folder of a JavaScript project. See [Customize JavaScript Just My Code](#BKMK_JS_Customize_Just_My_Code). |
275 | | - |
276 | | -<a name="BKMK_JS_Stepping_behavior"></a> |
277 | | -During JavaScript debugging: |
278 | | - |
279 | | -- If a function is non-user code, **Debug** > **Step Into** (or **F11**) behaves the same as **Debug** > **Step Over** (or **F10**). |
280 | | -- If a step begins in non-user (**LibraryCode** or **UnrelatedCode**) code, stepping temporarily behaves as if Just My Code isn't enabled. When you step back to user code, Just My Code stepping is re-enabled. |
281 | | -- When a user code step results in leaving the current execution context, the debugger stops at the next executed user code line. For example, if a callback executes in **LibraryCode** code, the debugger continues until the next line of user code executes. |
282 | | -- **Step Out** (or **Shift**+**F11**) stops on the next line of user code. |
283 | | - |
284 | | -If there's no more user code, debugging continues until it ends, hits another breakpoint, or throws an error. |
285 | | - |
286 | | -Breakpoints set in code are always hit, but the code is classified. |
287 | | - |
288 | | -- If the `debugger` keyword occurs in **LibraryCode**, the debugger always breaks. |
289 | | -- If the `debugger` keyword occurs in **UnrelatedCode**, the debugger doesn't stop. |
290 | | - |
291 | | -<a name="BKMK_JS_Exception_behavior"></a> |
292 | | -If an unhandled exception occurs in **MyCode** or **LibraryCode** code, the debugger always breaks. |
293 | | - |
294 | | -If an unhandled exception occurs in **UnrelatedCode**, and **MyCode** or **LibraryCode** is on the call stack, the debugger breaks. |
295 | | - |
296 | | -If first-chance exceptions are enabled for the exception, and the exception occurs in **LibraryCode** or **UnrelatedCode**: |
297 | | - |
298 | | -- If the exception is handled, the debugger doesn't break. |
299 | | -- If the exception isn't handled, the debugger breaks. |
300 | | - |
301 | | -### <a name="BKMK_JS_Customize_Just_My_Code"></a> Customize JavaScript Just My Code |
302 | | - |
303 | | -To categorize user and non-user code for a single JavaScript project, you can add a *.json* file named *mycode.json* to the root folder of the project. |
304 | | - |
305 | | -The *mycode.json* file doesn't need to list all key value pairs. The **MyCode**, **Libraries**, and **Unrelated** values can be empty arrays. |
306 | | - |
307 | | -*Mycode.json* files use this syntax: |
308 | | - |
309 | | -```json |
310 | | -{ |
311 | | - "Eval" : "Classification", |
312 | | - "Function" : "Classification", |
313 | | - "ScriptBlock" : "Classification", |
314 | | - "MyCode" : [ |
315 | | - "UrlOrFileSpec", |
316 | | - . . . |
317 | | - "UrlOrFileSpec" |
318 | | - ], |
319 | | - "Libraries" : [ |
320 | | - "UrlOrFileSpec", |
321 | | - . . |
322 | | - "UrlOrFileSpec" |
323 | | - ], |
324 | | - "Unrelated" : [ |
325 | | - "UrlOrFileSpec", |
326 | | - . . . |
327 | | - "UrlOrFileSpec" |
328 | | - ] |
329 | | -} |
330 | | - |
331 | | -``` |
332 | | - |
333 | | -**Eval, Function, and ScriptBlock** |
334 | | - |
335 | | -The **Eval**, **Function**, and **ScriptBlock** key value pairs determine how dynamically generated code is classified: |
336 | | - |
337 | | -|Name|Description| |
338 | | -|-|-| |
339 | | -|**Eval**|Script that is executed by passing a string to the host-provided `eval` function. By default, Eval script is classified as **MyCode**.| |
340 | | -|**Function**|Script that is executed by passing a string to the `Function` constructor. By default, Function script is classified as **LibraryCode**.| |
341 | | -|**ScriptBlock**|Script that is executed by passing a string to the `setTimeout`, `setImmediate`, or `setInterval` functions. By default, ScriptBlock script is classified as **UnrelatedCode**.| |
342 | | - |
343 | | -You can change the value to one of these keywords: |
344 | | - |
345 | | -- `MyCode` classifies the script as **MyCode**. |
346 | | -- `Library` classifies the script as **LibraryCode**. |
347 | | -- `Unrelated` classifies the script as **UnrelatedCode**. |
348 | | - |
349 | | -**MyCode, Libraries, and Unrelated** |
350 | | - |
351 | | -The **MyCode**, **Libraries**, and **Unrelated** key value pairs specify the URLs or files that you want to include in a classification: |
352 | | - |
353 | | -|Name|Description| |
354 | | -|-|-| |
355 | | -|**MyCode**|An array of URLs or files that are classified as **MyCode**.| |
356 | | -|**Libraries**|An array of URLs or files that are classified as **LibraryCode**.| |
357 | | -|**Unrelated**|An array of URLs or files that are classified as **UnrelatedCode**.| |
358 | | - |
359 | | -The URL or file string can have one or more `*` characters, which match zero or more characters. `*` is the same as the regular expression `.*`. |
| 254 | +Visual Studio attaches the debugger only to user code. For *.esproj* projects, you can configure user code (that is, *Just My Code* settings) in Visual Studio using the `skipFiles` setting in *launch.json*. This setting works the same as the *launch.json* settings in VS Code. For more information about *skipFiles*, see [Skipping Uninteresting Code](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_skipping-uninteresting-code). |
0 commit comments