From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 396 invoked by alias); 12 Jan 2007 11:42:40 -0000 Received: (qmail 388 invoked by uid 22791); 12 Jan 2007 11:42:40 -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 11:42:34 +0000 Received: from localhost (localhost [127.0.0.1]) by sophia.inria.fr (8.13.8/8.13.4) with ESMTP id l0CBgVNX020357 for ; Fri, 12 Jan 2007 12:42:31 +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 l0CBfRkS020020 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Fri, 12 Jan 2007 12:41:27 +0100 Subject: placing a breakpoint at a physical address on x86 with gdb From: Mathieu Lacage To: gdb@sourceware.org Content-Type: text/plain Date: Fri, 12 Jan 2007 11:42:00 -0000 Message-Id: <1168602087.2789.35.camel@garfield.inria.fr> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 (2.6.3-1.fc5.5) Content-Transfer-Encoding: 7bit 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 12:41:27 +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/msg00207.txt.bz2 hi, I would like to place a breakpoint at a physical address only within a single process: the idea is that I would like to be able to place a single breakpoint to catch every call to a given function which could be mapped at different virtual addresses within a single process. As far as I can tell, x86 debug registers are of no help since they are specified to interpret the breakpoint address before any virtual to physical address translation happens. So, I would need to place multiple local breakpoints, one for each address at which my function is mapped. Another way would be to map my function multiple times in memory but manage to mark each mapping to shared the same underlying physical memory and then insert an int3 breakpoint in the underlying physical memory. However, I do not see any way to do this with the existing mmap syscall: its MAP_PRIVATE flag will make each mapping independent of the others (which is not what I want) while its MAP_SHARED will potentially modify the underlying file when I insert the int3. 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. Is there anyone who could think of other, simpler, alternatives ? Mathieu --