Bug 451944 - Typedef on pointer_type does not display pointed object, cast leads to crash.
Summary: Typedef on pointer_type does not display pointed object, cast leads to crash.
Status: NEW
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-17 11:36 EST by xavier pouyollon CLA
Modified: 2014-11-20 05:25 EST (History)
0 users

See Also:


Attachments
Linux executable. (314.74 KB, application/x-gzip)
2014-11-17 11:36 EST, 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-11-17 11:36:46 EST
Created attachment 248702 [details]
Linux executable.

Hi Eugene,

Using attached zip file, step to p.adb:10.
Open expression view and add tp

The expression view displays:
Name          Type                 Value
tp            pack__tp_access      0x8a0d010

The property show a size of 4.

I would have expected, since tp is pointer to an array, to be able to unfold tp and see the various array elements.

If I dump memory at 0x8a0d010, I see a correct content.

Looking at the dwarf-infos:

 <2><8d8>: Abbrev Number: 12 (DW_TAG_variable)
    <8d9>   DW_AT_name        : tp
    <8dc>   DW_AT_decl_file   : 1
    <8dd>   DW_AT_decl_line   : 5
    <8de>   DW_AT_type        : <0x850>
    <8e2>   DW_AT_location    : 2 byte block: 91 6c     (DW_OP_fbreg: -20)
 <1><850>: Abbrev Number: 5 (DW_TAG_typedef)
    <851>   DW_AT_name        : (indirect string, offset: 0xa52): pack__tp_access
    <855>   DW_AT_decl_file   : 2
    <856>   DW_AT_decl_line   : 8
    <857>   DW_AT_type        : <0x85b>
 <1><85b>: Abbrev Number: 6 (DW_TAG_pointer_type)
    <85c>   DW_AT_byte_size   : 4   ==> Size correctly retrieved.
    <85d>   DW_AT_name        : (indirect string, offset: 0xa52): pack__tp_access
    <861>   DW_AT_type        : <0x865>
 <1><865>: Abbrev Number: 7 (DW_TAG_array_type)
    <866>   DW_AT_name        : (indirect string, offset: 0xb7c): pack__s
    <86a>   DW_AT_type        : <0x825>
    <86e>   DW_AT_sibling     : <0x88c>
 <2><872>: Abbrev Number: 4 (DW_TAG_subrange_type)
    <873>   DW_AT_type        : <0x81e>

The dwarf looks OK to me, I can't figure out why the IDE doesn't allow to "unfold" tp. Rather than returning <850> as type, shouldn't <865> be returned ?

Moreover, I have an agent crash if I try to cast:
(pack__s *) 0x8a0d010

Server-Properties: {"Name":"TCF Agent","OSName":"Linux 3.2.0-70-generic","UserName":"xavier","AgentID":"1460db33-74db-46a4-80e3-24007a71e292","TransportName":"TCP","ServiceManagerID":"1460db33-74db-46a4-80e3-24007a71e292-0","Port":"1534"}
agent: tcf/services/symbols_elf.c:3924: elf_reader_get_array_symbol: Assertion `sym->ctx == context_get_group(sym->ctx, 6)' failed.
Aborted (core dumped)

Thanks !
Xavier.
Comment 1 Eugene Tarassov CLA 2014-11-19 14:23:08 EST
More than one issue here:

1. DWARF info appears invalid:

 <2><872>: Abbrev Number: 4 (DW_TAG_subrange_type)
    <873>   DW_AT_type        : <0x81e>
    <877>   DW_AT_lower_bound : 8 byte block: 97 23 f8 ff ff ff f 6     (DW_OP_push_object_address; DW_OP_plus_uconst: 4294967288; DW_OP_deref)
    <880>   DW_AT_upper_bound : 10 byte block: 97 23 f8 ff ff ff f 23 4 6       (DW_OP_push_object_address; DW_OP_plus_uconst: 4294967288; DW_OP_plus_uconst: 4; DW_OP_deref)


"DW_OP_plus_uconst: 4294967288" cannot be right.


2. I've committed a fix for assertion failure.

3. To support type cast to a pointer to variable array (e.g. "(pack__s *)0x8a0d010"), I need to change declaration of get_array_symbol() function. This is not a backward compatible change - if you use symbols multiplexer, it will break your build. Let me know if you are OK with that.
Comment 2 xavier pouyollon CLA 2014-11-20 05:25:25 EST
Hi Eugene,

Thanks !

> *)0x8a0d010"), I need to change declaration of get_array_symbol() function. This is not a backward compatible change - if you use symbols multiplexer, it will break your build. Let me know if you are OK with that.

OK : We'll fix the symbols multiplexer then. 

Thanks !
Xavier.