How do I debug a C program in Mint?
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
How do I debug a C program in Mint?
I'm a Java programmer by training, trying to teach myself C. I currently use medit and compile programs manually. What are my options for debugging a C program and inspecting the state of variables at various times?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: How do I debug a C program in Mint?
Code: Select all
$ cc -g program.c
$ gdb a.out
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Your data and OS are backed up....right?
Re: How do I debug a C program in Mint?
Indeed, gdb is the debugger you'll likely want to use. IDEs like GNOME Builder (for writing Gtk programs, like for Cinnamon, MATE and Xfce) or Qt Creator (for writing Qt programs, like for KDE) come with builtin gdb integration. You may find modules to add gdb integration available for other IDEs, like for Eclipse.
You can also run gdb standalone from the terminal as noted above. Going through its documentation https://www.gnu.org/software/gdb/documentation/ or getting a good book on it will undoubtedly help you make the most of it.
A friendly option is to use gdbgui, which you start from the terminal just like gdb, but it opens a page in your web browser where you get a GUI to interact with gdb. More info here https://github.com/cs01/gdbgui/
If you're writing very big and complex programs, Valgrind may also be useful tool. You can use it for profiling your programs and finding performance bottlenecks and track down memory management and threading bugs. You could also just switch from programming in C to programming in Rust of course, which is memory and thread safe by design.
You can also run gdb standalone from the terminal as noted above. Going through its documentation https://www.gnu.org/software/gdb/documentation/ or getting a good book on it will undoubtedly help you make the most of it.
A friendly option is to use gdbgui, which you start from the terminal just like gdb, but it opens a page in your web browser where you get a GUI to interact with gdb. More info here https://github.com/cs01/gdbgui/
If you're writing very big and complex programs, Valgrind may also be useful tool. You can use it for profiling your programs and finding performance bottlenecks and track down memory management and threading bugs. You could also just switch from programming in C to programming in Rust of course, which is memory and thread safe by design.