This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++/2473: Program under debugg receives SIGSEGV when passingobj by value


The following reply was made to PR c++/2473; it has been noted by GNATS.

From: Aleksandar Ristovski <aristovski@qnx.com>
To: gdb-gnats@sources.redhat.com
Cc:  
Subject: Re: c++/2473: Program under debugg receives SIGSEGV when passing
 obj by value
Date: Tue, 08 Jul 2008 09:59:55 -0400

 drazen@gmail.com wrote:
 > Hi,
 > I bring the following code into the debugger:
 >  0  //-------------------------------------------------
 >  1  class F {
 >  2  public:
 >  3     int m_F;
 >  4     //-------
 >  5     F(int x)  : m_F(x) // constructor
 >  6     { }
 >  7     F(const F& f) :  m_F(f.m_F) // copy constructor
 >  8     { }
 >  9  };
 > 10  //NOTE: object is passed, not reference
 > 11  int  getMember(F f)     // 
 > 12  {
 > 13     return f.m_F;
 > 14  }
 > 15
 > 16  int main()
 > 17  {
 > 18    F f1(3);
 > 19    int i = getMember(f1);
 > 20    return 0;
 > 21  }
 > 22
 > 23  //----------------------------------------------
 > 
 > 
 
 It looks like it's compiler version related. When compiled with 4.1.2, it seems to work fine (tried gdb 6.7.1 and HEAD):
 
 gcc -v
 Using built-in specs.
 Target: i686-pc-linux-gnu
 Configured with: /var/tmp/portage/sys-devel/gcc-4.1.2/work/gcc-4.1.2/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.1.2 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.2 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.2/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.2/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec  --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-libunwind-exceptions --disable-multilib --enable-libmudflap --disable-libssp --disable-libgcj --with-arch=i686 --enable-languages=c,c++,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
 Thread model: posix
 gcc version 4.1.2 (Gentoo 4.1.2 p1.0.2)
 
 
 (gdb) show version
 GNU gdb 6.7.1
 Copyright (C) 2007 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
 and "show warranty" for details.
 This GDB was configured as "i686-pc-linux-gnu".
 (gdb) b main
 During symbol reading, Location list used without specifying the CU base address..
 Breakpoint 1 at 0x804843b: file /tmp/gdb2473/main.cpp, line 18.
 (gdb) r
 Starting program: /tmp/gdb2473/main
 
 Breakpoint 1, main () at /tmp/gdb2473/main.cpp:18
 18        F f1(3);
 (gdb) n
 During symbol reading, incomplete CFI data; unspecified registers (e.g., eax) at 0x8048438.
 19        int i = getMember(f1);
 (gdb) print getMember(f1)
 $1 = 3
 (gdb)
 
 
 
 HEAD:
 (gdb) show version
 GNU gdb (GDB) 6.8.50.20080708-cvs
 Copyright (C) 2008 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
 and "show warranty" for details.
 This GDB was configured as "i686-pc-linux-gnu".
 For bug reporting instructions, please see:
 <http://www.gnu.org/software/gdb/bugs/>.
 (gdb) b main
 During symbol reading, Location list used without specifying the CU base address..
 Breakpoint 1 at 0x804843b: file /tmp/gdb2473/main.cpp, line 18.
 (gdb) r
 Starting program: /tmp/gdb2473/main
 
 Breakpoint 1, main () at /tmp/gdb2473/main.cpp:18
 18        F f1(3);
 (gdb) n
 During symbol reading, incomplete CFI data; unspecified registers (e.g., eax) at 0x8048438.
 19        int i = getMember(f1);
 (gdb) print getMember(f1)
 $1 = 3
 
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]