Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging C programs in Visual Studio Code

I'm trying to debug a C program using Visual Studio Code in Ubuntu.

I set

"program": "${workspaceRoot}/sample"

in the launch.json where "sample" is the name of my program. Then I simply put a breakpoint in code and click the debug arrow. However, the debugger does not hit the breakpoint, a terminal simply flashes and closes. When I hover over my breakpoint it says:

Module containing this breakpoint has not yet loaded or the breakpoint adress could not be obtained.

Is there an additional setting that I must configure ?

like image 814
SpiderRico Avatar asked Apr 03 '17 15:04

SpiderRico


People also ask

How do I debug in Visual Studio Code?

Debug view. To bring up the Debug view, select the Debug icon in the Activity Bar on the side of VS Code. You can also use the keyboard shortcut ⇧⌘D (Windows, Linux Ctrl+Shift+D). The Debug view displays all information related to debugging and has a top bar with debugging commands and configuration settings.

How do I debug a Cygwin program in Visual Studio Code?

Windows debugging with GDB # You can debug Windows applications created using Cygwin or MinGW by using VS Code. To use Cygwin or MinGW debugging features, the debugger path must be set manually in the launch configuration (launch.json).

How to debug a memory dump in Visual Studio Code?

The C/C++ extension for VS Code also has the ability to debug memory dumps. To debug a memory dump, open your launch.json file and add the coreDumpPath (for GDB or LLDB) or dumpPath (for the Visual Studio Windows Debugger) property to the C++ Launch configuration, set its value to be a string containing the path to the memory dump.

How do I run a program in debug mode without debugging?

The Debug: Run (Start Without Debugging) action is triggered with Ctrl+F5 and uses the currently selected launch configuration. Many of the launch configuration attributes are supported in 'Run' mode. VS Code maintains a debug session while the program is running, and pressing the Stop button terminates the program.


1 Answers

The problem had nothing to do with VS code. I was simply missing the -g tag when compiling the program.

like image 129
SpiderRico Avatar answered Oct 07 '22 09:10

SpiderRico