From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: [RFC] problem with read_memory_string (reads 8 bytes at a time)
Date: Wed, 08 Apr 2009 18:27:00 -0000 [thread overview]
Message-ID: <20090408182650.GE7535@adacore.com> (raw)
Hello,
I did what I thought would be a nice cleanup in ada-lang.c last weekend,
by deleting a local function (extract_string), and replacing it by a call
to read_memory_string instead. This works fine most of the time, but
nightly testing did reveal a problem with that function on powerpc-elf.
(gdb) start
Cannot access memory at address 0x1002e8
Here is what happens:
1. The "start" commands needs to know that the name of the "main"
program is. As a result, we call ada_main_name, which finds
the symbol that points us to the string containing that main
name.
2. To read that name, we call read_memory_string now, and this
routine performs strings reads 8 bytes at a time.
The problem is that our string is at the end of our .rodata section.
The string is 8 bytes long, and sits at 0x1002e0. The .rodata section
ends at 0x001102ec. So here's what we end up doing:
a. Read 8 bytes from 0x1002e0 - no problem.
But we haven't read the \0 yet, so we keep going.
b. Read 8 bytes from 0x1002e0 + 8 = 0x1002e8:
i. The section ends at 0x001102ec, so bfd returns only 4 bytes read.
ii. We find out that only 4 bytes were read, so we still need to
read another 4 bytes for the 8byte read to be complete
iii. the next 4byte read doesn't find a section from which to
read the 4bytes, and so returns 0 signifying an error.
I don't really know how to fix this issue except by reading the string
one byte at a time :-(. Any suggestion?
Thanks,
--
Joel
next reply other threads:[~2009-04-08 18:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-08 18:27 Joel Brobecker [this message]
2009-04-08 19:01 ` Thiago Jung Bauermann
2009-04-08 21:26 ` Joel Brobecker
2009-04-08 22:18 ` Thiago Jung Bauermann
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=20090408182650.GE7535@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/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