[Lldb-commits] [Review request] DW_AT_const_value handling

Kaylor, Andrew andrew.kaylor at intel.com
Tue Feb 12 12:43:53 PST 2013


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.

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.
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).
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.

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.

Thanks in advance for any feedback.

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20130212/39f0a76f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dw_at_const_value.patch
Type: application/octet-stream
Size: 4328 bytes
Desc: dw_at_const_value.patch
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20130212/39f0a76f/attachment.obj>


More information about the lldb-commits mailing list