You are not logged in.

#1 2015-07-09 05:03:32

FelledTreeNo9
Member
Registered: 2015-05-05
Posts: 23

Compiling with GCC 5.1

Apologies if this turns out to be the wrong thread, this problem is a little beyond me.

On my desktop machine I've just done a pacman -Syu and it's running gcc 5.1.0. I have this simple program:

int main(int argc, char ** argv)
{
    int * i = new int;
    delete i;

    return 0;
}

Compile it, open it with gdb, try to 'step' the first instruction and get a gdb error:

$ g++ -g main.cpp
$ gdb a.out
GNU gdb (GDB) 7.9.1
[... etc etc ...]
Reading symbols from a.out...done.
(gdb) break main
Breakpoint 1 at 0x400645: file main.cpp, line 4.
(gdb) r
Starting program: /mnt/ve/dan/docs/code/c/soundtoy/v8/gdb_bug2/a.out 

Breakpoint 1, main (argc=1, argv=0x7fffffffe728) at main.cpp:4
4	    int * i = new int;
(gdb) s
operator new (sz=4)
    at /build/gcc-multilib/src/gcc-5-20150623/libstdc++-v3/libsupc++/new_op.cc:43
43	/build/gcc-multilib/src/gcc-5-20150623/libstdc++-v3/libsupc++/new_op.cc: No such file or directory.
(gdb) 

(I don't really want to step inside operator new - this is just a cut down test program - in my real program I'm intending to step into an outer function call that takes the new pointer as an argument.)

I would normally expect the 'step' command to step over the operator new call in this situation without going inside it since that function should have no debug symbols.

Similar problem when trying to 'step' past the delete call, except the file it can't find is called del_op.cc.

Also tried this on a laptop which hasn't been updated for a few weeks and is running gcc 4.9.2, and it's OK.

Perhaps 'info sources' is interesting:

(gdb) info sources
Source files for which symbols have been read in:

/mnt/ve/dan/docs/code/c/soundtoy/v8/gdb_bug2/main.cpp, 
/build/gcc-multilib/src/gcc-5-20150623/libstdc++-v3/libsupc++/new_op.cc, 
/build/gcc-multilib/src/gcc-5-20150623/libstdc++-v3/libsupc++/new, 
/build/gcc-multilib/src/gcc-build/gcc/include/stddef.h, /usr/include/stdlib.h, 
/build/gcc-multilib/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/cstdlib, 
/build/gcc-multilib/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/exception_ptr.h, 
/build/gcc-multilib/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu/bits/c++config.h, 
/build/gcc-multilib/src/gcc-5-20150623/libstdc++-v3/libsupc++/exception, 
/usr/include/bits/stdlib-float.h, /usr/include/bits/stdlib-bsearch.h, 
/build/gcc-multilib/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/<built-in>

Source files for which symbols will be read in on demand:

[... tons more files under /build/gcc-multilib/src ...]

Whereas on the laptop this shows only my main.cpp and nothing else.

Has libstdc++ been accidentally compiled with debug symbols, or something?

Last edited by FelledTreeNo9 (2015-07-09 05:06:04)

Offline

#2 2015-07-09 15:08:18

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,846
Website

Re: Compiling with GCC 5.1

Mod note: split from https://bbs.archlinux.org/viewtopic.php?id=194029 so as not to derail the original thread.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Online

Board footer

Powered by FluxBB