Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Denis Dmitriev <zealot351@gmail.com>
Cc: gdb-patches@sourceware.org,
	"Павел Михаилович Довгалюк" <pavel.dovgaluk@ispras.ru>
Subject: Re: [PATCH] Fix target architecture address size inside gdbarch structure
Date: Wed, 17 Oct 2018 13:02:00 -0000	[thread overview]
Message-ID: <31ac4f285c9df308feed9948441b9d6e@polymtl.ca> (raw)
In-Reply-To: <CAF3nGXcexeqnq=B7LzK6M5+HiaVdodM4eXVwqLYz1f-o0VUAdQ@mail.gmail.com>

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


  reply	other threads:[~2018-10-17 13:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-16 12:04 Denis Dmitriev
2018-10-16 21:13 ` Simon Marchi
2018-10-17 11:33   ` Denis Dmitriev
2018-10-17 13:02     ` Simon Marchi [this message]
2018-10-17 14:35       ` Denis Dmitriev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31ac4f285c9df308feed9948441b9d6e@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=pavel.dovgaluk@ispras.ru \
    --cc=zealot351@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox