public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/18436] New: Can't print dynamically allocated global array
@ 2015-05-20  4:54 stanton at haas dot berkeley.edu
  2015-05-20 16:34 ` [Bug gdb/18436] " keiths at redhat dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: stanton at haas dot berkeley.edu @ 2015-05-20  4:54 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 18436
           Summary: Can't print dynamically allocated global array
           Product: gdb
           Version: 7.9
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: stanton at haas dot berkeley.edu
  Target Milestone: ---

If I dynamically allocate memory for an array using malloc, if the pointer is
defined globally, when I ask gdb to print an element of the array I get the
error message

cannot subscript something of type `<data variable, no debug info>'

Here's a very short program that demonstrates the problem. Compile with 

gcc -g -c -o main.o main.c
gcc -o main main.o 

then, using gdb, step into the middle of the loop and try "print vec[0]". It
works fine if the "double *vec;" line is inside main().

#include <stdio.h>
#include <stdlib.h>

double *vec;

int main(int argc, char *argv[])
{
    int i;

    vec = (double *) malloc((unsigned) 10*sizeof(double));

    for (i=0; i<10; i++) {
        vec[i] = i;
        printf("Item %d = %15.6g\n", i, vec[i]);
    }

    free((char*) vec);

    return(0);
}

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


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

* [Bug gdb/18436] Can't print dynamically allocated global array
  2015-05-20  4:54 [Bug gdb/18436] New: Can't print dynamically allocated global array stanton at haas dot berkeley.edu
@ 2015-05-20 16:34 ` keiths at redhat dot com
  2015-05-20 17:15 ` stanton at haas dot berkeley.edu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: keiths at redhat dot com @ 2015-05-20 16:34 UTC (permalink / raw)
  To: gdb-prs

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

Keith Seitz <keiths at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |keiths at redhat dot com

--- Comment #1 from Keith Seitz <keiths at redhat dot com> ---
I tried your supplied test case on both the 7.9 branch and HEAD, and I was
unable to reproduce it on Fedora 21, using the system compiler (4.9.2 20150212
(Red Hat 4.9.2-6)).

What is your environment? gdb/gcc -v (or "show version" in gdb).
What does "info var ^vec$" give?

For reference:

GNU gdb (GDB) 7.9
Copyright (C) 2015 Free Software Foundation, Inc.
[snip]
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/keiths/tmp/18436...done.
(gdb) start
Temporary breakpoint 1 at 0x4005d5: file /home/keiths/tmp/18436.c, line 10.
Starting program: /home/keiths/tmp/18436 

Temporary breakpoint 1, main (argc=1, argv=0x7fffffffdb18)
    at /home/keiths/tmp/18436.c:10
