From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25915 invoked by alias); 17 Oct 2018 13:02:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 25898 invoked by uid 89); 17 Oct 2018 13:02:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2393 X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 Oct 2018 13:02:34 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w9HD2Rkq031674 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 17 Oct 2018 09:02:32 -0400 Received: by simark.ca (Postfix, from userid 112) id 8C1CD1EA70; Wed, 17 Oct 2018 09:02:27 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 501181E4C2; Wed, 17 Oct 2018 09:02:26 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 17 Oct 2018 13:02:00 -0000 From: Simon Marchi To: Denis Dmitriev Cc: gdb-patches@sourceware.org, =?UTF-8?Q?=D0=9F=D0=B0=D0=B2=D0=B5=D0=BB_?= =?UTF-8?Q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=D0=BE=D0=B2=D0=B8=D1=87_?= =?UTF-8?Q?=D0=94=D0=BE=D0=B2=D0=B3=D0=B0=D0=BB=D1=8E=D0=BA?= Subject: Re: [PATCH] Fix target architecture address size inside gdbarch structure In-Reply-To: References: <63523264fb0856e46a4846517945b6e4@polymtl.ca> Message-ID: <31ac4f285c9df308feed9948441b9d6e@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.6 X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg00365.txt.bz2 On 2018-10-17 07:33, Denis Dmitriev wrote: > hi! > > gcc --version > gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609 > Copyright (C) 2015 Free Software Foundation, Inc. > This is free software; see the source for copying conditions. There is > NO > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR > PURPOSE. > > uname -a > Linux heroboecPC 4.15.0-34-generic #37~16.04.1-Ubuntu SMP Tue Aug 28 > 10:44:06 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux > > > I took gdb 8.2.50.20180906-git (hash: > 739ab2e92e1840c9285f3cfce1f1236c0fa68730). > ./configure --host=x86_64-linux --target=mips64-linux-uclibc > make > After that, I start the debugger, install the architecture for > debugging. > set arch mips:octeon2 > tar rem :1234 (i have qemu with mips to connect) > disas $pc, $pc+20 > 0xbfc00000 in ?? () > (gdb) disas $pc, $pc+20 > Dump of assembler code from 0xbfc00000 to 0xbfc00014: > => 0xbfc00000: Cannot access memory at address 0xbfc00000 > > Address size is 32 bit instead of 64. Looking at the code, there is the mips ABI setting that comes into play, that's where the ptr size (and consequently the addr size): https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/mips-tdep.c;h=bf44c52f5d2ad73605cdfaabe1ac1d2bde822ef9;hb=HEAD#l8541 When loading a binary in GDB, it auto detects the ABI: $ ./gdb -q --data-directory=data-directory test Reading symbols from test... (No debugging symbols found in test) (gdb) show architecture The target architecture is set automatically (currently mips:isa64r2) (gdb) show mips abi The MIPS ABI is set automatically (currently "n64"). If you don't provide a binary to gdb, then you should probably set this to the right value: (gdb) set architecture mips:octeon2 The target architecture is assumed to be mips:octeon2 (gdb) show mips abi The MIPS ABI is set automatically (currently "o32"). (gdb) p sizeof(void*) $1 = 4 (gdb) set mips abi n64 (gdb) p sizeof(void*) $2 = 8 I don't know if it makes sense to have the architecture "mips:octeon2" along with a 32-bits ABI, I don't really know much about MIPS. If it doesn't, perhaps it would be possible to select a more sensible ABI by default when selecting that architecture. But for now, you have to select it by hand. Or if you can provide the binary to gdb, that's the ideal. Simon