Re: concrete hints on debugging C++ code (compiled with GCC) using GDB (Linux) ?

skidmarks <[email protected]> Sat, 24 Jan 2026 14:57:48 -0800
Newsgroups gmane.comp.gcc.help
Message-ID <[email protected]>
I suspect this wont help much, but what I compile with is:

    g++ -c -g -O0 -std=c++20 -o <object file folder>/<flile>.o <file>.cpp

This basically works. There are a few things that seem strange under 
gdb, most do to my vast(?) knowledge, but some of questionable merit 
using gdb, but in the whole, this works.

art

On 1/24/2026 12:34 PM, Basile Starynkevitch wrote:
> Hello all,
>
>
> In relation tohttps://github.com/RefPerSys/RefPerSys/issues/30
>
> what are concrete hints to debug such kind of bugs?
>
> How should I configure then compile GCC 16 (e.g. gcc-16-20260118 recent snapshot, symlinked as gcc-16snap)
>
> I did configure it as (in an external build tree, '/usr/src/Lang/_BuildGcc16') with
>
>   /usr/src/Lang/gcc-16snap/configure   '-v' '--prefix=/usr/local' '--with-gcc-major-version-only' '--program-suffix=-16' '--enable-shared' '--enable-plugin' '--enable-default-pie' '--with-system-zlib' '--disable-multilib' '--with-tune=native' '--enable-checking=release' '--enable-host-shared' '--build=x86_64-linux-gnu' '--host=x86_64-linux-gnu' '--target=x86_64-linux-gnu' 'CFLAGS=-g -O2' 'CXXFLAGS=-g -O2' '--enable-werror' 'build_alias=x86_64-linux-gnu'
> 'host_alias=x86_64-linux-gnu' 'target_alias=x86_64-linux-gnu' '--enable-languages=c,c++,jit,lto' :  '/usr/src/Lang/gcc-16snap/configure'   '-v' '--prefix=/usr/local' '--with-gcc-major-version-only' '--program-suffix=-16' '--enable-shared' '--enable-plugin' '--enable-default-pie' '--with-system-zlib' '--disable-multilib' '--with-tune=native' '--enable-checking=release' '--enable-host-shared' '--build=x86_64-linux-gnu' '--host=x86_64-linux-gnu' '--target=x86_64-
> linux-gnu' 'CFLAGS=-g -O2' 'CXXFLAGS=-g -O2' '--enable-werror' 'build_alias=x86_64-linux-gnu' 'host_alias=x86_64-linux-gnu' 'target_alias=x86_64-linux-gnu' '--enable-languages=c,c++,jit,lto'
>
> How should I configure GDB 17.1 (perhaps also compile it)?
>
> In particular, I want GDB to be able to print/display nicely instances of std::string
> (and maybe even instances of templates like std::map<std::string,int>....)
>
> Your advice is very appreciated!
>
> Regards