From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14793 invoked by alias); 28 Dec 2009 21:22:03 -0000 Received: (qmail 14784 invoked by uid 22791); 28 Dec 2009 21:22:02 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-qy0-f180.google.com (HELO mail-qy0-f180.google.com) (209.85.221.180) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 28 Dec 2009 21:21:56 +0000 Received: by qyk10 with SMTP id 10so5740127qyk.12 for ; Mon, 28 Dec 2009 13:21:54 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.116.140 with SMTP id m12mr6544290qcq.54.1262035314172; Mon, 28 Dec 2009 13:21:54 -0800 (PST) In-Reply-To: <20091224215217.GA32721@host0.dyn.jankratochvil.net> References: <26eb53620912241247i718992d6i422451f4b7f9931@mail.gmail.com> <20091224210825.GA29926@host0.dyn.jankratochvil.net> <26eb53620912241341w30a924afxf90f66166b8c552b@mail.gmail.com> <20091224215217.GA32721@host0.dyn.jankratochvil.net> From: Aravinda Date: Mon, 28 Dec 2009 21:22:00 -0000 Message-ID: <26eb53620912281321k3fe1ee7dy9fcdc8bdff69cd4b@mail.gmail.com> Subject: Re: Problem with manual watchpoints To: Jan Kratochvil Cc: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 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: 2009-12/txt/msg00171.txt.bz2 Hi Jan, Thanks again for the reply. When I tried with -O0, i found that, the same program got the breakpoint exception. But there were also times when it just ran to completion too. I then went back to the -O2 and ran the compiled program several times and found that, even with -O2, the breakpoint exception occurs sometimes and does not occur at other times. Reading about debug registers and breakpoint exception, I came across this "When using data breakpoints it is recommended that either the LE or GE bit of DR7 be set also. If either LE or GE is set, any data breakpoint trap is reported exactly after completion of the instruction that accessed the specified memory item. This exact reporting is accomplished by forcing the 80386 execution unit to wait for completion of data operand transfers before beginning execution of the next instruction. If neither GE nor LE is set, data breakpoints may not be reported until one instruction after the data is accessed or may not be reported at all." Which means, Im just having some trouble with exact reporting of the exception I guess. Inspite of having both LE and GE set, the behaviour is random. Could it be possible for a processor with debug registers to not support exact reporting or could there be problems since Im working on a VM ? Thanks, Aravinda On Thu, Dec 24, 2009 at 4:52 PM, Jan Kratochvil wrote: > On Thu, 24 Dec 2009 22:41:37 +0100, Aravinda wrote: >> Yes, thats why I have a watchpoint added at &a[20]. So on accessing >> the first element out of the allocated array, I want the program to >> receive a SIGTRAP. > > Ah, OK. > >> Infact it gets this signal when the getc(stdin) is included, is it >> something to do with the program should be in single step mode to get >> SIGTRAPs > > No. > >> or is the loop way too simple that it executes in no time before the SIGTRAP >> is even raised ? > > There may be some compiler optimization in effect such as if you have not used > "volatile" keyword for the "a" array. You should rather check the code using > "objdump -dS" or GDB "disass/m" how it got compiled. > > Still (with default -O0) I do not know the answer. > > > Regards, > Jan >