public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug corefiles/14944] New: "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11.
@ 2012-12-11 15:32 alexander.andrianov at oracle dot com
  2012-12-11 17:09 ` [Bug corefiles/14944] " palves at redhat dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: alexander.andrianov at oracle dot com @ 2012-12-11 15:32 UTC (permalink / raw)
  To: gdb-prs

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

             Bug #: 14944
           Summary: "Couldn't find general-purpose registers in core
                    file." while reading 32-bit core files on Solaris 11.
           Product: gdb
           Version: 7.5
            Status: NEW
          Severity: normal
          Priority: P2
         Component: corefiles
        AssignedTo: unassigned@sourceware.org
        ReportedBy: alexander.andrianov@oracle.com
    Classification: Unclassified


Starting with version 7.1 reading of 32-bit core files on Solaris is not
working properly. This issue is reproducible with GDB built with both Oracle
Solaris Studio or gcc 4.5.2. 

The issue also exists in the current snapshot of source files. 

Consider the following code generating segfault:

$cat ~/work/segfault/segfault.c 
#include <stdio.h>
#include <string.h>

int main(void)
{
    printf("Warning: Segmentation Fault should occur\n");
    char *dest = 0x0;
    memcpy (dest, "lol", 3);
    return 0;
}

If we compile segfault.c with -m32 option and run to generate core file, GDB is
not able to read the core file properly.


$./gdb ~/work/segfault/segfault.i386 -c ~/work/segfault/core.i386
GNU gdb (GDB) 7.5.50.20121129-cvs
Copyright (C) 2012 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 "i386-pc-solaris2.11".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from ~/work/segfault/segfault.i386...done.

warning: Couldn't find general-purpose registers in core file.
Core was generated by `./segfault.i386'.

warning: Couldn't find general-purpose registers in core file.
#0  <unavailable> in ?? ()
(gdb) quit


At the same time, GDB compiled with -g option (CFLAGS=-g) works properly:


#./gdb ~/work/segfault/segfault.i386 -c ~/work/segfault/core.i386
GNU gdb (GDB) 7.5.50.20121129-cvs
Copyright (C) 2012 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 "i386-pc-solaris2.11".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from ~/work/segfault/segfault.i386...done.
[New LWP 1]
Core was generated by `./segfault.i386'.
Program terminated with signal 11, Segmentation fault.
#0  0xbfe3c2b4 in memcpy () from /usr/lib/libc.so.1
(gdb) quit


The problem was introduced after these changes:

    2010-01-04  Daniel Gutson  <dgutson@codesourcery.com>

            * bfd.m4 (BFD_HAVE_SYS_PROCFS_TYPE): Define _STRUCTURE_PROC
            before including procfs.h.
            (BFD_HAVE_SYS_PROCFS_TYPE_MEMBER): Likewise.
            * configure.in: Added autoconf probe for the pr_fpreg member.
            * configure: Regenerated.
            * config.in: Regenerated.
            * elf.c: Define _STRUCTURE_PROC before including procfs.h.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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 corefiles/14944] "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11.
  2012-12-11 15:32 [Bug corefiles/14944] New: "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11 alexander.andrianov at oracle dot com
@ 2012-12-11 17:09 ` palves at redhat dot com
  2012-12-11 17:12 ` palves at redhat dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: palves at redhat dot com @ 2012-12-11 17:09 UTC (permalink / raw)
  To: gdb-prs

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

Pedro Alves <palves at redhat dot com> changed:

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

--- Comment #1 from Pedro Alves <palves at redhat dot com> 2012-12-11 17:09:38 UTC ---
This only happens if gdb itself is 64-bit, right?

I was under the impression that didn't work even before that patch.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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 corefiles/14944] "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11.
  2012-12-11 15:32 [Bug corefiles/14944] New: "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11 alexander.andrianov at oracle dot com
  2012-12-11 17:09 ` [Bug corefiles/14944] " palves at redhat dot com
@ 2012-12-11 17:12 ` palves at redhat dot com
  2012-12-11 19:06 ` alexander.andrianov at oracle dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: palves at redhat dot com @ 2012-12-11 17:12 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Pedro Alves <palves at redhat dot com> 2012-12-11 17:12:42 UTC ---
I meant to say:

> At the same time, GDB compiled with -g option (CFLAGS=-g) works properly:

That's sound very much like a red herring.  -g alone shouldn't affect this.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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 corefiles/14944] "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11.
  2012-12-11 15:32 [Bug corefiles/14944] New: "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11 alexander.andrianov at oracle dot com
  2012-12-11 17:09 ` [Bug corefiles/14944] " palves at redhat dot com
  2012-12-11 17:12 ` palves at redhat dot com
