Bug 448092 - Ada : Dwarf expression exception : Need to support AT_data_location ?
Summary: Ada : Dwarf expression exception : Need to support AT_data_location ?
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 critical (vote)
Target Milestone: 1.3   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-21 10:39 EDT by xavier pouyollon CLA
Modified: 2015-06-16 03:18 EDT (History)
0 users

See Also:


Attachments
Test vxWorks DKM. (79.01 KB, application/x-zip)
2014-10-21 10:39 EDT, xavier pouyollon CLA
no flags Details
Linux version (134.49 KB, application/x-download)
2014-10-24 09:52 EDT, xavier pouyollon CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description xavier pouyollon CLA 2014-10-21 10:39:43 EDT
Created attachment 248050 [details]
Test vxWorks DKM.

Hi Eugene,

With the attached Ada VxWorks module, there is an exception in evaluate_expression.

case OP_push_object_address:
            if (state->args_cnt == 0) str_exception(ERR_INV_ADDRESS, "Invalid address of containing object");

I'm stopped at relative pc 0x6e0 in p.adb on line:
   DN (E, FP, TP);

It tries to evaluate die <876> for attribute AT_upper_bound: 
My hypothesis is that we need support for 
    <86b>   DW_AT_data_location: 2 byte block: 97 6  
in order that state->args_cnt is being set. 

 <1><866>: Abbrev Number: 3 (DW_TAG_array_type)
    <867>   DW_AT_name        : (indirect string, offset: 0xe09): pack__s
    <86b>   DW_AT_data_location: 2 byte block: 97 6     (DW_OP_push_object_address; DW_OP_deref)
    <86e>   DW_AT_type        : <0x85f>
    <872>   DW_AT_sibling     : <0x88a>
 <2><876>: Abbrev Number: 4 (DW_TAG_subrange_type)
    <877>   DW_AT_type        : <0x858>
    <87b>   DW_AT_lower_bound : 5 byte block: 97 23 4 6 6       (DW_OP_push_object_address; DW_OP_plus_uconst: 4; DW_OP_deref; DW_OP_deref)
    <881>   DW_AT_upper_bound : 7 byte block: 97 23 4 6 23 4 6  (DW_OP_push_object_address; DW_OP_plus_uconst: 4; DW_OP_deref; DW_OP_plus_uconst: 4; DW_OP_deref)
 
Caller (get_object_size) comes from this die:
 <2><936>: Abbrev Number: 13 (DW_TAG_variable)
    <937>   DW_AT_name        : fp
    <93a>   DW_AT_decl_file   : 1
    <93b>   DW_AT_decl_line   : 6
    <93c>   DW_AT_type        : <0x8c4>
    <940>   DW_AT_location    : 2 byte block: 91 5c     (DW_OP_fbreg: -36)

Best Regards,
Xavier.
Comment 1 xavier pouyollon CLA 2014-10-24 09:03:59 EDT
Hi Eugene,

I'm fighting to add AT_data_location. We're going to need that for ADA support.

I'm having troubles to see where I must update the code. So far, I've been in 
read_and_evaluate_dwarf_object_property to add AT_data_location to get dwarf_evaluate_expression called.

I've updated dwarf_evaluate_expression so State->args_cnt = 1.

Since we fail in get_object_size when calling get_array_index_length (it will trigger the exception when evaluating die <876> I've added:

             ObjectInfo * idx = get_dwarf_children(obj);
           read_and_evaluate_dwarf_object_property(sym_ctx, sym_frame, obj, AT_data_location, &p);

before calling get_array_index_length.

I go slightly further but unfortunately dwarf_expression_obj_addr is 0. My understanding is that it should be updated by these 2 rules:
<940>   DW_AT_location    : 2 byte block: 91 5c     (DW_OP_fbreg: -36)
and then by
<86b>   DW_AT_data_location: 2 byte block: 97 6     (DW_OP_push_object_address; DW_OP_deref)

I'm having troubles understanding the big picture here and what to do. Any help, suggestion, even fix is more than welcome ! 

So far, I can not supply you a Linux version of this ADA test program, which would help to reproduce the issue.

Many thanks,
Xavier.
Comment 2 xavier pouyollon CLA 2014-10-24 09:52:10 EDT
Created attachment 248157 [details]
Linux version

To reproduce on Linux.
Comment 3 xavier pouyollon CLA 2014-10-24 09:55:30 EDT
Hi Eugene,

To reproduce, unzip the Linux version.
Start the agent with p.out
Put a breakpoint at p
Run. Break hit. Continue. Break hit.
Once stopped in p.adb, line 3 step-over to line 10
   DN (E, FP, TP);
Open expression view and add new expression fp

For fp, I have the following error:

At col 2: Cannot retrieve symbol size. Invalid address of containing object. Invalid address

Best Regards,
Xavier.
Comment 4 xavier pouyollon CLA 2014-11-06 06:10:12 EST
Hi Eugene,

Any update on it ? I'm trying to implement AT_data_location support but so far I still need to clarify my mind to get a better understanding of how dwarf expression support works.

Any advices welcome.

Best Regards,
Xavier.
Comment 5 xavier pouyollon CLA 2014-11-10 09:12:31 EST
Hi Eugene,

Thanks to your fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=450361, we can now display fp but the content is unfortunately wrong because TCF doesn't support yet AT_data_location.

Best Regards,
Xavier.
Comment 6 xavier pouyollon CLA 2014-11-12 13:02:24 EST
Hi Eugene,

I'm using the Linux version (for reference about the die number).

I'm trying to get a correct display of fp fields and I'm really struggling.

I've added a field in ObjectInfo:
ObjectInfo * data_loc;

I see get_location_info being called for <8e5>, the tag variable fp. I want to add the processing of the AT_data_location from <82c> to change the address of the currently evaluated object.

So far, I have hacked so when object2symbol sees object <82c>, it will setup the <8e5>'s data_loc to <82c>'s object. (I could not find a better place.... Seems called when size is retrieved for fp array)

I've tried in get_location_info:

        if ((obj) && (obj->data_loc != NULL)) {
            printf ("DO THE AT_data_location INDIRECTION\n");
            /* Get original address */
            read_dwarf_object_property(sym_ctx, sym_frame, obj, AT_location, &v);
            add_dwarf_location_command(info, &v);

            /* And also process the indirection from AT_data_location */

            read_dwarf_object_property(sym_ctx, sym_frame, obj->data_loc, AT_data_location, &v);
            add_dwarf_location_command(info, &v);
            return 0;
        }

This doesn't change anything. 
Any help really appreciated.

Best Regards,
Xavier.
Comment 7 Eugene Tarassov CLA 2014-11-12 15:16:19 EST
Changing get_location_info() to follow AT_data_location indirection is not a good idea, because it will break other usages of the function, like computation of variable attributes of a symbol. The best place to perform hidden indirection is expression evaluation. I have committed necessary changes.
Fixed.
Thanks!
Comment 8 xavier pouyollon CLA 2014-11-13 05:08:27 EST
Hi Eugene,

Many thanks for the fix. 
I understand now what I've missed and I have a better view of the big picture.
(but still with some fuzzy points)

Thanks !
Xavier.