From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10363 invoked by alias); 30 May 2011 16:05:15 -0000 Received: (qmail 10349 invoked by uid 22791); 30 May 2011 16:05:13 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-qw0-f41.google.com (HELO mail-qw0-f41.google.com) (209.85.216.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 May 2011 16:04:59 +0000 Received: by qwa26 with SMTP id 26so2468554qwa.0 for ; Mon, 30 May 2011 09:04:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.73.33 with SMTP id o33mr3498313qcj.294.1306771498826; Mon, 30 May 2011 09:04:58 -0700 (PDT) Received: by 10.229.188.76 with HTTP; Mon, 30 May 2011 09:04:58 -0700 (PDT) Date: Mon, 30 May 2011 16:05:00 -0000 Message-ID: Subject: Addition of a special memory reading command From: Tomas Martinec To: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-05/txt/msg00137.txt.bz2 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 #include #include #include 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