Bug 7932 - Emit debug information about non-type template parameters
Summary: Emit debug information about non-type template parameters
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: 30161
Blocks:
  Show dependency treegraph
 
Reported: 2002-09-16 10:56 UTC by Wolfgang Bangerth
Modified: 2009-08-31 22:49 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-12-11 23:03:15


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bangerth 2002-09-16 10:56:00 UTC
This is more like a feature request than a bug-report, so
is low priority. But it might be low-hanging fruit for
someone knowledgable about this kind of stuff:

It would be nice to have debug information about the values
of non-type template parameters, for example to evaluate
expressions including them (thus being able to just cut-and-
paste them from the program). I guess, these parameters
would then just appear as constant variables with a 
lifetime equal to the entire scope.

Example program and debug session:
----------------------
#include <cstdlib>

template <int dim> struct X {
    X(){ abort(); };
};

int main () {
  X<1> x;
};
-----------------

When executed, the program stops at the site of the abort.
In a debugger, then try this:
-----------------
(gdb) r
Starting program: /home/bangerth/tmp/gcc/a.out

Program received signal SIGABRT, Aborted.
0x40131ab1 in kill () from /lib/libc.so.6
(gdb) bt
#0  0x40131ab1 in kill () from /lib/libc.so.6
#1  0x401318a8 in raise () from /lib/libc.so.6
#2  0x40132edb in abort () from /lib/libc.so.6
#3  0x080485ab in X<1>::X() () at x.cc:4
#4  0x0804855b in main () at x.cc:8
#5  0x401209ed in __libc_start_main () from /lib/libc.so.6
(gdb) fr 3
#3  0x080485ab in X<1>::X() () at x.cc:4
4           X(){ abort(); };
(gdb) p dim
No symbol "dim" in current context.

Regards
  Wolfgang

Release:
unknown

Environment:
gcc 3.2
Comment 1 Andrew Pinski 2003-05-25 22:09:24 UTC
still exitst on the mainline (20030525).

tin:~/src/gnu/gcctest>gcc -g3 pr7932.cc 
tin:~/src/gnu/gcctest>gdb a.out
GNU gdb 2003-05-24-cvs
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 "i686-pc-linux-gnu"...
(gdb) run
Starting program: /home/gates/pinskia/src/gnu/gcctest/a.out 

Program received signal SIGABRT, Aborted.
0x420292d1 in kill () from /lib/i686/libc.so.6
(gdb) fr 3
#3  0x08048361 in X (this=0xbffec587) at pr7932.cc:5
5           X(){ abort(); };
(gdb) p dim
No symbol "dim" in current context.
Comment 2 Dodji Seketeli 2009-08-31 21:59:09 UTC
I think this bug should be fixed in trunk (4.5) by the patch for PR debug/30161.
Can we close this bug or should we wait for GDB ?
Comment 3 Wolfgang Bangerth 2009-08-31 22:05:52 UTC
(In reply to comment #2)
> I think this bug should be fixed in trunk (4.5) by the patch for PR
> debug/30161.
> Can we close this bug or should we wait for GDB ?

What does GDB currently say for the testcase shown in the initial report?

W.
Comment 4 Dodji Seketeli 2009-08-31 22:14:57 UTC
Subject: Re:  Emit debug information about non-type template
 parameters

Le 01/09/2009 00:05, bangerth at gmail dot com a écrit :

> What does GDB currently say for the testcase shown in the initial report?

I think GDB doesn't know about the new type debug information added by gcc
yet. So it won't say anything. But I haven't test GDB HEAD. My reasoning
was that maybe we could open a GDB bug to track this there now that we
generate debug info for this case ? Or is there a GDB bug opened for this
already ?
Comment 5 Wolfgang Bangerth 2009-08-31 22:49:05 UTC
(In reply to comment #4)
> > What does GDB currently say for the testcase shown in the initial report?
> 
> I think GDB doesn't know about the new type debug information added by gcc
> yet. So it won't say anything.

I just tried with GDB 6.6, and you are right: it doesn't know about "dim".


> But I haven't test GDB HEAD. My reasoning
> was that maybe we could open a GDB bug to track this there now that we
> generate debug info for this case ? Or is there a GDB bug opened for this
> already ?

I didn't open a GDB bug back then, and I don't have any experience with GDB
bugs in the first place. Would you mind opening a bug with their bugzilla
(or whatever they use)?

Either way, yes, we can close this PR now.

Thanks
 W.