Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use and meaning of DW_AT_location

Tags:

dwarf

llvm-3.0

I wanted to know the use of the attribute DW_AT_location for debugging. It is one of the attributes specified by dwarf for debugging, but could not really understand what exactly it represents. And also when should this attribute be emitted when we compile a code.

like image 796
Maximus Avatar asked Oct 16 '25 17:10

Maximus


1 Answers

From the DWARF 3 spec (http://dwarfstd.org/doc/Dwarf3.pdf):

2.16 Data Locations Any debugging information entry describing a data object, which includes variables, parameters, common blocks and the like, may have a DW_AT_location attribute, whose value is a location description (see Section 2.6).

The value of the DW_AT_location attribute is a location expression. Location expressions are fairly complex, I'd advise you to read the DWARF spec referenced above to learn more. In summary, a location expression can be a simple address with the location of the variable, or a mini-program that must be evaluated at run-time by the debugger to determine the location of the variable. Here are some example location expressions, from the DWARF spec:

Ideally, your compiler should emit a location list for a variable describing its location at all points in the program. Tracking a variable's location through registers is not trivial, that is why some compilers when producing debug information disable optimizations like moving variables into registers.

like image 142
Bogatyr Avatar answered Oct 19 '25 12:10

Bogatyr