10          vec = (double *) malloc((unsigned) 10*sizeof(double));
(gdb) n
12          for (i=0; i<10; i++) {
(gdb) 
13              vec[i] = i;
(gdb) 
14              printf("Item %d = %15.6g\n", i, vec[i]);
(gdb) p vec[0]
$1 = 0
(gdb) info var ^vec$
All variables matching regular expression "^vec$":

File /home/keiths/tmp/18436.c:
double *vec;
(gdb)

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


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

* [Bug gdb/18436] Can't print dynamically allocated global array
  2015-05-20  4:54 [Bug gdb/18436] New: Can't print dynamically allocated global array stanton at haas dot berkeley.edu
  2015-05-20 16:34 ` [Bug gdb/18436] " keiths at redhat dot com
@ 2015-05-20 17:15 ` stanton at haas dot berkeley.edu
  2015-05-20 17:48 ` keiths at redhat dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: stanton at haas dot berkeley.edu @ 2015-05-20 17:15 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from stanton at haas dot berkeley.edu ---
Thanks for the response, Keith First, I’m running OS X 10.10.3.

Test 1: MacPorts versions of gdb and gcc
gdb version = GNU gdb (GDB) 7.7.1
gcc version = gcc version 4.9.2 (MacPorts gcc49 4.9.2_1) 

(gdb) print vec[0]
cannot subscript something of type `<data variable, no debug info>'
(gdb) info var ^vec$
All variables matching regular expression "^vec$":

Non-debugging symbols:
0x0000000100001028  vec

Test 2: Same debugger, but Apple LLVM version 6.1.0 (clang-602.0.53) (based on
LLVM 3.6.0svn): same result.

Test 3: I just installed home-brew gdb 7.9 and tried the same test with the
Apple LLVM compiled code. Same result again.



> On May 20, 2015, at 9:34 AM, keiths at redhat dot com <sourceware-bugzilla@sourceware.org> wrote:
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=18436
> 
> Keith Seitz <keiths at redhat dot com> changed:
> 
>           What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                 CC|                            |keiths at redhat dot com
> 
> --- Comment #1 from Keith Seitz <keiths at redhat dot com> ---
> I tried your supplied test case on both the 7.9 branch and HEAD, and I was
> unable to reproduce it on Fedora 21, using the system compiler (4.9.2 20150212
> (Red Hat 4.9.2-6)).
> 
> What is your environment? gdb/gcc -v (or "show version" in gdb).
> What does "info var ^vec$" give?
> 
> For reference:
> 
> GNU gdb (GDB) 7.9
> Copyright (C) 2015 Free Software Foundation, Inc.
> [snip]
> Type "apropos word" to search for commands related to "word"...
> Reading symbols from /home/keiths/tmp/18436...done.
> (gdb) start
> Temporary breakpoint 1 at 0x4005d5: file /home/keiths/tmp/18436.c, line 10.
> Starting program: /home/keiths/tmp/18436 
> 
> Temporary breakpoint 1, main (argc=1, argv=0x7fffffffdb18)
>    at /home/keiths/tmp/18436.c:10
> 10          vec = (double *) malloc((unsigned) 10*sizeof(double));
> (gdb) n
> 12          for (i=0; i<10; i++) {
> (gdb) 
> 13              vec[i] = i;
> (gdb) 
> 14              printf("Item %d = %15.6g\n", i, vec[i]);
> (gdb) p vec[0]
> $1 = 0
> (gdb) info var ^vec$
> All variables matching regular expression "^vec$":
> 
> File /home/keiths/tmp/18436.c:
> double *vec;
> (gdb)
> 
> -- 
> You are receiving this mail because:
> You reported the bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-18099-listarch-gdb-prs=sources.redhat.com@sourceware.org Wed May 20 17:26:27 2015
Return-Path: <gdb-prs-return-18099-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 40058 invoked by alias); 20 May 2015 17:26:26 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 40032 invoked by uid 55); 20 May 2015 17:26:25 -0000
From: "stanton at haas dot berkeley.edu" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/18436] Can't print dynamically allocated global array
Date: Wed, 20 May 2015 17:26:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: gdb
X-Bugzilla-Version: 7.9
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: stanton at haas dot berkeley.edu
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at sourceware dot org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-18436-4717-L5LGDZaUN8@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-18436-4717@http.sourceware.org/bugzilla/>
References: <bug-18436-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-q2/txt/msg00293.txt.bz2
Content-length: 3017

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

--- Comment #3 from stanton at haas dot berkeley.edu ---
Further follow-up: I tried MacPorts cgdb, - same result.

I then tried LLDB (the Xcode default debugger) on the same executable - it can
print the contents of vec just fine However, I don’t want to use LLDB!


> On May 20, 2015, at 10:15 AM, Richard Stanton <stanton@haas.berkeley.edu> wrote:
> 
> Thanks for the response, Keith First, I’m running OS X 10.10.3.
> 
> Test 1: MacPorts versions of gdb and gcc
> gdb version = GNU gdb (GDB) 7.7.1
> gcc version = gcc version 4.9.2 (MacPorts gcc49 4.9.2_1) 
> 
> (gdb) print vec[0]
> cannot subscript something of type `<data variable, no debug info>'
> (gdb) info var ^vec$
> All variables matching regular expression "^vec$":
> 
> Non-debugging symbols:
> 0x0000000100001028  vec
> 
> Test 2: Same debugger, but Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn): same result.
> 
> Test 3: I just installed home-brew gdb 7.9 and tried the same test with the Apple LLVM compiled code. Same result again.
> 
> 
> 
>> On May 20, 2015, at 9:34 AM, keiths at redhat dot com <sourceware-bugzilla@sourceware.org> wrote:
>> 
>> https://sourceware.org/bugzilla/show_bug.cgi?id=18436
>> 
>> Keith Seitz <keiths at redhat dot com> changed:
>> 
>>          What    |Removed                     |Added
>> ----------------------------------------------------------------------------
>>                CC|                            |keiths at redhat dot com
>> 
>> --- Comment #1 from Keith Seitz <keiths at redhat dot com> ---
>> I tried your supplied test case on both the 7.9 branch and HEAD, and I was
>> unable to reproduce it on Fedora 21, using the system compiler (4.9.2 20150212
>> (Red Hat 4.9.2-6)).
>> 
>> What is your environment? gdb/gcc -v (or "show version" in gdb).
>> What does "info var ^vec$" give?
>> 
>> For reference:
>> 
>> GNU gdb (GDB) 7.9
>> Copyright (C) 2015 Free Software Foundation, Inc.
>> [snip]
>> Type "apropos word" to search for commands related to "word"...
>> Reading symbols from /home/keiths/tmp/18436...done.
>> (gdb) start
>> Temporary breakpoint 1 at 0x4005d5: file /home/keiths/tmp/18436.c, line 10.
>> Starting program: /home/keiths/tmp/18436 
>> 
>> Temporary breakpoint 1, main (argc=1, argv=0x7fffffffdb18)
>>   at /home/keiths/tmp/18436.c:10
>> 10          vec = (double *) malloc((unsigned) 10*sizeof(double));
>> (gdb) n
>> 12          for (i=0; i<10; i++) {
>> (gdb) 
>> 13              vec[i] = i;
>> (gdb) 
>> 14              printf("Item %d = %15.6g\n", i, vec[i]);
>> (gdb) p vec[0]
>> $1 = 0
>> (gdb) info var ^vec$
>> All variables matching regular expression "^vec$":
>> 
>> File /home/keiths/tmp/18436.c:
>> double *vec;
>> (gdb)
>> 
>> -- 
>> You are receiving this mail because:
>> You reported the bug.
>

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-18100-listarch-gdb-prs=sources.redhat.com@sourceware.org Wed May 20 17:37:15 2015
Return-Path: <gdb-prs-return-18100-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 72576 invoked by alias); 20 May 2015 17:37:15 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 72543 invoked by uid 55); 20 May 2015 17:37:14 -0000
From: "stanton at haas dot berkeley.edu" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/18436] Can't print dynamically allocated global array
Date: Wed, 20 May 2015 17:37:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: gdb
X-Bugzilla-Version: 7.9
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: stanton at haas dot berkeley.edu
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at sourceware dot org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-18436-4717-oRQQzAPj84@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-18436-4717@http.sourceware.org/bugzilla/>
References: <bug-18436-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-q2/txt/msg00294.txt.bz2
Content-length: 720

https://sourceware.org/bugzilla/show_bug.cgi?id\x18436

--- Comment #4 from stanton at haas dot berkeley.edu ---
It also works if I use the MacPorts port gdb-apple, which announces itself as

GNU gdb 6.3.50.20050815-cvs (Wed Nov 26 07:47:26 UTC 2014)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-apple-darwin14.0.0 --target=".

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


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

* [Bug gdb/18436] Can't print dynamically allocated global array
  2015-05-20  4:54 [Bug gdb/18436] New: Can't print dynamically allocated global array stanton at haas dot berkeley.edu
  2015-05-20 16:34 ` [Bug gdb/18436] " keiths at redhat dot com
  2015-05-20 17:15 ` stanton at haas dot berkeley.edu
@ 2015-05-20 17:48 ` keiths at redhat dot com
  2015-05-20 18:13 ` stanton at haas dot berkeley.edu
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: keiths at redhat dot com @ 2015-05-20 17:48 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #5 from Keith Seitz <keiths at redhat dot com> ---
(In reply to stanton from comment #2)
> Thanks for the response, Keith First, I’m running OS X 10.10.3.
> 
> Test 1: MacPorts versions of gdb and gcc
> gdb version = GNU gdb (GDB) 7.7.1
> gcc version = gcc version 4.9.2 (MacPorts gcc49 4.9.2_1) 
> 
> (gdb) print vec[0]
> cannot subscript something of type `<data variable, no debug info>'
> (gdb) info var ^vec$
> All variables matching regular expression "^vec$":
> 
> Non-debugging symbols:
> 0x0000000100001028  vec
> 

