public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15770] New: "Info Variables" returns bad results for typedef array
@ 2013-07-22 20:26 b_smith at aerosimulation dot com
  2013-07-23 11:53 ` [Bug c++/15770] " b_smith at aerosimulation dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: b_smith at aerosimulation dot com @ 2013-07-22 20:26 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15770

            Bug ID: 15770
           Summary: "Info Variables" returns bad results for typedef array
           Product: gdb
           Version: 7.2
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: b_smith at aerosimulation dot com

When using "info variables" on a structure with a custom float type, the array
length value indicates 0 when it should be 8.

Sample code to reproduce is below:

test.c
--------------------------------
typedef float float32;

const float32 hsi_range[] = {2.5, 5.0, 10.0, 20.0, 40.0, 80.0, 160.0, 320.0};

typedef struct {
   float32 f32ara[8];
   int a;
   char c;
} shm_rec_t;

shm_rec_t shm;

int main()
{
   return 0;
}
-------------------------------

At the command line:
$ g++ -g test.c -o T
$ gdb T
(gdb) info variables
...
...
(gdb) ptype shm_rec_t


- When called, this will return "float32 f32ara[0];" for the first element in
the struct.

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/15770] "Info Variables" returns bad results for typedef array
  2013-07-22 20:26 [Bug c++/15770] New: "Info Variables" returns bad results for typedef array b_smith at aerosimulation dot com
@ 2013-07-23 11:53 ` b_smith at aerosimulation dot com
  2013-07-23 15:37 ` tromey at redhat dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: b_smith at aerosimulation dot com @ 2013-07-23 11:53 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15770

--- Comment #1 from b_smith at aerosimulation dot com ---
We have further been able to test the issue and establish that this will work
with any typedef assignment, not just float as listed in the example.
Additionally, it seems that the index only breaks when the initialized array
has the same count of elements as the struct's array. 

So, the following is an example program that also breaks the "info variables" +
"Ptype shm_rec_t" sequence results:

typedef int int32;

const int32 hsi_range[] = {2, 5, 10};  //note: {0, 2, 5, 10} would return valid
results

typedef struct {
   int32 i32ara[3];
   int a;
   char c;
} shm_rec_t;

shm_rec_t shm;

int main()
{
   return 0;
}

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/15770] "Info Variables" returns bad results for typedef array
  2013-07-22 20:26 [Bug c++/15770] New: "Info Variables" returns bad results for typedef array b_smith at aerosimulation dot com
  2013-07-23 11:53 ` [Bug c++/15770] " b_smith at aerosimulation dot com
@ 2013-07-23 15:37 ` tromey at redhat dot com
  2013-07-23 16:21 ` b_smith at aerosimulation dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tromey at redhat dot com @ 2013-07-23 15:37 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15770

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |tromey at redhat dot com
         Resolution|---                         |FIXED

--- Comment #2 from Tom Tromey <tromey at redhat dot com> ---
This works in gdb 7.6:

(gdb) ptype shm_rec_t
type = struct shm_rec_t {
    float f32ara[8];
    int a;
    char c;
}

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/15770] "Info Variables" returns bad results for typedef array
  2013-07-22 20:26 [Bug c++/15770] New: "Info Variables" returns bad results for typedef array b_smith at aerosimulation dot com
  2013-07-23 11:53 ` [Bug c++/15770] " b_smith at aerosimulation dot com
  2013-07-23 15:37 ` tromey at redhat dot com
@ 2013-07-23 16:21 ` b_smith at aerosimulation dot com
  2013-07-23 16:37 ` tromey at redhat dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: b_smith at aerosimulation dot com @ 2013-07-23 16:21 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15770

b_smith at aerosimulation dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #3 from b_smith at aerosimulation dot com ---
Thanks for taking a look, Tom.

Just to confirm, did you run "info variables" before running the "ptype"
command? Its a peculiar bug, but on our instance the problem only manifested
when "info variables" was called before "ptype". When we called "ptype" first,
without calling "info variables" we got the proper results. From your comment I
couldn't tell if you had skipped directly to the ptype call.

Thanks,

Brad

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/15770] "Info Variables" returns bad results for typedef array
  2013-07-22 20:26 [Bug c++/15770] New: "Info Variables" returns bad results for typedef array b_smith at aerosimulation dot com
                   ` (2 preceding siblings ...)
  2013-07-23 16:21 ` b_smith at aerosimulation dot com
@ 2013-07-23 16:37 ` tromey at redhat dot com
  2013-07-23 16:54 ` b_smith at aerosimulation dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: tromey at redhat dot com @ 2013-07-23 16:37 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15770

--- Comment #4 from Tom Tromey <tromey at redhat dot com> ---
Yeah, I did.  Sorry for not making that clear.
Here is my gdb session:

barimba. ~/Space/gdb/7.6/install/bin/gdb ./q
GNU gdb (GDB) 7.6.0.20130515-cvs
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/q...done.
(gdb) info variables 
All defined variables:

File q.cc:
shm_rec_t shm;
static const float hsi_range[8];

