VS Code and Valgrind: Difference between pages

From Computer Science at Indiana State University
(Difference between pages)
Jump to navigation Jump to search
m 1 revision imported
 
wiki_previous>Jkinne
No edit summary
 
Line 1: Line 1:
This page contains some information on proper setup of VS Code to use on your home computer and have it connect to the CS server.
Note that <code>valgrind</code> is installed on cs.indstate.edu but not on all of the lab desktops, so make sure you are logged into cs in the terminal (e.g., <code>ssh username@cs.indstate.edu</code>).


=Download/install=
First, you should make sure to compile your program with debugging information enabled. See [[GNU Debugger]].  You can run the <code>valgrind</code> memory checker by running:
* Download and install from here - https://code.visualstudio.com/download
** On Linux, you might install using the package manager for your system (it varies by distribution).
** On Mac, the downloaded file is not an installer. You should drag the downloaded file into your Application folder and run it from there.
 
=Extensions=
To install extensions you click on one of the icons on the left hand side of the Visual Studio Code window.
 
'''Recommended extensions'''
* Remote SSH (by Microsoft) - allows you to connect to the CS server and run a terminal from within VS Code. Installing this will also install the following normally, which are also recommended.
** Remote SSH: Editing Configuration (by Microsoft)
** Remote Explorer (by Microsoft)
* Python (by Microsoft) - allows you to run and debug Python code within VS Code'''But note''' - you should not install this extension while connected to the CS server as this eats up a fair amount of space on the CS server.
 
'''Be careful'''
* When you install extensions and are doing development remotely on the CS server, some try to install large installation files on the CS server. The above do not. You can check what has been installed and how much space they are taking up with the following commands from a terminal:
<pre>
<pre>
cd ~/.vscode-server
valgrind program_file.o
ls -lh extensions
du -d 1 -h extensions
du -d 1 -h .
</pre>
</pre>
 
To see more detailed information about potential memory leaks, you can use the <code>--leak-check=full</code> option:
=Connecting to CS Server=
Click on the Remote Explorer icon on the left, click + to add a new connection, and put in your username@cs.indstate.edu. ''You may need to quit VS Code and start it again'', but you should see the connection listed. You can click the arrow icon to connect with the current window or click the window button to connect in a new window.
 
At this point when you Open, Save, etc. files, they will be on the CS server.
 
You can also start a terminal within VS Code by clicking Terminal in the menu at the top and then "New Terminal".
 
You can have a source code file open and then run the file from within the terminal.
 
If you want to '''close the remote connection''' you can click on the connection icon in the lower left of the window and choose to close the remote connection. Then you would be looking at files on your personal computer again.
 
If you have multiple accounts on the CS server, you can create multiple Remote Explorer entries. If you click the gear by SSH in the Remote Explorer pane, you can click to edit the configuration file to change how these are displayed. For example, this configuration file lists two accounts for Jeff Kinne.
<pre>
<pre>
Host jkinne@cs.indstate.edu
valgrind --leak-check=full program_file.o
  HostName cs.indstate.edu
</pre>
  User jkinne


Host cs51000@cs.indstate.edu
More information about valgrind: https://valgrind.org/docs/manual/quick-start.html
  HostName cs.indstate.edu
  User cs51000
</pre>

Revision as of 13:14, 15 November 2022

Note that valgrind is installed on cs.indstate.edu but not on all of the lab desktops, so make sure you are logged into cs in the terminal (e.g., ssh username@cs.indstate.edu).

First, you should make sure to compile your program with debugging information enabled. See GNU Debugger. You can run the valgrind memory checker by running:

valgrind program_file.o

To see more detailed information about potential memory leaks, you can use the --leak-check=full option:

valgrind --leak-check=full program_file.o

More information about valgrind: https://valgrind.org/docs/manual/quick-start.html