Hello Everyone,

Consider the following test case:
[..]
int main () {
        __int128 newVar = 8;
        newVar = ~newVar;
        return 0;
}
[..]
Compiled as: $gcc foo.c -g -O1
 produces DWARF for "newVar" as:
[..]
0x0000004f:     DW_TAG_variable
                  DW_AT_name    ("newVar")
                  DW_AT_decl_file       ("/home/foo.c")
                  DW_AT_decl_line       (2)
                  DW_AT_decl_column     (0x0b)
                  DW_AT_type    (0x00000070 "__int128")
                  DW_AT_location        (0x00000004:
                     [0x0000000000401149, 0x0000000000401149): 
DW_OP_implicit_value 0x10 0x08 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00
0x00 0x00 0x00
                     [0x0000000000401149, 0x000000000040114f): 
DW_OP_implicit_value 0x10 0xf7 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 
0xff 0xff 0xff
0xff 0xff 0xff)
[..]

I need to know, what's motivation here the for representing location with 
DW_OP_implicit_value form. Can't it be represented using DW_OP_consts ?? or 
some piece wise composition like this(works GDB is printing value correctly).
[..]
0x00000043:     DW_TAG_variable
                  DW_AT_location        (0x00000000:
                     [0x00000000002016a1, 0x00000000002016b4): DW_OP_constu 
0x75bcd15, DW_OP_stack_value, DW_OP_piece 0x8, DW_OP_lit0, DW_OP_stack_value, 
DW_OP_bit_piece 0x40 0x40, DW_OP_stack_value
                     [0x00000000002016b4, 0x00000000002016cb): DW_OP_constu 
0xeb79a2a, DW_OP_stack_value, DW_OP_piece 0x8, DW_OP_lit0, DW_OP_stack_value, 
DW_OP_bit_piece 0x40 0x40, DW_OP_stack_value)
                  DW_AT_name    ("newVar")
                  DW_AT_decl_file       ("/home/foo.c")
                  DW_AT_decl_line       (2)
                  DW_AT_type    (0x0000005a "__int128")
[..]

If possible can somebody clarify the overall motivation behind 
"DW_OP_implicit_value" design/usage in GCC ? It's confusing in a sense if we 
use "int newVar = 8"  in above program the GCC creates location expression 
using "DW_OP_stack_value":
DW_AT_location        (0x00000004:
                     [0x0000000000401149, 0x0000000000401149): DW_OP_lit8, 
DW_OP_stack_value
                     [0x0000000000401149, 0x000000000040114f): DW_OP_const1s 
-9, DW_OP_stack_value)

While digging in, I stumbled upon this snippet(comment) from dwarf2out.c:

/* Determine if DW_OP_stack_value or DW_OP_implicit_value
     is more compact.  For DW_OP_stack_value we need:
     litsize + 1 (DW_OP_stack_value)
     and for DW_OP_implicit_value:
     1 (DW_OP_implicit_value) + 1 (length) + size.  */

Can somebody engaged in this feature help/clarify, all the findings here.

Thanks in anticipation!
Sourabh.

Reply via email to