This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug debug/14444] no proper debugging information for local variable


------- Additional Comments From max-gccbug at openchat dot com  2004-05-05 13:44 -------
have the same problem with 3.2.2 for the following test program 
 
#include <stdarg.h> 
#include <stdio.h> 
#include <string> 
using namespace std; 
 
class Sprintf : public string 
{ 
public: 
  Sprintf(string const &s) : string(s) {} 
  Sprintf(const char *format, ...); 
}; 
 
 
Sprintf::Sprintf (const char *format, ...) 
{ 
  char mybuf[8192]; 
  int len = sizeof(mybuf)-1; 
  va_list v; 
  va_start(v, format); 
  vsnprintf(mybuf, len, format, v); 
  *this = string(mybuf); 
  va_end(v); 
} 
 
main() 
{ 
    printf("%s\n", Sprintf("This is line number %d", i).c_str()); 
} 
g++ -g -O0 test.cpp 
 
gdb a.out 
 
GNU gdb Red Hat Linux (5.3post-0.20021129.29rh) 
Copyright 2003 Free Software Foundation, Inc. 
GDB is free software, covered by the GNU General Public License, and you are 
welcome to change it and/or distribute copies of it under certain conditions. 
Type "show copying" to see the conditions. 
There is absolutely no warranty for GDB.  Type "show warranty" for details. 
This GDB was configured as "i386-redhat-linux"... 
(gdb) b main 
Breakpoint 1 at 0x8048a1d: file test.cpp, line 27. 
(gdb) run 
Starting program: /home/max/a.out 
 
Breakpoint 1, main () at test.cpp:27 
27          printf("%s\n", Sprintf("This is line number %d", 20).c_str()); 
(gdb) s 
Sprintf (this=0xbffff2e0, format=0x8048b8c "This is line number %d") 
    at test.cpp:15 
15      { 
(gdb) n 
17        int len = sizeof(mybuf)-1; 
(gdb) n 
19        va_start(v, format); 
(gdb) n 
20        vsnprintf(mybuf, len, format, v); 
(gdb) n 
21        *this = string(mybuf); 
(gdb) info locals 
No locals. 
(gdb)  
 
g++ -v 
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs 
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info --enable-shared --enable-threads=posix 
--disable-checking --with-system-zlib --enable-__cxa_atexit 
--host=i386-redhat-linux 
Thread model: posix 
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) 
 
Note the "int len" was added when trying to troubleshoot the problem, the bug 
exists even if there is no int len local variable. 
 
 
 
                                                                                

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14444


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