<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">The attached patch addresses a problem we recently came across trying to use LLDB to debug a program that was built with GCC 4.7.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The current code that parses variables for a specific DWARF context is letting the handler for the DW_AT_const_value attribute fall through to the DW_AT_location handler and setting the “value” as the “location” in the Variable it creates,
with a flag indicating that it’s a value and not a location.<o:p></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal">There are two problems with this. First, the DW_AT_const_value can be a block of data, a single value or a string while the DW_AT_location can be either a block of data or a location list. The current code only works if DW_AT_const_value
is a block of data. If it is either a single value or a string, the current code tries to handle it as a location list. The second problem is that the current code assumes that no variable will have both a DW_AT_const_value attribute and a DW_AT_location
attribute. It turns out that isn’t true for code built with GCC 4.7 (at least).<o:p></o:p></p>
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal">The attached patch addresses these two problems by (1) creating an explicit handler for DW_AT_const_value which duplicates the block handling and adds new handling for the two missing cases, and (2) checks for the presence of DW_AT_location
and effectively ignores DW_AT_const_value if the DW_AT_location is also present. If DW_AT_location is found after DW_AT_const_value, it will overwrite the ‘location’ that was stored for the constant value. I believe this is OK because the actual location
should also contain the constant value.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’m still working on finding a way to test all of the new cases, but I wanted to send this patch off for review ASAP in case I’m taking the wrong approach. The solution in my patch doesn’t feel terribly elegant, but any alternatives I
could think of seemed to involve significant changes in the way constant values were being handled.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks in advance for any feedback.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">-Andy<o:p></o:p></p>
</div>
</body>
</html>