From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16365 invoked by alias); 25 Apr 2012 01:15:21 -0000 Received: (qmail 16357 invoked by uid 22791); 25 Apr 2012 01:15:20 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-ob0-f169.google.com (HELO mail-ob0-f169.google.com) (209.85.214.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 Apr 2012 01:15:07 +0000 Received: by obbeh20 with SMTP id eh20so2073763obb.0 for ; Tue, 24 Apr 2012 18:15:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.36.100 with SMTP id p4mr786394oej.42.1335316506672; Tue, 24 Apr 2012 18:15:06 -0700 (PDT) Received: by 10.182.179.35 with HTTP; Tue, 24 Apr 2012 18:15:06 -0700 (PDT) In-Reply-To: <4F96C2A7.2010206@mentor.com> References: <4F96A614.3040303@mentor.com> <4F96A812.4000008@mentor.com> <4F96B68C.3050703@mentor.com> <4F96C2A7.2010206@mentor.com> Date: Wed, 25 Apr 2012 01:15:00 -0000 Message-ID: Subject: Re: Hardware watchpoint for read From: Xin Tong To: "Gustavo, Luis" Cc: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 2012-04/txt/msg00204.txt.bz2 On Tue, Apr 24, 2012 at 11:11 AM, Luis Gustavo wr= ote: > On 04/24/2012 12:06 PM, Xin Tong wrote: >> >> On Tue, Apr 24, 2012 at 10:19 AM, Luis Gustavo >> =A0wrote: >>> >>> On 04/24/2012 11:17 AM, Xin Tong wrote: >>>> >>>> >>>> On Tue, Apr 24, 2012 at 9:18 AM, Luis Gustavo >>>> =A0wrote: >>>>> >>>>> >>>>> On 04/24/2012 10:15 AM, Xin Tong wrote: >>>>>> >>>>>> >>>>>> >>>>>> On Tue, Apr 24, 2012 at 9:09 AM, Luis Gustavo >>>>>> =A0wrote: >>>>>>> >>>>>>> >>>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> >>>>>>> On 04/24/2012 10:02 AM, Xin Tong wrote: >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> Hello >>>>>>>> >>>>>>>> I am wondering that can gdb insert hardware watch point for read to >>>>>>>> the watched memory ? can other debugger do that ? is it supported = in >>>>>>>> hardware watchpoint ? >>>>>>>> >>>>>>>> Thanks >>>>>>>> >>>>>>>> Xin >>>>>>>> >>>>>>> >>>>>>> Read watchpoints are hard to implement as soft-watchpoints, so >>>>>>> they're >>>>>>> usually implemented as hardware watchpoints. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> software write watchpoint is easier to implement ? do not software >>>>>> watchpoint need to watch all memory accesses (read and write) to a >>>>>> memory location in software ? >>>>> >>>>> >>>>> >>>>> >>>>> Writes are "easier" to implemenet due to the fact that they usually >>>>> change >>>>> memory contents. Reads don't. >>>> >>>> >>>> >>>> Either way, do not gdb need to instrument every memory accesses if a >>>> software watch point is used ? >>> >>> >>> >>> It does things lazily. It single-steps instruction-by-instruction and >>> checks >>> for change of contents. >> >> >> ok, i see. so it =A0does not dissasmble the instructions. =A0but for rea= d, >> it may need to disassemble the instructions which makes it harder to >> implement. > > > Yes, this is the problem with read watchpoints implemented as software > watchpoints. It's hard to determine a trigger without making it painfully > slow, and the debugger needs knowledge about the arch's instructions. > > >>> >>> >>>>> >>>>> >>>>>> >>>>>>> >>>>>>> If a debugger knows how to properly set the bits in the hardware, >>>>>>> either >>>>>>> through ptrace or other means, it can configure a >>>>>>> read/write/read-write >>>>>>> watchpoint. Depends on hardware support really. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> do you know whether this is supported on the x86 chips ? is thee a w= ay >>>>>> to try this out in gdb ? >>>>> >>>>> >>>>> >>>>> >>>>> All those modes should be supported in x86. Try "watch", "rwatch" and >>>>> "awatch". >>>> >>>> >>>> >>>> how are hardware watch, =A0rwatch and awatch implemented in gdb. make >>>> call to ptrace apis and ptrace apis =A0program some x86 registers >>>> through a driver interfaces ? >>>> >>> >>> ptrace calls really. GDB's x86 backend knows how to set those bits. what are the performance penalties of having a watchpoint on a memory location in the state of the art x86 processor. Because it might be implemented with a parallel circuitry in the processor, my guess is that it could be cheap. Xin >>> >>>>> >>>>>> >>>>>>> >>>>>>> Regards, >>>>>>> Luis >>>>> >>>>> >>>>> >>>>> >>> >