From mboxrd@z Thu Jan 1 00:00:00 1970 From: Orjan Friberg To: gdb-patches@sources.redhat.com Subject: Hardware watchpoints; dealing with false triggers? Date: Thu, 29 Nov 2001 06:25:00 -0000 Message-id: <3C064547.93F40E8D@axis.com> X-SW-Source: 2001-11/msg00556.html I'm wondering how/if gdb deals with false hardware watchpoint triggers. Depending on how your hardware watchpoints are implemented, you could run the risk of having to watch a larger area than what the watched variable actually occupies in memory. I've looked at the i386 hardware watchpoint implementation in gdb, and read chapter 15 of the Intel Architecture Software Developer's Manual Volume 3 about the debug registers, but I can't tell if it's susceptible to false triggers. The i386 breakpoint registers can only deal with 1, 2, and 4-byte sized areas, so watching a 4-byte aligned 3-byte struct seems to use two of the i386's debug registers (watching 2 and 1 bytes, respectively). But consider the following: say your watchpoint registers can only watch 4-byte aligned areas of 4 bytes, but you want to rwatch (or awatch) an unaligned variable of size 4 bytes. You'd have to use two watchpoint registers, both covering too much, like this: Variable to watch: | 0 1 2 3 | Watchpoints: | 0 1 2 3 | 0 1 2 3 | wp1 wp2 Now, say a there's a read of wp1's byte 0. The hardware would trigger, but it would be a false trigger. Gdb would somehow have to find out the actual address that was read and if it was found to be outside of the variable's range it would not trigger the watchpoint. (For the current write watchpoint implementation in gdb, false triggers wouldn't be a problem, since the value of the variable wouldn't change.) I guess some new target hooks could be needed, but besides that: are there any major obstacles for implementing such target-dependent false trigger handling in gdb? -- Orjan Friberg Axis Communications AB From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19301 invoked by alias); 29 Nov 2001 14:25:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.cygnus.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 19260 invoked from network); 29 Nov 2001 14:25:13 -0000 Received: from unknown (HELO krynn.axis.se) (193.13.178.10) by hostedprojects.ges.redhat.com with SMTP; 29 Nov 2001 14:25:13 -0000 Received: from ironmaiden.axis.se (ironmaiden.axis.se [10.13.8.120]) by krynn.axis.se (8.12.1/8.12.1/Debian -2) with ESMTP id fATEPBCJ021727 for ; Thu, 29 Nov 2001 15:25:11 +0100 Received: from axis.com (localhost [127.0.0.1]) by ironmaiden.axis.se (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id PAA17239 for ; Thu, 29 Nov 2001 15:25:11 +0100 X-Authentication-Warning: ironmaiden.axis.se: Host localhost [127.0.0.1] claimed to be axis.com Message-ID: <3C064547.93F40E8D@axis.com> Date: Mon, 19 Nov 2001 11:58:00 -0000 From: Orjan Friberg Organization: Axis Communications AB X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.19 i686) X-Accept-Language: en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: Hardware watchpoints; dealing with false triggers? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2001-11/txt/msg00341.txt.bz2 Message-ID: <20011119115800.BuGQNjDSAwASX0cMSDVzUrjvcsEErceSqYl2ECeM648@z> I'm wondering how/if gdb deals with false hardware watchpoint triggers. Depending on how your hardware watchpoints are implemented, you could run the risk of having to watch a larger area than what the watched variable actually occupies in memory. I've looked at the i386 hardware watchpoint implementation in gdb, and read chapter 15 of the Intel Architecture Software Developer's Manual Volume 3 about the debug registers, but I can't tell if it's susceptible to false triggers. The i386 breakpoint registers can only deal with 1, 2, and 4-byte sized areas, so watching a 4-byte aligned 3-byte struct seems to use two of the i386's debug registers (watching 2 and 1 bytes, respectively). But consider the following: say your watchpoint registers can only watch 4-byte aligned areas of 4 bytes, but you want to rwatch (or awatch) an unaligned variable of size 4 bytes. You'd have to use two watchpoint registers, both covering too much, like this: Variable to watch: | 0 1 2 3 | Watchpoints: | 0 1 2 3 | 0 1 2 3 | wp1 wp2 Now, say a there's a read of wp1's byte 0. The hardware would trigger, but it would be a false trigger. Gdb would somehow have to find out the actual address that was read and if it was found to be outside of the variable's range it would not trigger the watchpoint. (For the current write watchpoint implementation in gdb, false triggers wouldn't be a problem, since the value of the variable wouldn't change.) I guess some new target hooks could be needed, but besides that: are there any major obstacles for implementing such target-dependent false trigger handling in gdb? -- Orjan Friberg Axis Communications AB