Using Visual Studio Code v 1.32.3 on Windows 10, when I navigate to Debug > Add Configuration, nothing happens. No errors or other messages, nothing appears to be written to the workspace folder, no errors in Event Viewer, so far just nothing.
I am somewhat new to VSCode so please don't discount that this might be a newbie error. Potentially notable is that the project is a Cordova project, I have created a Workspace (and confirmed that I am using it and not just opening the folder).
What I have checked so far:
Verifying that nothing is actively trying to build or otherwise access that folder. PhoneGap Desktop is stopped and no emulators running.
Restarted PC
Reinstalled the Cordova Tools plugin
Interestingly if I open a new instance of VS Code and before opening any file or folder I go back to Debug > Add Configuration I will get a message "Please first open a folder in order to do advanced debug configura..." So this indicates that there may be a problem with my workspace or directory but I haven't found it yet.
Any ideas greatly appreciated.
Edit 1:
Version of Cordova Tools is 1.8.0.
I've since tried adding my own launch.json to the .vscode directory. Contents:
{
"version": "0.2.0",
"configurations": [
{
"name": "Run android on device|emulator",
"type": "cordova",
"request": "launch",
"platform": "android",
"target": "device|emulator",
"sourceMaps": true,
"cwd": "${workspaceFolder}"
},
]
}
Notable is that in the bottom right corner of the window a "Add Configuration" button appears while I am viewing launch.json and it does appear to work correctly, prompting me with snippets to add.
None of these impact my ability to debug unfortunately.
Alright I think I have this working. Steps:
I deleted the launch.json added in my edit. (Effectively now no launch.json file again)
Navigate to Debug > Start Debugging
Ignore the error dialog that appears
VSCode will create a launch.json and display the debug menu
From here it looks like I'm back on track.
Check VS Code OUTPUT window. When VS Code is downloading some launcher packages like .NET Core Launch, Debugging process may be affected.
After downloading packages are completed check it again.
ctrl + shift + P then enter "reload window" works for me
For me when I press Add Configuration from the dropdown on the upper left it does nothing, I keep pressing up and down in and out of places and suddently it works... then it does not again...
However I found a blue button on the lower right of the screen that works more consistently, I'm uncertain if it is the same issue or that button doesn't work for you either but this was my own experience.
Did you install the latest version of VS Code? I had the same problem and I fixed it by updating to the latest version.
One silly mistake that may lead to this problem is and that I did was to debug when in a non executable file, so be sure to be in that file which is executable. In my case it was a .cpp file where I should've been but I was in one of the header file .h that I created while debugging.
You should delete .vscode folder and run again debugger extension.
This will generate a new .vscode folder with a launch.json file in.
Related
I've installed Quartus and NIOS II IDE on my Linux machine. Originally I tried importing an existing NIOS II Project into Eclipse, but it just sits there spinning away and eventually tells me it can't import the project because it already exists.
I tried installing everything on a Win10 machine and the project imported OK. I did notice that some of the paths in the orignal project have backslashes. So, for example:
#include "..\subfolder\include_file.h"
Kind of thing. I wonder whether maybe it was that was causing issues.
So, I then tried creating an hello world NIOS Processor in Quartus and making a NIOS II project from scratch. Every step along the way with Eclipse was grindingly slow, but eventually worked up until the point I was able to hit Finish at which point it's just hanging with the little circle with red and blue arrows spinning round and round.
I also have a pop up window with a long list of:
Remote System Explorer Opertion
lines, and at the top it says:
The user operation is waiting for background work to complete
It seems like everything is installed correctly, I can open the NIOS II Eclipse IDE from Quartus for example. Quartus itself works nicely.
I used these instructions to installed Eclipse:
Is anyone able to give me any pointers as to why this is so incredibly slow please? My Linux machine is pretty high spec and flies. Nothing else whatsoever even vaguely struggles on it.
If there's anything I can try to give diagnostic info, am more than happy to supply. Thanks!
I found a solution here
https://askubuntu.com/questions/761604/eclipse-not-working-in-16-04
To test if this fix works, try opening a terminal, and doing
$export SWT_GTK3=0
then run eclipse-nios2. That is, do something like
$ ~/intelFPGA_lite/20.1/nios2eds/bin/eclipse-nios2
If that fixes the problem then to make the fix permanent edit eclipse.ini which for me is in intelFPGA_lite/20.1/nios2eds/bin/eclipse_nios2
In that file, between the lines openFile and --launcher.appendVmargs
insert
--launcher.GTK_version
2
So it reads:
openFile
--launcher.GTK_version
2
--launcher.appendVmargs
and save.
Worked for me!
Try using Visual Studio Code instead. It can do (almost) everything that Eclipse can do, with the added benefit that you can debug remote. E.g. in my setup, I develop exclusively using macOS. I have Quartus installed in a Ubuntu 20.04 VM and VSCODE allows me to develop and debug as if I'm running Quartus natively in macOS.
I'll provide a rough 'how-to' below.
I strongly suggest using a Ubuntu environment for Quartus (other linux environments should work too: I've tested Arch and Manjaro). The Windows install is a royal pain to get working, regardless of IDE choice. I haven't tried the Windows version since 20.1 but nothing worked out of the box and it took many hours or messing with config files to fix it. Also, the Windows version isn't native anyway - it's actually running in Ubuntu via WSL.
Make sure you have installed your required version of Quartus - this should work for Pro, Standard and Lite editions. You can skip the manual installation of NiosII Build Tools for Eclipse if you'd like but I would actually recommend installing it. It can still be useful, if only for creating a new project, BSP etc.
Install VSCODE along with the C/C++ Extension provided by Microsoft (and the Visual Studio Code Remote - SSH extension if you intend to use that feature)
Create a new project using Eclipse (or skip, if you already have a project)
Open VSCODE, select open and navigate to the software directory of your project.
VSCODE will open your project and you should see your application directory and BSP directory.
From here, you can work on your code with full linting, auto completion etc.
If you need to regenerate your BSP, you can either do that using Eclipse or just run the command-line tool instead.
Compiling
If you allowed Eclipse to create your project for you, it will have produced a makefile in your application directory. Compiling is as simple as running 'make' from the application directory. I like to keep a terminal window open within VSCODE so I can run various tools as I work so this is usually how I can compile code. If, instead, you'd like to integrate this into VSCODE, you can define a task (https://code.visualstudio.com/docs/editor/tasks).
Eclipse automatically adds new sources that you create to the makefile. VSCODE won't do this - however, I personally don't think this is a bad thing. I don't like IDEs messing with my makefiles, I want fully control over them myself. So when you create a new source file, just remember to add it to the makefile. There is probably a way to get VSCODE to add sources files automatically (you can run commands on save etc) - but I have no motivation to try to figure this out.
Debugging
It is also possible to debug Nios2 software live on the target via the USB-Blaster using VSCODE. To do this, open the launch.json file in the .vscode folder of your project. If this file does not exist, just create it. The path should be:
<project root dir>/.vscode/launch.json
Copy the following into the launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "app",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/app/app.elf",
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"MIMode": "gdb",
"miDebuggerServerAddress": "localhost:2334",
"miDebuggerPath": "/PATH/TO/intelFPGA/20.1/nios2eds/bin/gnu/H-x86_64-pc-linux-gnu/bin/nios2-elf-gdb",
"debugServerPath": "/PATH/TO/intelFPGA/20.1/quartus/bin/nios2-gdb-server",
"debugServerArgs": "--tcpport 2334 --reset-target --tcppersist",
}
]
}
This file is a list of debug targets and settings. You can add any number of configurations here, but easiest to just start with one for now. The configuration above is called 'app', you can change this to suit your own project if you wish.
Update the "program" entry with the path to your applications elf
file
Update the "miDebuggerPath" path with the path the nios2-elf-gdb on
your system. This is the gdb client for Nios2
Update the "debugServerPath" path with the path the nios2-gdb-server.
This is the gdb server for Nios2
Save the file and now click on the "run and debug" button on the left
side control panel in VSCODE
You'll see play button at the top of the screen next to the configuration you just defined in launch.json. Hit the play button - this will start an instance of the gdb server, followed by the gdb client and connect the two. If all goes well, your target will run and stop in main.
VSCODE will provide you with a set of debug tools for stepping, watching variables, call stack - all that good stuff. On the right hand side, you can view the debug console which will allow you to enter commands directly into the gdb console. Note, you have to prepend your commands with -exec. E.g. to print the value of a variable x, you would type:
-exec print x
Caveat
There is a problem with this debugging method: nios2-gdb-server doesn't always exit cleanly and as a result the port doesn't close. If you try to start another debug session, the server won't start because the port is in use. Eclipse solves this problem by randomizing the port everytime it launches the gdb. I have not found a way to do that VSCODE yet.
I find easiest way around this is to run the gdb server manually when I need it. Comment out the two 'debugServer' lines above. Open a second terminal in VSCODE and run:
nios2-gdb-server --tcpport 2334 --reset-target --tcppersist
This will keep the server running even when you stop debugging. If you start another debug session, it will reconnect to the same server instance.
Update: rioV8 provided a helpful solution to this problem which involves using a vscode extension to generate a random environment variable which can used be used in place of the port numbers. The solution is here.
I am working through the instructions on building VSC for developers (https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run) currently. Right under "Build" it instructs me to go "Go into vscode and start the build task with CMD+Shift+B) since I have a mac. I have gone into the folder in my finder and have pressed this combination of buttons but nothing happens at all. Am I supposed to do this in the terminal or am I missing anything?
It looks like the vscode directory must be opened in Visual Studio Code and a build is performed with ⌘ Command+Shift+B.
Here is an older version of the instructions where it is clearer:
https://github.com/microsoft/vscode-wiki/blob/2e2d6b0/How-to-Contribute.md#build
It appears that the directory vscode got mixed up with the full application name in a subsequent edit.
Every time I build or run a program in VSCode a new python debug console is loaded. Before I know it I have 20+ and need to start deleting them. After 32 open consoles I get the error "The terminal process terminated with exit code: 256". I changed the terminal from the default console to git bash recently. How can I stop this?
A way around this issue is to stop VS Code from redundantly printing to the TERMINAL during debugging in the first place. Since it prints to the DEBUG CONSOLE as well, you can use that instead.
Change console to "none" "internalConsole" in each configuration in your project's launch.json file:
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "internalConsole"
}
]
May 2019 Update: the "none" option was replaced by "internalConsole" so I edited my answer to reflect that. Here's the relevant GitHub Issue.
Adding "args": ["&&", "exit"], to launch.json remedies this for Git Bash. Certainly a hack, but I no longer have to manually close many debug terminals.
This may have been resolved in recent debug updates to core VS Code within the last year (as of 8/2022), but I was still seeing this intermittently.
I don't know if this will help the original poster, but I discovered that for me the issue persisted due to using Git Bash as the default terminal in Windows. Switching to Command Prompt as the default terminal fixed the issue. I haven't tested with other platforms or terminals.
Changing the default terminal to Command Prompt causes the Python extension to launch the "Python Debug" terminal with Command Prompt instead of Git Bash. I did log a VS Code/Python Extension defect about this. The initial response is that Git Bash is not officially supported currently.
There appears to be a communication problem between the Git Bash terminals and VS Code that causes this issue. Some of the characters between Git Bash and VS Code get dropped. Sometimes this mangles the debug command and I get and error and have to retry in addition to getting an extra debug window.
There is some additional background info and hacks to fix this from the past in this answer.
Hopefully fixed in the Insiders Build and should be in v1.54. See Debug opens a new integrated terminal for each Python session
. Test it in the Insiders Build if you can and report at the issue if it fixed/did not fix.
Actually you can delete all the instances of the terminal just by clicking on the trash can icon 🗑. If it does not work for the first time, restart the VS Code and try again.
What are the best ways to troubleshoot and debug Visual Studio Code?
I have encountered conflicts in some snippet/suggestion extensions while editing in Visual Studio Code and want to try to find the root cause.
P.S. I would appreciate any experience in resolving conflicts between extensions. Feel free to chime in if you have encountered this issue before (built-in suggestions completely overwriting extension suggestions after a couple of seconds)
Taken from https://code.visualstudio.com/docs/extensions/developing-extensions:
Running and debugging your extension
You can easily run your extension under the debugger by pressing F5.
This opens a new VS Code window with your extension loaded. Output
from your extension shows up in the Debug Console. You can set break
points, step through your code, and inspect variables either in the
Debug view or the Debug Console.
To debug installed Visual Studio Code extensions, first navigate to the installed extension's project folder.
%USERPROFILE%\.vscode\extension\${PublisherName}.${ExtensionName}-${VersionNumber}\
This folder is contained in your user profile or root folder. It may also be called .vscode-insiders depending on the version of Visual Studio Code you have installed.
This project folder should already have the debugger set up and you can just press F5 in a project source file to open the [Extension Development Host] as originally assumed.
For more information you can check the <projectroot>/.vscode/launch.json to find the launch configurations detailing the use of the [Extension Development Host] if you need to fine-tune these settings.
Example taken from auto-generated extension debugger settings launch.json:
// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.1.0",
"configurations": [{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"]
}]
}
From there it's just a simple(~) matter of adding breakpoints and/or console logs to work out the cause of extension-related issues.
~ Edit: I have enough rep to embed images now 😘
For more information on general development of Visual Studio Code extensions see the official docs here:
https://code.visualstudio.com/docs/extensions/developing-extensions#_creating-your-own-extension
To view the errors for someone else's extension you installed normally:
In the menu, select View > Output
Select the extension in a small dropdown at the top right of the output window
I am unable to find a setting to enable modified/changed/new lines highlight in editor. Like on this screenshot from the video about angular2 by google.
How to enable modified line hilight?
This is connected with your file being under revision control. If you have your files in git and open the folder in VS Code. You will see the colors depending on the change you've made.
Check section about Gutter indicators.
I had the same problem try launching vscode in terminal like: code your-project-dictionary.
If code command cannot be found, enable code in shell:
Open VSCode press CMD+Shift+P. A dialog will be shown: Type in "shell" and click on Shell Command: Install 'code' command in PATH. Now you can launch VSCode in terminal. This solved my issue with highlighting changed files on VSC Project Structure!
I had the same issue and turns out that for me it was a bug in git client. Reinstalling git resolved the problem with changes highlighting. Ensure that you are using latest git client. Then reopen VSCode, reopen project/folder.
It seems you should open with folder, rather than open just files.
open just files:
img example
open with folder:
img example
anyway, in terminal, use code xxxx(folder name) to open project, or right click the floder and choose open with vscode in context
Tip: must open the real directory, but not a link dir
if you add fold to a workspace, also must add a real direcotory
{
"folders": [
{
"path": "."
},
{
"path": "../src/xxx/"
},
{ # ../golang/src/test must be a real dir
"path": "../golang/src/test"
}
],