public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "gdb.bugs at mfriebe dot de" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/16016] New: ptype incorrectly shows "record" (pascal/struct) as class (if accessed via pointer) (7.6.1 regression)
Date: Tue, 08 Oct 2013 10:49:00 -0000	[thread overview]
Message-ID: <bug-16016-4717@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=16016

            Bug ID: 16016
           Summary: ptype incorrectly shows "record" (pascal/struct) as
                    class (if accessed via pointer) (7.6.1 regression)
           Product: gdb
           Version: 7.6
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: gdb.bugs at mfriebe dot de

GDB up to and including 7.5.1 are NOT affected
GDB 7.6.0 was not tested
GDB 7.6.1 (from mingw / tested on w32 vista) has the below issue

Consider the following program (compiled with free pascal / dwarf2)

program Test_Record_var_param;
type
  TFoo = record    a,b: Integer;   end;
  PFoo = ^TFoo;
var
  r1, r2: TFoo;  p1, p2: PFoo;
begin
  P1 := @r1;  P2 := @r1;
end.
-----

"p1" and "p2" are both pointers to the record declaration. Except for the name,
they point to the same dwarf information entry in .debug_info

Yet running 
gdb -i mi
-gdb-set language pascal


ptype p1^
&"ptype p1^\n"
~"type = TFOO = record \n"
~"    A : LONGINT;\n"
~"    B : LONGINT;\n"
~"end\n"
^done
(gdb) 

-data-evaluate-expression p1^
^done,value="{A = 0, B = 0}"
(gdb) 

ptype p2^
&"ptype p2^\n"
~"type = TFOO = class \n"
~"  public\n""
~"    A : LONGINT;\n"
~"    B : LONGINT;\n"
~"end\n"
^done
(gdb) 

-data-evaluate-expression p2^
^done,value="{A = 0, B = 0}"
(gdb) 


ptype p2^ claims p2 points to a class, which is incorrect. 
This only happens if "ptype p1^" wal run first.

Running 
ptype p2^
ptype p1^

and ptype p1^ will claim to be a class.


-data-evaluate-expression correctly returns a record in all cases (a rlass
would include the class name)


---
Extract from objdump

 <1><9d>: Abbrev Number: 2 (DW_TAG_variable)
    <9e>   DW_AT_name        : P1    
    <a1>   DW_AT_location    : 5 byte block: 3 10 e0 40 0     (DW_OP_addr:
40e010)
    <a7>   DW_AT_type        : <0xf6>    
 <1><ab>: Abbrev Number: 2 (DW_TAG_variable)
    <ac>   DW_AT_name        : P2    
    <af>   DW_AT_location    : 5 byte block: 3 20 e0 40 0     (DW_OP_addr:
40e020)
    <b5>   DW_AT_type        : <0xf6>    

Both DW_AT_type point to the same entry

 <1><cb>: Abbrev Number: 4 (DW_TAG_typedef)
    <cc>   DW_AT_name        : TFOO    
    <d1>   DW_AT_type        : <0xd5>    
 <1><d5>: Abbrev Number: 5 (DW_TAG_structure_type)
    <d6>   DW_AT_name        : TFOO    
    <db>   DW_AT_byte_size   : 8    
 <2><dc>: Abbrev Number: 6 (DW_TAG_member)
    <dd>   DW_AT_name        : A    
    <df>   DW_AT_data_member_location: 2 byte block: 23 0    
(DW_OP_plus_uconst: 0)
    <e2>   DW_AT_type        : <0x10a>    
 <2><e6>: Abbrev Number: 6 (DW_TAG_member)
    <e7>   DW_AT_name        : B    
    <e9>   DW_AT_data_member_location: 2 byte block: 23 4    
(DW_OP_plus_uconst: 4)
    <ec>   DW_AT_type        : <0x10a>    


 <1><f6>: Abbrev Number: 4 (DW_TAG_typedef)
    <f7>   DW_AT_name        : PFOO    
    <fc>   DW_AT_type        : <0x100>    
 <1><100>: Abbrev Number: 8 (DW_TAG_pointer_type)
    <101>   DW_AT_type        : <0xcb>    

 <1><10a>: Abbrev Number: 4 (DW_TAG_typedef)
    <10b>   DW_AT_name        : LONGINT    
    <113>   DW_AT_type        : <0x117>    
 <1><117>: Abbrev Number: 9 (DW_TAG_base_type)
    <118>   DW_AT_name        : LONGINT    
    <120>   DW_AT_encoding    : 5    (signed)
    <121>   DW_AT_byte_size   : 4

-- 
You are receiving this mail because:
You are on the CC list for the bug.


             reply	other threads:[~2013-10-08 10:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-08 10:49 gdb.bugs at mfriebe dot de [this message]
2013-10-17 20:10 ` [Bug gdb/16016] " sergiodj at redhat dot com
2014-09-12 23:12 ` sergiodj at redhat dot com
2015-01-06  1:35 ` gdb.bugs at mfriebe dot de
2015-08-31 10:08 ` gdb.bugs at mfriebe dot de
2020-08-20 22:22 ` mnalis-sourceware at voyager dot hr
2020-08-21 20:31 ` [Bug pascal/16016] " tromey at sourceware dot org
2020-08-24 15:45 ` muller at sourceware dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-16016-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).