Bug 16696 - AIX 32-bit cores, high section addresses.
Summary: AIX 32-bit cores, high section addresses.
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 7.7
: P2 normal
Target Milestone: 7.8
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-12 10:24 UTC by Pedro Alves
Modified: 2014-03-12 11:09 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro Alves 2014-03-12 10:24:27 UTC
GDB fails to find the memory for variables in 32-bit AIX cores when the program had the corresponding segment mapped at a high addresses (>= 0x80000000).

E.g.:

 (gdb) p &__n_pthreads
 $2 = (<data variable, no debug info> *) 0xf074fda8 <__n_pthreads>
 (gdb) p __n_pthreads
 $1 = -1

That should have returned 2 instead of -1.  

(-1 is the value the variable has in the executable)
Comment 1 Sourceware Commits 2014-03-12 10:42:18 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, gdb-7.7-branch has been updated
       via  0136e467ea6d053fede23dda74c30033bd9371b7 (commit)
      from  e80f9a926c466c79ab1d25522e845f6c44704970 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0136e467ea6d053fede23dda74c30033bd9371b7

commit 0136e467ea6d053fede23dda74c30033bd9371b7
Author: Pedro Alves <palves@redhat.com>
Date:   Wed Mar 12 10:28:59 2014 +0000

    AIX 32-bit core loading, high section addresses.
    
    I noticed GDB was failing to enable threading support for 32-bit AIX
    cores.  I traced it to failure to read variables from libpthreads.a.
    The issue is that data for that library is loaded at a high address,
    and bfd is sign extending the section addresses:
    
     (gdb) info files
     Symbols from "/home/palves/crash".
     Local core dump file:
    	 `/home/palves/core', file type aixcoff-rs6000.
    	 0x2ff22000 - 0x2ff23000 is .stack
    	 0x20000000 - 0x200316e0 is .data
    	 0x20000e90 - 0x200016c0 is .data
    	 0xfffffffff0254000 - 0xfffffffff0297920 is .data
    	 0xfffffffff07b46a8 - 0xfffffffff07b47c8 is .data
    	 0xfffffffff0298000 - 0xfffffffff029bfcc is .data
    	 0xfffffffff06dafe0 - 0xfffffffff07b3838 is .data
     Local exec file:
    	 `/home/palves/crash', file type aixcoff-rs6000.
    	 Entry point: 0x20001394
    	 0x10000150 - 0x10000e90 is .text
    	 0x20000e90 - 0x2000149c is .data
    	 0x2000149c - 0x200016c0 is .bss
    	 0xd053b124 - 0xd053e15f is .text in /usr/lib/libpthreads.a(shr_comm.o)
    	 0xf0254000 - 0xf0297920 is .data in /usr/lib/libpthreads.a(shr_comm.o)
    	 0xf0254450 - 0xf0297920 is .bss in /usr/lib/libpthreads.a(shr_comm.o)
    	 0xd053a280 - 0xd053aabe is .text in /usr/lib/libcrypt.a(shr.o)
    	 0xf07b46a8 - 0xf07b47c8 is .data in /usr/lib/libcrypt.a(shr.o)
    	 0xf07b47c8 - 0xf07b47c8 is .bss in /usr/lib/libcrypt.a(shr.o)
    	 0xd04fb180 - 0xd053917e is .text in /usr/lib/libpthreads.a(shr_xpg5.o)
    	 0xf0298000 - 0xf029bfcc is .data in /usr/lib/libpthreads.a(shr_xpg5.o)
    	 0xf029bf64 - 0xf029bfcc is .bss in /usr/lib/libpthreads.a(shr_xpg5.o)
    	 0xd0100900 - 0xd04fa39c is .text in /usr/lib/libc.a(shr.o)
    	 0xf06dafe0 - 0xf07b3838 is .data in /usr/lib/libc.a(shr.o)
    	 0xf0751e94 - 0xf07b3838 is .bss in /usr/lib/libc.a(shr.o)
    
    Notice:
    	...
    	0xfffffffff0298000 - 0xfffffffff029bfcc is .data
    	...
    
    Those are the bfd section start/end addresses.  It't not visible here:
    
             ...
    	 0xf0298000 - 0xf029bfcc is .data in /usr/lib/libpthreads.a(shr_xpg5.o)
             ...
    
    ... just because GDB trims that number to 32-bit when printing.
    
    GDB then fails to find the memory for libpthreads.a variables in the
    core, and falls back to reading it directly from the executable (which
    yields the values as originally initialized in the code).
    
    E.g.:
    
     (gdb) p &__n_pthreads
     $2 = (<data variable, no debug info> *) 0xf074fda8 <__n_pthreads>
     (gdb) p __n_pthreads
     $1 = -1
    
    That should have returned 2 instead of -1.
    
    bfd/
    2014-03-12  Pedro Alves  <palves@redhat.com>
    
    	PR gdb/16696
    	* rs6000-core.c (rs6000coff_core_p): Cast pointers to bfd_vma
    	through ptr_to_uint instead of through long.

-----------------------------------------------------------------------

Summary of changes:
 bfd/ChangeLog     |    6 ++++++
 bfd/rs6000-core.c |    4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)
Comment 2 Sourceware Commits 2014-03-12 11:08:59 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  5893c83a47db6f00e183a271f3b330dcd8efd069 (commit)
      from  7701725167853ea4fcb9698e29e466d3b6541ddd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5893c83a47db6f00e183a271f3b330dcd8efd069

commit 5893c83a47db6f00e183a271f3b330dcd8efd069
Author: Pedro Alves <palves@redhat.com>
Date:   Wed Mar 12 11:07:37 2014 +0000

    Mention PR gdb/16696 in corresponding ChangeLog entry.

-----------------------------------------------------------------------

Summary of changes:
 bfd/ChangeLog |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Comment 3 Pedro Alves 2014-03-12 11:09:43 UTC
Fixed 7.7.1 and mainline.