From: Tomas Martinec <fyzmat@gmail.com>
To: gdb@sourceware.org
Subject: Addition of a special memory reading command
Date: Mon, 30 May 2011 16:05:00 -0000 [thread overview]
Message-ID: <BANLkTi=rs+62oeC3X5qV_C=HCRYrSTQpZg@mail.gmail.com> (raw)
Hello,
I am developing an Eclipse plugin for my virtual machine and I have
encountered some problems with displaying memory of the debuggee.
Address space of my debuggee can contain holes (which are not page
aligned and generally can have any size) and reading such a memory
causes troubles. For example, lets consider that the memory at
addresses 0x10000000-0x10000004 is valid and the neighbourhood is not
valid. Then gdb that is ordered to read 20 bytes of memory from
address 0x0ffffff0 will not show the last valid bytes.
So, if the programmer (or the gdb frontend) wants to get the real
memory contents in this case, he must read the memory for each
interested address until he find a valid memory block.
I can understand that my case is rather special, but it can happen in
usual C userspace application too. If the memory page at address
0x0010000 is mapped and the previous one is not mapped, reading 100
bytes from the address 0x000fffff fails. This issue can be illustrated
on the following source code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
int main(void) {
void* address = (void*) 0x00100000;
char* allocated_address = (char*) mmap(address,
4092,
PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS,
-1,
0
);
strcpy(allocated_address, "testing string");
return EXIT_SUCCESS;
}
I think that having a special memory command would solve this. The
command would ask the virtual machine about the next valid block of
memory from the provided address. If the programmer encounters "Cannot
access memory at address ..." during examining the memory, he can use
the proposed command to ensure that the memory really is not valid or
to find out that the valid memory begins from an address X. My VM can
provide such information to gdb and, for the userspace scenario, I can
imagine that an operating system would be able to get the info from
page tables.
Probably I will be able to write a patch to gdb that implements the
command. The patch would create the command and implement it in the
remote protocol - for other targets it would just print "not
supported". However, I doubt that the Eclipse CDT community would
accept changes related to the proposed command until the command is
accepted into gdb. And keeping the patches for both gdb and CDT does
not seem to be fortunate to me.
So, how do you like the proposed command? Might it be possible to
integrate it to the future version of gdb?
Regards,
Tomas
next reply other threads:[~2011-05-30 16:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-30 16:05 Tomas Martinec [this message]
2011-05-30 19:44 ` Petr Hluzín
2011-06-01 16:35 ` Tomas Martinec
2011-06-01 19:05 ` Petr Hluzín
2011-06-01 19:23 ` Tomas Martinec
2011-06-10 18:25 ` Tomas Martinec
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='BANLkTi=rs+62oeC3X5qV_C=HCRYrSTQpZg@mail.gmail.com' \
--to=fyzmat@gmail.com \
--cc=gdb@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