Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Iru Cai via Gdb <gdb@sourceware.org>
To: gdb@sourceware.org
Subject: How to handle different sizes of pointers in GDB?
Date: Mon, 19 Aug 2024 18:20:35 +0800	[thread overview]
Message-ID: <CANL=iQTqr=W3Q+nHLtqt26onquKqV6_0tsmcbgBJM4Tt_DBM-w@mail.gmail.com> (raw)

Hi,

I'm porting GDB to a new architecture. Now the application for this
architecture has two kinds of pointers in different sizes, one is 32-bit
and one is 64-bit. I have done the following things:

1. I use set_gdbarch_addr_bit(gdbarch,64) and
set_gdbarch_ptr_bit(gdbarch,64) to set both the addresses and the pointers
64-bit.
2. I tried to add a DW_AT_byte_size and DW_AT_address_class information
under each of the pointer type with DW_TAG_pointer_type in the compiler for
my new architecture.

My program can be like this:

int strlen32(const char *s) { /* s is 32-bit ... */ }
int strlen64(const _PTR64 char *s) { /* s is 64-bit ... */ }

However, GDB doesn't seem to get the correct type when printing the frame
arguments in read_frame_arg(), when I debug into strlen32, GDB can make the
GDB server crash because GDB is trying to read from a 64-bit address, which
it thinks is the value of s. And when I debug this GDB read_frame_arg(), I
see the type length of s in strlen32 is still 8 bytes.

So is there anything missing to make GDB use the type length information
from the DWARF debugging info?

Regards,
Iru

             reply	other threads:[~2024-08-19 10:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-19 10:20 Iru Cai via Gdb [this message]
2024-08-19 10:42 ` Luis Machado via Gdb
2024-08-21  1:51   ` Iru Cai via Gdb

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='CANL=iQTqr=W3Q+nHLtqt26onquKqV6_0tsmcbgBJM4Tt_DBM-w@mail.gmail.com' \
    --to=gdb@sourceware.org \
    --cc=vimacs.hacks@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