Considering you have source files and can step through your program, this tells
me that there is a debug info problem concerning the global variable vec or
there is some obscure bug in gdb preventing this from working.

I have some vague recollection of custom Apple DWARF extensions making their
way into GCC for MacOS, but not GDB. That might explain why LLDB can
successfully inspect the variable.

Does "readelf -w" (does that exist on Mac?) show any output DIEs?

For example, for the test case associated with this bug,

$ readelf -w main | grep producer
     <c>   DW_AT_producer    : (indirect string, offset: 0xb6): GNU C 4.9.2
20150212 (Red Hat 4.9.2-6) -mtune=generic -march=x86-64 -g  
    DW_AT_producer     DW_FORM_strp

Other than the fact that we have debug DIEs, we can also see the "-g" was
passed to GCC to output debug info.

Also, what is the debug info for "vec" (if any)? In my build of the test, I
have:
 <1><d7>: Abbrev Number: 8 (DW_TAG_variable)
    <d8>   DW_AT_name        : vec      
    <dc>   DW_AT_decl_file   : 1        
    <dd>   DW_AT_decl_line   : 4        
    <de>   DW_AT_type        : <0xec>   
    <e2>   DW_AT_external    : 1        
    <e2>   DW_AT_location    : 9 byte block: 3 50 10 60 0 0 0 0 0      
(DW_OP_addr: 601050)

A (not satisfactory IMO) workaround is to tell gdb what "vec" is:
(gdb) file ~/tmp/18436.nodebug
(gdb) start
Temporary breakpoint 1 at 0x4005ca
Starting program: /home/keiths/tmp/18436.nodebug 

Temporary breakpoint 1, 0x00000000004005ca in main ()
(gdb) ni 50
Item 0 =               0
0x000000000040062b in main ()
(gdb) p vec[0]
cannot subscript something of type `<data variable, no debug info>'
(gdb) p ((double*)vec)[0]
$1 = 0
(gdb)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-18102-listarch-gdb-prs=sources.redhat.com@sourceware.org Wed May 20 17:49:36 2015
Return-Path: <gdb-prs-return-18102-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 94441 invoked by alias); 20 May 2015 17:49:36 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 94410 invoked by uid 48); 20 May 2015 17:49:35 -0000
From: "keiths at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/18436] Can't print dynamically allocated global array
Date: Wed, 20 May 2015 17:49:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: gdb
X-Bugzilla-Version: 7.9
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: keiths at redhat dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at sourceware dot org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-18436-4717-uaEp5YjVMb@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-18436-4717@http.sourceware.org/bugzilla/>
References: <bug-18436-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-q2/txt/msg00296.txt.bz2
Content-length: 910

https://sourceware.org/bugzilla/show_bug.cgi?id\x18436

--- Comment #6 from Keith Seitz <keiths at redhat dot com> ---
(In reply to stanton from comment #4)
> It also works if I use the MacPorts port gdb-apple, which announces itself as
>
> GNU gdb 6.3.50.20050815-cvs (Wed Nov 26 07:47:26 UTC 2014)
> Copyright 2004 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "--host=i686-apple-darwin14.0.0 --target=".

This would seem to support my suspicion that there are DWARF extensions that
were never submitted and/or approved for FSF GDB.

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


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

* [Bug gdb/18436] Can't print dynamically allocated global array
  2015-05-20  4:54 [Bug gdb/18436] New: Can't print dynamically allocated global array stanton at haas dot berkeley.edu
                   ` (2 preceding siblings ...)
  2015-05-20 17:48 ` keiths at redhat dot com
@ 2015-05-20 18:13 ` stanton at haas dot berkeley.edu
  2015-05-21 17:26 ` stanton at haas dot berkeley.edu
  2023-08-03 15:53 ` tromey at sourceware dot org
  5 siblings, 0 replies; 7+ messages in thread
