Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* gdb + mmap + /dev/mem
@ 2005-04-01 16:41 rtainewbie
  2005-04-01 17:21 ` Daniel Jacobowitz
  0 siblings, 1 reply; 2+ messages in thread
From: rtainewbie @ 2005-04-01 16:41 UTC (permalink / raw)
  To: gdb

[-- 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);
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-04-01 17:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-01 16:41 gdb + mmap + /dev/mem rtainewbie
2005-04-01 17:21 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox