From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7510 invoked by alias); 12 Jan 2007 12:48:23 -0000 Received: (qmail 7492 invoked by uid 22791); 12 Jan 2007 12:48:22 -0000 X-Spam-Check-By: sourceware.org Received: from sophia.inria.fr (HELO sophia.inria.fr) (138.96.64.20) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 12 Jan 2007 12:48:16 +0000 Received: from localhost (localhost [127.0.0.1]) by sophia.inria.fr (8.13.8/8.13.4) with ESMTP id l0CCmDL7013890 for ; Fri, 12 Jan 2007 13:48:13 +0100 Received: from garfield.inria.fr (garfield.inria.fr [138.96.88.66]) (authenticated bits=0) by sophia.inria.fr (8.13.8/8.13.4) with ESMTP id l0CCm1Fo013736 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Fri, 12 Jan 2007 13:48:01 +0100 Subject: Re: placing a breakpoint at a physical address on x86 with gdb From: Mathieu Lacage To: gdb@sourceware.org In-Reply-To: <1168602087.2789.35.camel@garfield.inria.fr> References: <1168602087.2789.35.camel@garfield.inria.fr> Content-Type: multipart/mixed; boundary="=-PPk5CUYQaRObKmK2pfF+" Date: Fri, 12 Jan 2007 12:48:00 -0000 Message-Id: <1168606081.2789.38.camel@garfield.inria.fr> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 (2.6.3-1.fc5.5) X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (sophia.inria.fr [138.96.64.20]); Fri, 12 Jan 2007 13:48:01 +0100 (MET) 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: 2007-01/txt/msg00210.txt.bz2 --=-PPk5CUYQaRObKmK2pfF+ Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 397 On Fri, 2007-01-12 at 12:41 +0100, Mathieu Lacage wrote: > Yet another alternative would be to create a shared memory segment with > shm_open, copy the code of my function in there, create multiple memory > mappings with mmap (MAP_SHARED) on that shared memory segment and insert > an int3 in the shared memory segment whenever needed. and the attached test code demonstrates this. Mathieu -- --=-PPk5CUYQaRObKmK2pfF+ Content-Disposition: attachment; filename=test-mmap.c Content-Type: text/x-csrc; name=test-mmap.c; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 2046 #include #include #include #include #include #include #include #include #include #include #define BUFFER_SIZE (1024) int main (int argc, char *argv[]) { int file_fd, shm_fd; struct stat stat_buffer; char buffer[BUFFER_SIZE]; int retval; off_t left; file_fd = open ("./test-mmap.c", O_RDONLY); retval = fstat(file_fd, &stat_buffer); assert (retval != -1); shm_fd = shm_open ("my-test", O_RDWR | O_CREAT, S_IRWXU); assert (shm_fd != -1); retval = ftruncate (shm_fd, stat_buffer.st_size); assert (retval != -1); left = stat_buffer.st_size; while (left > 0) { off_t to_read; ssize_t actually_read; ssize_t actually_written; if (left > BUFFER_SIZE) { to_read = BUFFER_SIZE; } else { to_read = left; } actually_read = read (file_fd, buffer, to_read); assert (actually_read != -1); actually_written = write (shm_fd, buffer, actually_read); assert (actually_written == actually_read); left -= actually_read; } close (file_fd); printf ("done copying file to shared memory\n"); // Here, we have a shared memory segment which contains the content of our file. { void *map_one; void *map_two; char *one; char *two; map_one = mmap (0, stat_buffer.st_size, PROT_READ | PROT_EXEC | PROT_WRITE, MAP_SHARED, shm_fd, 0); assert (map_one != MAP_FAILED); map_two = mmap (0, stat_buffer.st_size, PROT_READ | PROT_EXEC | PROT_WRITE, MAP_SHARED, shm_fd, 0); assert (map_two != MAP_FAILED); one = map_one; two = map_two; printf ("one=%c\n", one[10]); printf ("two=%c\n", two[10]); one[10] = 'Y'; msync (map_one, stat_buffer.st_size, MS_SYNC); printf ("one=%c\n", one[10]); printf ("two=%c\n", two[10]); retval = munmap (map_one, stat_buffer.st_size); assert (retval != -1); retval = munmap (map_two, stat_buffer.st_size); assert (retval != -1); } return 0; } --=-PPk5CUYQaRObKmK2pfF+--