I am working on a debugger that supports range of debugging information formats, including DWARF. Recently I've experienced strange thing: mingw64 doesn't emit information about line numbers for code inside lambdas.
Here what I compiled:
void CallLambda(void (*lambda)());
int main()
{
for (int i = 0; i < 10000; i++)
CallLambda([]()-> void // <-- line #27
{
CallLambda([]()-> void
{
new int;
new int;
});
});
return 0;
}
...
void CallLambda(void (*lambda)())
{
lambda(); // <-- line #138
}
My debugger hooks calls of operator new
and saves call stack for each; addresses only. Later entries are resolved using available debugging information.
Here the call stacks I got for those operator new
:
libstdc++-6.dll!Znwy + 0x17 bytes 000000006fd07287
main.exe!0000000000401571 (for another new int here the address main.exe!000000000040157b)
main.exe!0000000000401594
main.exe!_Z10CallLambdaPFvvE Line 138 + 0x10 bytes 00000000004019f8
main.exe!00000000004015cd
main.exe!00000000004015e6
main.exe!_Z10CallLambdaPFvvE Line 138 + 0x10 bytes 00000000004019f8
main.exe!main Line 25 + 0x2c bytes 000000000040162f
...
I dumped the DWARF debugging information to find any information for addresses 0x401571 and 0x40157b.
Found the only place that corresponds to both addresses:
< 4><0x00005b48> DW_TAG_structure_type
DW_AT_name <lambda()>
DW_AT_decl_file 0x00000001 I:/Projects/deleaker/branches/branch_2020_02_10_leak_in_lambda/deleaker2/TestProjects/MingwTest/main.cpp
DW_AT_decl_line 0x0000001b
...
< 5><0x00005b6e> DW_TAG_subprogram
...
DW_AT_low_pc 0x00401560
DW_AT_high_pc <offset-from-lowpc>39
Here the entire output.
So it seems that the information is not enough to locate line numbers for 0x401571 and 0x40157b: parent node DW_TAG_structure_type contains DW_AT_decl_line = 0x0000001b = 27.
I believe I missed something.
Here the mingw64 version:
g++.EXE (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
User contributions licensed under CC BY-SA 3.0