From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13902 invoked by alias); 27 Sep 2006 18:20:39 -0000 Received: (qmail 13890 invoked by uid 22791); 27 Sep 2006 18:20:36 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.palmsource.com (HELO mx2.palmsource.com) (12.7.175.14) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 27 Sep 2006 18:20:30 +0000 Received: from localhost (localhost [127.0.0.1]) by localhost.domain.tld (Postfix) with ESMTP id 3414626E19; Wed, 27 Sep 2006 11:20:24 -0700 (PDT) Received: from mx2.palmsource.com ([127.0.0.1]) by localhost (mx2.palmsource.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 18426-01-3; Wed, 27 Sep 2006 11:20:23 -0700 (PDT) Received: from ussunex01.palmsource.com (unknown [192.168.101.9]) by mx2.palmsource.com (Postfix) with ESMTP id 2DC8E26E17; Wed, 27 Sep 2006 11:20:23 -0700 (PDT) Received: from 192.168.92.59 ([192.168.92.59]) by ussunex01.palmsource.com ([192.168.101.9]) via Exchange Front-End Server owa.palmsource.com ([10.0.20.17]) with Microsoft Exchange Server HTTP-DAV ; Wed, 27 Sep 2006 18:20:23 +0000 Received: from svmsnyderlnx by owa.palmsource.com; 27 Sep 2006 11:20:22 -0700 Subject: Re: [patch] Cut memory address width From: Michael Snyder To: Jan Kratochvil Cc: gdb-patches@sourceware.org In-Reply-To: <20060927161501.GA23340@host0.dyn.jankratochvil.net> References: <20060927161501.GA23340@host0.dyn.jankratochvil.net> Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Wed, 27 Sep 2006 18:20:00 -0000 Message-Id: <1159381222.9768.43.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-09/txt/msg00193.txt.bz2 On Wed, 2006-09-27 at 18:15 +0200, Jan Kratochvil wrote: > Hi, > > `x/x $ebx' on gdb/amd64 debugging inferior/i386 causes Cannot access memory at > address 0xffffce70 (or so) as $ebx is considered `int' and sign-extended to > 64-bit while the resulting address 0xffffffffffffce70 fails to be accessed. > > $esp does not exhibit this problem as it is `builtin_type_void_data_ptr' not > `builtin_type_int' as $ebx is. Therefore it gets extended as unsigned. > > Simulate the part of paddress(); it is questionable how deep in the functions > calling stack the address width cut should be. Yes, but I think the assumption is that esp is most commonly used to hold an address, while ebx is most commonly used to hold an integer. Hence the default types. I would tend to say that what the user should do is use an explicit cast. As is, he is using an implicit cast and not getting what he expects. > > As bugreported by John Reiser : > > When debugging a 32-bit executable on x86_64, gdb does not allow examining the stack if pointed to by a non-$esp register. For example, > -----foo.S > _start: .globl _start > nop > int3 > movl %esp,%ebx > int3 # examining memory from $ebx fails, from $esp succeeds > nop > nop > ----- > $ gcc -m32 -o foo -nostartfiles -nostdlib foo.S > $ gdb foo > Program received signal SIGTRAP, Trace/breakpoint trap. > 0x08048076 in _start () > (gdb) x/i $pc > 0x8048076 <_start+2>: mov %esp,%ebx > (gdb) stepi > 0x08048078 in _start () > (gdb) x/x $esp > 0xffffce70: 0x00000001 > (gdb) x/x $ebx > 0xffffce70: Cannot access memory at address 0xffffce70 > (gdb) x/x 0xffffce70 > 0xffffce70: 0x00000001 > > Expected Results: "x/x $ebx" should have succeeded, too, when %ebx has the > same value as %esp and examining from $esp works.