public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/43912] New: lambda debug info does not describe captured variables
@ 2010-04-27 19:57 tromey at gcc dot gnu dot org
2010-07-27 15:14 ` [Bug c++/43912] " jakub at gcc dot gnu dot org
2010-07-28 11:41 ` jakub at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: tromey at gcc dot gnu dot org @ 2010-04-27 19:57 UTC (permalink / raw)
To: gcc-bugs
It would be nice for gdb users if any variables captured by a lambda
were described in the debuginfo for the inner function.
See http://sourceware.org/bugzilla/show_bug.cgi?id=11547
--
Summary: lambda debug info does not describe captured variables
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tromey at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43912
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/43912] lambda debug info does not describe captured variables
2010-04-27 19:57 [Bug c++/43912] New: lambda debug info does not describe captured variables tromey at gcc dot gnu dot org
@ 2010-07-27 15:14 ` jakub at gcc dot gnu dot org
2010-07-28 11:41 ` jakub at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-27 15:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jakub at gcc dot gnu dot org 2010-07-27 15:14 -------
I've briefly looked at this. For !processing_template_decl, it shouldn't be
hard to walk LAMBDA_EXPR_CAPTURE_LIST e.g. in cp_parser_lambda_expression
and add copy_decl of the vars from the capture list with DECL_VALUE_EXPR
pointing to this->__fieldname or *this->__fieldname. Templates slightly
complicate that though, as if this was to be done say in build_lambda_object
guarded with !processing_template_decl, lambda_function probably doesn't have
body instantiated yet. And if cp_parser_lambda_expression does this
unconditionally, we'd need to handle tsubsting DECL_VALUE_EXPRs.
Or we could add them during genericization of the lambda function, but we'd
then need to be able to find the corresponding LAMBDA_EXPR from the
FUNCTION_DECL.
Another thing is whether it is right to call the __lambda* argument this. Even
when it is artificial, it is still visible to the user in the debugger.
Shouldn't it be made DECL_NAMELESS once the vars with DECL_VALUE_EXPR are
added?
Jason, what do you prefer here?
Testcase I was playing with:
extern "C" void abort ();
template<typename F>
F
foo (int *x, int *y, F f)
{
for (; x != y; ++x)
f (*x);
return f;
}
template<typename T>
void
bar (T *w)
{
T s = 0, t = 0, u = 0, v = 10;
foo (&w[0], &w[10], [&s, &t, u, v] (T &a) -> void
{
s += a;
t += s + 10 - v;
});
if (s != 45 || t != 165)
abort ();
}
int
main ()
{
int s = 0, t = 0, u = 10, v = 10;
int w[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
foo (&w[0], &w[10], [&s, &t, u, v] (int &a) -> void
{
s += a;
t += s + 10 - v;
});
if (s != 45 || t != 165)
abort ();
bar (w);
return 0;
}
--
jakub at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-07-27 15:14:11
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43912
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/43912] lambda debug info does not describe captured variables
2010-04-27 19:57 [Bug c++/43912] New: lambda debug info does not describe captured variables tromey at gcc dot gnu dot org
2010-07-27 15:14 ` [Bug c++/43912] " jakub at gcc dot gnu dot org
@ 2010-07-28 11:41 ` jakub at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-28 11:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from jakub at gcc dot gnu dot org 2010-07-28 11:41 -------
Created an attachment (id=21334)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21334&action=view)
gcc46-pr43912.patch
Untested proof of concept patch (which handles just non-templates though).
The captured vars can be printed fine in the debugger, though no testing of
more complicated captures (like arrays etc.) has been done.
Not sure how to handle the template case though, so not working on this
anymore.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43912
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-07-28 11:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-27 19:57 [Bug c++/43912] New: lambda debug info does not describe captured variables tromey at gcc dot gnu dot org
2010-07-27 15:14 ` [Bug c++/43912] " jakub at gcc dot gnu dot org
2010-07-28 11:41 ` jakub at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).