From: "rtainewbie" <rtainewbie@libero.it>
To: "gdb" <gdb@sources.redhat.com>
Subject: gdb + mmap + /dev/mem
Date: Fri, 01 Apr 2005 16:41:00 -0000 [thread overview]
Message-ID: <IEA10O$5C11B39B82AF59A7BD34617F4F6C3DE1@libero.it> (raw)
[-- Attachment #1: Type: text/plain, Size: 816 bytes --]
I am trying to debug a simple application running on GNU-Linux kernel 2.6.8.1
(see attachment).
This application works in a memory region not visible for linux (parameter
mem=XXX at boot time).
I map this region using mmap on /dev/mem device as root user.
When I debug it, accessing pointer to this region, the system freezes. So reboot
is necessary and no debug is possible.
The application work correcty but the only solution for debug it is running a
concurrent application that writes the content of this memory region using printf.
Does anybody know an easier and more confortable solution.
Thanks a lot.
____________________________________________________________
Navighi a 2 MEGA e i primi 3 mesi sono GRATIS.
Scegli Libero Adsl Flat senza limiti su http://www.libero.it
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mem.c --]
[-- Type: text/x-csrc; name="mem.c", Size: 699 bytes --]
#include<stdio.h>
#include <sys/mman.h>
#include <syscall.h>
#include <errno.h>
int main()
{
int fd,i;
unsigned char * mem1, *mem2;
const int size = 2 * 1024 * 1024;
unsigned long addrphys = 254 * 1024 * 1024;
mlockall(MCL_CURRENT| MCL_FUTURE);
if ((fd = open("/dev/mem", 02) ) < 0)
{
printf("can't open /dev/mem \n");
exit (-1);
}
mem1 = (unsigned char *) mmap((void *)0,size ,PROT_READ | PROT_WRITE,MAP_SHARED , fd, addrphys);
if (mem1)
memset(mem1,0, size-1);
printf("%d",(int) mem1);
if (mem1)
{
for (i=0; i < (size-1); i++)
{
printf("%x ", *(mem1 +i));
}
printf("\n\r");
}
munmap((void *)mem1,size );
close(fd);
}
next reply other threads:[~2005-04-01 16:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-01 16:41 rtainewbie [this message]
2005-04-01 17:21 ` Daniel Jacobowitz
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='IEA10O$5C11B39B82AF59A7BD34617F4F6C3DE1@libero.it' \
--to=rtainewbie@libero.it \
--cc=gdb@sources.redhat.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