From: stanton at haas dot berkeley.edu @ 2015-05-20 18:13 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #7 from stanton at haas dot berkeley.edu ---
Thanks, Keith. I found a port of readelf, but it doesn’t like my executable:

Richards-Mac-Pro:C stanton$ greadelf -w main | grep producer
readelf: Error: Not an ELF file - it has the wrong magic bytes at the start

> On May 20, 2015, at 10:48 AM, keiths at redhat dot com <sourceware-bugzilla@sourceware.org> wrote:
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=18436
> 
> --- Comment #5 from Keith Seitz <keiths at redhat dot com> ---
> (In reply to stanton from comment #2)
>> Thanks for the response, Keith First, I’m running OS X 10.10.3.
>> 
>> Test 1: MacPorts versions of gdb and gcc
>> gdb version = GNU gdb (GDB) 7.7.1
>> gcc version = gcc version 4.9.2 (MacPorts gcc49 4.9.2_1) 
>> 
>> (gdb) print vec[0]
>> cannot subscript something of type `<data variable, no debug info>'
>> (gdb) info var ^vec$
>> All variables matching regular expression "^vec$":
>> 
>> Non-debugging symbols:
>> 0x0000000100001028  vec
>> 
> 
> Considering you have source files and can step through your program, this tells
> me that there is a debug info problem concerning the global variable vec or
> there is some obscure bug in gdb preventing this from working.
> 
> I have some vague recollection of custom Apple DWARF extensions making their
> way into GCC for MacOS, but not GDB. That might explain why LLDB can
> successfully inspect the variable.
> 
> Does "readelf -w" (does that exist on Mac?) show any output DIEs?
> 
> For example, for the test case associated with this bug,
> 
> $ readelf -w main | grep producer
>     <c>   DW_AT_producer    : (indirect string, offset: 0xb6): GNU C 4.9.2
> 20150212 (Red Hat 4.9.2-6) -mtune=generic -march=x86-64 -g  
>    DW_AT_producer     DW_FORM_strp
> 
> Other than the fact that we have debug DIEs, we can also see the "-g" was
> passed to GCC to output debug info.
> 
> Also, what is the debug info for "vec" (if any)? In my build of the test, I
> have:
> <1><d7>: Abbrev Number: 8 (DW_TAG_variable)
>    <d8>   DW_AT_name        : vec      
>    <dc>   DW_AT_decl_file   : 1        
>    <dd>   DW_AT_decl_line   : 4        
>    <de>   DW_AT_type        : <0xec>   
>    <e2>   DW_AT_external    : 1        
>    <e2>   DW_AT_location    : 9 byte block: 3 50 10 60 0 0 0 0 0      
> (DW_OP_addr: 601050)
> 
> A (not satisfactory IMO) workaround is to tell gdb what "vec" is:
> (gdb) file ~/tmp/18436.nodebug
> (gdb) start
> Temporary breakpoint 1 at 0x4005ca
> Starting program: /home/keiths/tmp/18436.nodebug 
> 
> Temporary breakpoint 1, 0x00000000004005ca in main ()
> (gdb) ni 50
> Item 0 =               0
> 0x000000000040062b in main ()
> (gdb) p vec[0]
> cannot subscript something of type `<data variable, no debug info>'
> (gdb) p ((double*)vec)[0]
> $1 = 0
> (gdb)
> 
> -- 
> You are receiving this mail because:
> You reported the bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-18104-listarch-gdb-prs=sources.redhat.com@sourceware.org Wed May 20 18:18:23 2015
Return-Path: <gdb-prs-return-18104-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 63490 invoked by alias); 20 May 2015 18:18:22 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 63465 invoked by uid 55); 20 May 2015 18:18:22 -0000
From: "stanton at haas dot berkeley.edu" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/18436] Can't print dynamically allocated global array
Date: Wed, 20 May 2015 18:18:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: gdb
X-Bugzilla-Version: 7.9
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: stanton at haas dot berkeley.edu
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at sourceware dot org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-18436-4717-MHVjUmQIPe@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-18436-4717@http.sourceware.org/bugzilla/>
References: <bug-18436-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-q2/txt/msg00298.txt.bz2
Content-length: 520

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

