<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Global const static float debug info"
href="https://llvm.org/bugs/show_bug.cgi?id=26619">26619</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Global const static float debug info
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>ewan@codeplay.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>