From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20933 invoked by alias); 30 Nov 2011 13:35:30 -0000 Received: (qmail 20727 invoked by uid 22791); 30 Nov 2011 13:35:29 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from usmamail.tilera.com (HELO USMAMAIL.TILERA.COM) (206.83.70.75) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 30 Nov 2011 13:35:16 +0000 Received: from [10.7.0.51] (10.9.0.23) by USMAExch2.tad.internal.tilera.com (10.3.0.33) with Microsoft SMTP Server id 14.0.694.0; Wed, 30 Nov 2011 08:35:14 -0500 Message-ID: <4ED63112.5080504@tilera.com> Date: Wed, 30 Nov 2011 13:35:00 -0000 From: Jeff Kenton User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 MIME-Version: 1.0 To: Jan Kratochvil CC: Subject: Re: GDB: problem debugging 32 bit binary on 64 bit machine References: <4ED54766.2020601@tilera.com> <20111129211102.GA15255@host2.jankratochvil.net> In-Reply-To: <20111129211102.GA15255@host2.jankratochvil.net> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-11/txt/msg00134.txt.bz2 On 11/29/2011 04:11 PM, Jan Kratochvil wrote: > On Tue, 29 Nov 2011 21:58:14 +0100, Jeff Kenton wrote: >> 0x400000008" (address is above the 32 bit limit). This is caused by >> a call to extract_typed_address() from scan_dyntag() reading an 8 >> byte type when it should only be reading 4 bytes. > ARCH_SIZE there should be 32 and TARGET_GDBARCH should be 32-bit. This sounds like the basic problem. Building the 32 bit target_gdbarch is easy. What's the best way (place in the code) to detect 32 bit vs. 64 bit binaries and switch between different gdbarch's? Thanks. > > I guess for some reasons your GDB found wrong (64-bit) library for your 32-bit > program. See the settings like `set solib-search-path', `set sysroot' etc. > >> I have two questions: >> 1. is tweaking extract_typed_address() the right way to handle 32 >> bit addresses on a 64 bit machine? > No. If ARCH_SIZE and TARGET_GDBARCH are set right it will work. > > >> 2. what's going wrong with dl_main()? > There is called a notification new library has been loaded in the inferior, > therefore GDB tries to load a matching symbol file (=the library itself) on > the GDB side. > > >> 3. meta-question: is this a generic bug in gdb's handling of 32 bit >> binaries, or is there likely something I missed while porting? > It 32-on-64 normally works, at least in Fedora, no custom patches for it > there. > > > Regards, > Jan