--- Comment #8 from stanton at haas dot berkeley.edu ---
Unfortunately, the workaround below doesn’t work on my system:

(gdb) print vec[0]
cannot subscript something of type `<data variable, no debug info>'
(gdb) print ((double*)vec)[0]
Cannot access memory at address 0x200000

I just installed MacPorts gcc 5.1.0, and also hand-compiled gdb 7.9.1. It
didn’t help.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-18105-listarch-gdb-prs=sources.redhat.com@sourceware.org Wed May 20 20:16:22 2015
Return-Path: <gdb-prs-return-18105-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 4257 invoked by alias); 20 May 2015 20:16:21 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 4230 invoked by uid 55); 20 May 2015 20:16:20 -0000
From: "stanton at haas dot berkeley.edu" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/18436] Can't print dynamically allocated global array
Date: Wed, 20 May 2015 20:16:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: gdb
X-Bugzilla-Version: 7.9
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: stanton at haas dot berkeley.edu
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at sourceware dot org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-18436-4717-LZ1nTv7kpw@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-18436-4717@http.sourceware.org/bugzilla/>
References: <bug-18436-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-q2/txt/msg00299.txt.bz2
Content-length: 952

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

--- Comment #9 from stanton at haas dot berkeley.edu ---
I just noticed something odd. Using gcc 5.1 and gdb 7.7.1 (both MacPorts), I
can inspect v[0] fine if I compile like this:

gcc -g main.c -o main

It fails if I compile the same program (same gcc, some gdb) like this:

gcc -g -c -o main.o main.c
gcc -o main main.o 

Any idea why this should be different? 


> On May 20, 2015, at 11:17 AM, Richard Stanton <stanton@haas.berkeley.edu> wrote:
> 
> Unfortunately, the workaround below doesn’t work on my system:
> 
> (gdb) print vec[0]
> cannot subscript something of type `<data variable, no debug info>'
> (gdb) print ((double*)vec)[0]
> Cannot access memory at address 0x200000
> 
> I just installed MacPorts gcc 5.1.0, and also hand-compiled gdb 7.9.1. It didn’t help.
> 
>

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-18106-listarch-gdb-prs=sources.redhat.com@sourceware.org Wed May 20 21:18:16 2015
Return-Path: <gdb-prs-return-18106-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 123518 invoked by alias); 20 May 2015 21:18:16 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 123487 invoked by uid 48); 20 May 2015 21:18:16 -0000
From: "dje at google dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug python/11324] python pretty-printers uglify backtraces
Date: Wed, 20 May 2015 21:18:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: python
X-Bugzilla-Version: archer
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dje at google dot com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Resolution: FIXED
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at sourceware dot org
X-Bugzilla-Target-Milestone: 7.1
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cc resolution
Message-ID: <bug-11324-4717-hes9tZOPmn@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-11324-4717@http.sourceware.org/bugzilla/>
References: <bug-11324-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-q2/txt/msg00300.txt.bz2
Content-length: 671

https://sourceware.org/bugzilla/show_bug.cgi?id\x11324

dje at google dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |dje at google dot com
         Resolution|---                         |FIXED

--- Comment #2 from dje at google dot com ---
IIUC the intended solution is now implemented: gdbpy_gdb_memory_error and
print_stack_unless_memory_error.

Please reopen and clarify if not.

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


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

* [Bug gdb/18436] Can't print dynamically allocated global array
  2015-05-20  4:54 [Bug gdb/18436] New: Can't print dynamically allocated global array stanton at haas dot berkeley.edu
                   ` (3 preceding siblings ...)
  2015-05-20 18:13 ` stanton at haas dot berkeley.edu
@ 2015-05-21 17:26 ` stanton at haas dot berkeley.edu
  2023-08-03 15:53 ` tromey at sourceware dot org
  5 siblings, 0 replies; 7+ messages in thread
