Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++: Do I need GCC and GDB with the same version to debug

I am developing in C++ on Windows with minGW. I have debugging problems at the moment.

I must use an old version of GCC (4.4). So I was just wondering if it is possible to compile with this old GCC and debug with a new GDB?

What is the link between the two of them?

(Any pointers regarding debugger crashes would be greatly appreciated too! I just know that I need to be sure to use debug DLLs)

like image 835
Plouff Avatar asked Apr 22 '15 15:04

Plouff


People also ask

Is GDB and gcc same?

gcc is a debugger by GNU project. Gdb can step through your source code line-by-line or even instruction by instruction. You may also watch the value of any variable at run-time. In additon, it also helps to identify the place and the reason making the program crash.

Which gcc compiler option should you use in order to include symbols for debugging?

Most programs and libraries are, by default, compiled with debugging symbols included (with gcc option -g).

Is GDB a good debugger?

GDB stands for GNU Project Debugger and is a powerful debugging tool for C(along with other languages like C++). It helps you to poke around inside your C programs while they are executing and also allows you to see what exactly happens when your program crashes.


1 Answers

GDB and GCC are separate programs -- separate source bases (with a bit of shared code, though not much), generally separate maintainers, different release schedules, and different version numbers. They do share a bit of culture and of course there is some coordination.

GDB is reasonably good about backward compatibility. It even keeps workarounds for bugs in debuginfo emitted by older versions of GCC and sometimes other compilers. What this means is that you can usually upgrade GDB while keeping the same GCC version.

The reverse, though, is not always the case. Sometimes a new version of GCC emits debug info that an older GDB cannot understand. In this situation you must upgrade GDB as well. In some limited situations you can pass a compatibility flag to GCC to ask for downgraded debug info, but this isn't always possible. And, since it is simple to upgrade GDB, you might as well.

like image 73
Tom Tromey Avatar answered Oct 05 '22 23:10

Tom Tromey