@ 2012-12-11 19:06 ` alexander.andrianov at oracle dot com
  2012-12-11 19:09 ` palves at redhat dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: alexander.andrianov at oracle dot com @ 2012-12-11 19:06 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Alexander Andrianov <alexander.andrianov at oracle dot com> 2012-12-11 19:06:30 UTC ---
(In reply to comment #2)
> I meant to say:
> 
> > At the same time, GDB compiled with -g option (CFLAGS=-g) works properly:
> 
> That's sound very much like a red herring.  -g alone shouldn't affect this.

Mea culpa. I missed that CFLAGS overrides my other flags including -m64. Sorry
for confusing. 


(In reply to comment #1)
> This only happens if gdb itself is 64-bit, right?

Yes, my gdb is 64-bit binary. 

> I was under the impression that didn't work even before that patch.

As I understand before that patch it was working because it was working in a
different way. At least gdb 7.0 and 6.8 work with 32-bit cores.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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 corefiles/14944] "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11.
  2012-12-11 15:32 [Bug corefiles/14944] New: "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11 alexander.andrianov at oracle dot com
                   ` (2 preceding siblings ...)
  2012-12-11 19:06 ` alexander.andrianov at oracle dot com
@ 2012-12-11 19:09 ` palves at redhat dot com
  2012-12-12 11:28 ` alexander.andrianov at oracle dot com
  2012-12-12 11:55 ` palves at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: palves at redhat dot com @ 2012-12-11 19:09 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from Pedro Alves <palves at redhat dot com> 2012-12-11 19:09:40 UTC ---
Okay.  Would you want to work on this and contribute a fix?  Not many GDB
developers develop for or even have easy Solaris access nowadays...  We can
provide guidance, though.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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 corefiles/14944] "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11.
  2012-12-11 15:32 [Bug corefiles/14944] New: "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11 alexander.andrianov at oracle dot com
                   ` (3 preceding siblings ...)
  2012-12-11 19:09 ` palves at redhat dot com
@ 2012-12-12 11:28 ` alexander.andrianov at oracle dot com
  2012-12-12 11:55 ` palves at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: alexander.andrianov at oracle dot com @ 2012-12-12 11:28 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #5 from Alexander Andrianov <alexander.andrianov at oracle dot com> 2012-12-12 11:28:28 UTC ---
(In reply to comment #4)
> Okay.  Would you want to work on this and contribute a fix?  Not many GDB
> developers develop for or even have easy Solaris access nowadays...  We can
> provide guidance, though.

Looks like it is a reasonable solution at this moment, so I'll try to do that. 
Any help where to start investigating would be appreciated.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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 corefiles/14944] "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11.
  2012-12-11 15:32 [Bug corefiles/14944] New: "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11 alexander.andrianov at oracle dot com
                   ` (4 preceding siblings ...)
  2012-12-12 11:28 ` alexander.andrianov at oracle dot com
@ 2012-12-12 11:55 ` palves at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: palves at redhat dot com @ 2012-12-12 11:55 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #6 from Pedro Alves <palves at redhat dot com> 2012-12-12 11:55:26 UTC ---
Best would be to pick up an x86_64 GNU/Linux box, and follow through the code
figuring out how things are supposed to work in this same scenario.

The core handling code in gdb starts in corelow.c.  Architecture and OS hooks
go through gdbarch callbacks.  The actually reading of the core files is done
by the bfd library.  bfd only "thinks" in terms of sections, so in order to get
at e.g., the registers for each of the core's threads, GDB will look for
sections name .reg/NNN.  These are so called pseudo-sections, because they
don't really exist on the core -- bfd made them up.  You can find the code that
does that in bfd/elf.c, look for make_pseudosection, and the various "grok"
routines.

My guess is that the change to use the new proc API make it so some #ifdef
(like HAVE_PRSTATUS_T, HAVE_PRPSINFO_T, etc.) now has different results. 
There's desire to get rid of the #ifdefery in the first place.  So if indeed
the problem is related to that, the best fix would be to make the Solaris core
bfd support code host independent (so cross debugging of cores works), like
other targets already are -- see the elf_backend_grok_prstatus hook, etc.,
though you may likely find a simpler fix.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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:[~2012-12-12 11:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-11 15:32 [Bug corefiles/14944] New: "Couldn't find general-purpose registers in core file." while reading 32-bit core files on Solaris 11 alexander.andrianov at oracle dot com
2012-12-11 17:09 ` [Bug corefiles/14944] " palves at redhat dot com
2012-12-11 17:12 ` palves at redhat dot com
2012-12-11 19:06 ` alexander.andrianov at oracle dot com
2012-12-11 19:09 ` palves at redhat dot com
2012-12-12 11:28 ` alexander.andrianov at oracle dot com
2012-12-12 11:55 ` palves at redhat 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).