From: stanton at haas dot berkeley.edu @ 2015-05-21 17:26 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #10 from stanton at haas dot berkeley.edu ---
Final follow-up (for now):

gdb works fine if you add a -g flag to both the compilation and the linking
step. Not sure why, but at least it’s working now.

> gcc -g -c -o main.o main.c
> gcc -g -o main main.o 



> On May 20, 2015, at 1:15 PM, Richard Stanton <stanton@haas.berkeley.edu> wrote:
> 
> I just noticed something odd. Using gcc 5.1 and gdb 7.7.1 (both MacPorts), I can inspect v[0] fine if I compile like this:
> 
> gcc -g main.c -o main
> 
> It fails if I compile the same program (same gcc, some gdb) like this:
> 
> gcc -g -c -o main.o main.c
> gcc -o main main.o 
> 
> Any idea why this should be different? 
> 
> 
>> On May 20, 2015, at 11:17 AM, Richard Stanton <stanton@haas.berkeley.edu> wrote:
>> 
>> Unfortunately, the workaround below doesn’t work on my system:
>> 
>> (gdb) print vec[0]
>> cannot subscript something of type `<data variable, no debug info>'
>> (gdb) print ((double*)vec)[0]
>> Cannot access memory at address 0x200000
>> 
>> I just installed MacPorts gcc 5.1.0, and also hand-compiled gdb 7.9.1. It didn’t help.
>> 
>> 
>

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-18112-listarch-gdb-prs=sources.redhat.com@sourceware.org Thu May 21 17:39:52 2015
Return-Path: <gdb-prs-return-18112-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 61389 invoked by alias); 21 May 2015 17:39:52 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 61342 invoked by uid 48); 21 May 2015 17:39:50 -0000
From: "dje at google dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug c++/17976] ptype (anonymous namespace) doesn't work
Date: Thu, 21 May 2015 17:39:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: c++
X-Bugzilla-Version: HEAD
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dje at google dot com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Resolution: FIXED
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at sourceware dot org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-17976-4717-Y2GY1yRk9X@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-17976-4717@http.sourceware.org/bugzilla/>
References: <bug-17976-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-q2/txt/msg00306.txt.bz2
Content-length: 474

https://sourceware.org/bugzilla/show_bug.cgi?id\x17976

dje at google dot com changed:

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

--- Comment #2 from dje at google dot com ---
patch committed

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


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

* [Bug gdb/18436] Can't print dynamically allocated global array
  2015-05-20  4:54 [Bug gdb/18436] New: Can't print dynamically allocated global array stanton at haas dot berkeley.edu
                   ` (4 preceding siblings ...)
  2015-05-21 17:26 ` stanton at haas dot berkeley.edu
@ 2023-08-03 15:53 ` tromey at sourceware dot org
  5 siblings, 0 replies; 7+ messages in thread
From: tromey at sourceware dot org @ 2023-08-03 15:53 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
                 CC|                            |tromey at sourceware dot org
             Status|NEW                         |RESOLVED

--- Comment #11 from Tom Tromey <tromey at sourceware dot org> ---
(In reply to stanton from comment #10)
> Final follow-up (for now):
> 
> gdb works fine if you add a -g flag to both the compilation and the linking
> step. Not sure why, but at least it’s working now.

I don't know why either, normally -g isn't needed at link time.
Anyway, I'm going to close this, since it seems to work.

If you think that's in error, we can reopen it.
One potential issue here is that the macOS port isn't really maintained.

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

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

end of thread, other threads:[~2023-08-03 15:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-20  4:54 [Bug gdb/18436] New: Can't print dynamically allocated global array stanton at haas dot berkeley.edu
2015-05-20 16:34 ` [Bug gdb/18436] " keiths at redhat dot com
2015-05-20 17:15 ` stanton at haas dot berkeley.edu
2015-05-20 17:48 ` keiths at redhat dot com
2015-05-20 18:13 ` stanton at haas dot berkeley.edu
2015-05-21 17:26 ` stanton at haas dot berkeley.edu
2023-08-03 15:53 ` tromey at sourceware dot org

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