[llvm-bugs] [Bug 26619] New: Global const static float debug info
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Feb 15 04:22:25 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26619
Bug ID: 26619
Summary: Global const static float debug info
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: ewan at codeplay.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
In the example below there isn't enough DWARF present to get the value of g_pi:
const static double g_pi = 3.14;
const static int g_ret_code = 0;
#define M_PI 3.14
int main()
{
const double local = M_PI / g_pi;
return g_ret_code;
}
This produces the following relevant IR with -O0 & -g3, where we can see that
the values for both g_pi and g_ret_code are present in the debug meta-data. So
far so good.
!9 = !DIGlobalVariable(name: "g_pi", scope: !0, file: !1, line: 1, type: !10,
isLocal: true, isDefinition: true, variable: double 3.140000e+00)
!10 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !11)
!11 = !DIBasicType(name: "double", size: 64, align: 64, encoding: DW_ATE_float)
!12 = !DIGlobalVariable(name: "g_ret_code", scope: !0, file: !1, line: 2, type:
!13, isLocal: true, isDefinition: true, variable: i32 0)
!13 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !7)
However looking at the DWARF we can see that although the variable g_ret_code
has its value hardcoded into the
DWARF via DW_AT_const_value, g_pi has no DW_AT_const_value entry. There also
isn't a DW_AT_location attribute for g_pi, so the debugger has no
way to locate the value.
DWARF snippet:
< 1><0x0000002a> DW_TAG_variable
DW_AT_name "g_pi"
DW_AT_type <0x00000035>
DW_AT_decl_file 0x00000001
/home/ewan/Desktop/Scratch/c/clang_test/main.c
DW_AT_decl_line 0x00000001
< 1><0x00000035> DW_TAG_const_type
DW_AT_type <0x0000003a>
< 1><0x0000003a> DW_TAG_base_type
DW_AT_name "double"
DW_AT_encoding DW_ATE_float
DW_AT_byte_size 0x00000008
< 1><0x00000041> DW_TAG_variable
DW_AT_name "g_ret_code"
DW_AT_type <0x0000004d>
DW_AT_decl_file 0x00000001
/home/ewan/Desktop/Scratch/c/clang_test/main.c
DW_AT_decl_line 0x00000002
DW_AT_const_value 0x00000000
< 1><0x0000004d> DW_TAG_const_type
DW_AT_type <0x00000052>
Although the problem variable in this example was a double I've also seen this
with float, so something to do with non-intergral types
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160215/4432b886/attachment.html>
More information about the llvm-bugs
mailing list