Non-debugging symbols:
0x0000000000400660  _IO_stdin_used
0x0000000000400668  __dso_handle
0x00000000004007a8  __FRAME_END__
0x0000000000600de0  __frame_dummy_init_array_entry
0x0000000000600de0  __init_array_start
0x0000000000600de8  __do_global_dtors_aux_fini_array_entry
0x0000000000600de8  __init_array_end
0x0000000000600df0  __JCR_END__
0x0000000000600df0  __JCR_LIST__
0x0000000000600df8  _DYNAMIC
0x0000000000601000  _GLOBAL_OFFSET_TABLE_
0x0000000000601028  __data_start
0x0000000000601028  data_start
0x000000000060102c  __bss_start
0x000000000060102c  _edata
0x0000000000601030  __TMC_END__
0x0000000000601040  completed.6137
0x0000000000601088  _end
(gdb) ptype shm_rec_t
type = struct shm_rec_t {
    float f32ara[8];
    int a;
    char c;
}
(gdb) quit

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/15770] "Info Variables" returns bad results for typedef array
  2013-07-22 20:26 [Bug c++/15770] New: "Info Variables" returns bad results for typedef array b_smith at aerosimulation dot com
                   ` (3 preceding siblings ...)
  2013-07-23 16:37 ` tromey at redhat dot com
@ 2013-07-23 16:54 ` b_smith at aerosimulation dot com
  2013-07-23 17:42 ` tromey at redhat dot com
  2013-07-23 18:10 ` b_smith at aerosimulation dot com
  6 siblings, 0 replies; 8+ messages in thread
From: b_smith at aerosimulation dot com @ 2013-07-23 16:54 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15770

b_smith at aerosimulation dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from b_smith at aerosimulation dot com ---
Tom,

Thanks for the diligence. Looking at your "info variables" output I just want
to confirm that you have the following lines in your test file (particular
attention to the float32):

  typedef float float32;

  const float32 hsi_range[] = {2.5, 5.0, 10.0, 20.0, 40.0, 80.0, 160.0, 320.0};

  typedef struct {
    float32 f32ara[8];
    ...
  }


It is important that the typdef is declared and then used for the const array.
>From your output, it looked like your array used a basic float, instead of the
typdef float32. When we use a standard float, the bug doesn't occur. The bug
requires a typdef type. Our output for "info variables" and "ptype" is:

(gdb) info variables
All defined variables:

File test.c:
shm_rec_t shm;
static float32 hsi_range[8];

(gdb) ptype shm_rec_t
type = struct shm_rec_t {
    float32 f32ara[0];
    int a;
    char c;
}



...versus your:

File q.cc:
shm_rec_t shm;
static const float hsi_range[8];

(gdb) ptype shm_rec_t
type = struct shm_rec_t {
    float f32ara[8];
    int a;
    char c;
}

However, I could understand if the outputs are different due to versioning, and
the new version resolved the type in both the "info variables" and "ptype"
calls. 

Thanks, 

Brad

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/15770] "Info Variables" returns bad results for typedef array
  2013-07-22 20:26 [Bug c++/15770] New: "Info Variables" returns bad results for typedef array b_smith at aerosimulation dot com
                   ` (4 preceding siblings ...)
  2013-07-23 16:54 ` b_smith at aerosimulation dot com
@ 2013-07-23 17:42 ` tromey at redhat dot com
  2013-07-23 18:10 ` b_smith at aerosimulation dot com
  6 siblings, 0 replies; 8+ messages in thread
From: tromey at redhat dot com @ 2013-07-23 17:42 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15770

--- Comment #6 from Tom Tromey <tromey at redhat dot com> ---
I cut and pasted "test.c" from the original report.
Could you try 7.6?

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/15770] "Info Variables" returns bad results for typedef array
  2013-07-22 20:26 [Bug c++/15770] New: "Info Variables" returns bad results for typedef array b_smith at aerosimulation dot com
                   ` (5 preceding siblings ...)
  2013-07-23 17:42 ` tromey at redhat dot com
@ 2013-07-23 18:10 ` b_smith at aerosimulation dot com
  6 siblings, 0 replies; 8+ messages in thread
From: b_smith at aerosimulation dot com @ 2013-07-23 18:10 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15770

--- Comment #7 from b_smith at aerosimulation dot com ---
Tom,

Thanks again for the help. I just installed gdb 7.6 and it worked as expected.
Output below:

(gdb) info variables
All defined variables:

File test.c:
shm_rec_t shm;
static const float32 hsi_range[8];


(gdb) ptype shm_rec_t
type = struct shm_rec_t {
    float32 f32ara[8];
    int a;
    char c;
}

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-07-23 18:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-22 20:26 [Bug c++/15770] New: "Info Variables" returns bad results for typedef array b_smith at aerosimulation dot com
2013-07-23 11:53 ` [Bug c++/15770] " b_smith at aerosimulation dot com
2013-07-23 15:37 ` tromey at redhat dot com
2013-07-23 16:21 ` b_smith at aerosimulation dot com
2013-07-23 16:37 ` tromey at redhat dot com
2013-07-23 16:54 ` b_smith at aerosimulation dot com
2013-07-23 17:42 ` tromey at redhat dot com
2013-07-23 18:10 ` b_smith at aerosimulation dot com

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).