-
Notifications
You must be signed in to change notification settings - Fork 8
Description
What
The proposal has 2 complementary ideas:
- Provide sample
launch.jsonfiles for students to copy, rather than creating via the interface. - Add comments to the
launch.jsonfile to explain what each part does and provide guidance on any edits.
Where
Mac/Windows setup tutorials for VS Code. OR, a separate location for sample launch.json files (if e.g. we wanted to host them for various courses).
Idea 1 - Provide Sample launch.json Configurations
Creating launch.json through the VS Code interface is OK, but there are a few annoyances:
- If students haven't opened a C++ file, they aren't provided the correct option in the dropdown to add a configuration.
- CodeLLDB fails to create launch.json when rust is not installed #224 where a bug in the CodeLLDB extension made the dropdown
launch.jsoncreation not work. - Students clicking the wrong thing or being unsure whether they want e.g. C++ (GDB/LLDB) vs. CodeLLDB
I think creating a launch.json file manually (e.g. mkdir -p .vscode && touch .vscode/launch.json) or via the interface and then copying in a configuration is probably more reliable.
And, I don't think there's any pedagogical loss in providing a sample launch.json config - we already tell them exactly what to click and then a default config pops up. To be honest, any time I've ever configured something myself, the first thing I do is look for a sample online, e.g. https://tsx.is/vscode.
The sample files could be copied out of the tutorial page, or provided via a wget like our sample .gitignore. We would need one sample for Windows+WSL and one for Mac. (I don't think we need a different sample for different projects.)
(For Mac, we could potentially maintain two examples, one for CodeLLDB and one for the MS extension, or only provide the CodeLLDB version. Regardless, having a note to double check the "type" against your installed extension would be helpful for students who get that mixed up.)
We could also consider whether it might make sense for EECS 280 to maintain several sample launch.json configs that may be used by other courses.
Idea 2 - Explanatory Comments in launch.json
If students don't understand the configuration, it's hard for them to adapt, even in small ways (e.g. setting up command line arguments).
Adding comments to a sample launch.json puts the key information right there for students when they are looking at launch.json. It also serves as a clear guide for "change this if you need to do X". While .json files don't universally support comments, VS Code treats launch.json specially (and in fact the generated one has comments).
My hope is that students would also create multiple configurations (rather than editing "program", "args", etc. back and forth) and that the process of copying and updating the configuration options will actually help them learn and remember what each piece does better.
Example
I put together a quick example for Windows+WSL in EECS 280.
Another example from my 498 for debugging a TypeScript program run via tsx:
{
"version": "0.2.0",
// launch.json defines debugging configurations. You can select among
// the configurations from the dropdown menu in the Debug left panel.
"configurations": [
// Debug the active TS file (i.e. the one open in the editor).
// If you launch while looking at launch.json, you'll get an error!
{
"name": "Debug Current File (tsx)",
"type": "node",
"request": "launch",
"runtimeExecutable": "npx",// "npx tsx" with the current file.
"args": [ "tsx", "--", "${file}"],
"cwd": "${workspaceFolder}", // Set working directory to workspace root.
"console": "integratedTerminal", // Necessary for user input via stdin.
"internalConsoleOptions": "neverOpen", // Don't focus debug console automatically.
"sourceMaps": true, // Enable source maps for TypeScript debugging.
"skipFiles": [ // Don't step into libraries or dependencies when debugging.
"<node_internals>/**",
"${workspaceFolder}/node_modules/**",
],
"smartStep": true, // Skip over implicitly generated code when stepping.
},
// Edit/copy this configuration, replacing EXAMPLE with your own filename,
// if you would like a dedicated debug configuration for a specific file.
{
"name": "Debug EXAMPLE (tsx)",
"type": "node",
"request": "launch",
"runtimeExecutable": "npx", // "npx tsx" with file below.
"args": [ "tsx", "--", "src/EXAMPLE.ts"],
"cwd": "${workspaceFolder}", // Set working directory to workspace root.
"console": "integratedTerminal", // Necessary for user input via stdin.
"internalConsoleOptions": "neverOpen", // Don't focus debug console automatically.
"sourceMaps": true, // Enable source maps for TypeScript debugging.
"skipFiles": [ // Don't step into libraries or dependencies when debugging.
"<node_internals>/**",
"${workspaceFolder}/node_modules/**",
],
"smartStep": true, // Skip over implicitly generated code when stepping.
}
]
}
{ "version": "0.2.0", // A list of debug configurations. You may add more, separated by commas. // The name you specify is shown in a dropdown menu on the debug panel. // To run a configuration, select it there and click the green play button. // EXAMPLE - for the euchre project, you might create configurations for: // - "Card Public Tests" (running card_public_tests.exe) // - "Card Tests" (running card_tests.exe) // - "Euchre Test 00" (running euchre.exe, with arguments for test 00) // - "Euchre Test 01" (running euchre.exe, with arguments for test 01) // - (similar configs for Pack, Player, and other Euchre tests) "configurations": [ // EXAMPLE - Windows+WSL C++ Debugging // Edit/copy this config. Customize the appropriate properties. { // The name of this configuration, shown in the debug panel dropdown. "name": "EXAMPLE", // The type of debugger to use. On Windows+WSL this should be "cppdbg". // (You must also have the C++ extension installed.) "type": "cppdbg", "request": "launch", // The program to debug. (Examples: card_public_tests.exe, euchre.exe). // REMEMBER - you must compile/recompile your program before debugging! "program": "${workspaceFolder}/example.exe", // Command line arguments to pass to the program when debugging. // Example: ["pack.in", "noshuffle", 3, "Ivan", "Human", ...] "args": [], // Set the current working directory for the debugged program, where // input files are expected to be found. For EECS 280 projects, this // is the top-level project directory, using ${workspaceFolder}. "cwd": "${workspaceFolder}", // Environment variables to set for the debugged program. If compiling // with the AddressSanitizer (ASan) enabled, uncomment the ASAN_OPTIONS. "environment": [ // { // "name": "ASAN_OPTIONS", // // Pause on ASan errors. Disable ASan leak checker, which doesn't // // play nicely with debuggers. // "value": "abort_on_error=1:detect_leaks=0" // } ], ///// You probably don't need to configure options below this line ////// // If true, automatically pause debugger at the first line of main(). "stopAtEntry": false, // Generally set to false to use the integrated terminal in VS Code. "externalConsole": false, // The debugger to use. On Windows+WSL, use "gdb". "MIMode": "gdb", "setupCommands": [ // Enable pretty-printing for gdb to improve display of STL containers. { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] }