From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17621 invoked by alias); 10 Mar 2011 12:18:15 -0000 Received: (qmail 17608 invoked by uid 22791); 10 Mar 2011 12:18:13 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_TD X-Spam-Check-By: sourceware.org Received: from mail-iy0-f169.google.com (HELO mail-iy0-f169.google.com) (209.85.210.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 Mar 2011 12:18:08 +0000 Received: by iyf13 with SMTP id 13so1990065iyf.0 for ; Thu, 10 Mar 2011 04:18:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.42.66.7 with SMTP id n7mr10193819ici.20.1299759486267; Thu, 10 Mar 2011 04:18:06 -0800 (PST) Received: by 10.42.163.7 with HTTP; Thu, 10 Mar 2011 04:18:06 -0800 (PST) In-Reply-To: <20110310103409.GA29242@host1.jankratochvil.net> References: <20110310081154.GA13603@host1.jankratochvil.net> <20110310103409.GA29242@host1.jankratochvil.net> Date: Thu, 10 Mar 2011 12:18:00 -0000 Message-ID: Subject: Re: Why no hwatch command in gdb ? From: robert song 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: 2011-03/txt/msg00073.txt.bz2 Hi, Jan, On 3/10/11, Jan Kratochvil wrote: > GNU gdb (GDB) 7.2.50.20110310-cvs > This GDB was configured as "x86_64-unknown-linux-gnu". > (gdb) watch gdb_stdout > Hardware watchpoint 2: gdb_stdout > (gdb) watch gdb_stderr > Hardware watchpoint 3: gdb_stderr > (gdb) watch gdb_stdlog > Hardware watchpoint 4: gdb_stdlog > (gdb) watch gdb_stdin > Hardware watchpoint 5: gdb_stdin > (gdb) watch gdb_stdtargin > Hardware watchpoint 6: gdb_stdtargin > (gdb) continue > Continuing. > Warning: > Could not insert hardware watchpoint 5. > Could not insert hardware breakpoints: > You may have requested too many hardware breakpoints/watchpoints. > (gdb) Well, I am confused with the gdb hardware watchpoint support in x86 arch. I tested it in a ARM board. Now the kernel can support up to 1 hardware watchpoint and 6 hardware breakpoints. (gdb) hbreak main No hardware breakpoint support in the target. (gdb) b main Breakpoint 2 at 0x8364: file /tmp/helloworld.c, line 7. (gdb) run Starting program: /tmp/helloworld Breakpoint 2, main () at /tmp/helloworld.c:7 7 i=1; (gdb) watch i Hardware watchpoint 3: i (gdb) watch i Watchpoint 4: i (gdb) hbreak 8 Hardware assisted breakpoint 5 at 0x8370: file /tmp/helloworld.c, line 8. (gdb) hbreak 9 Hardware assisted breakpoint 6 at 0x837c: file /tmp/helloworld.c, line 9. (gdb) hbreak 10 Hardware assisted breakpoint 7 at 0x8388: file /tmp/helloworld.c, line 10. (gdb) hbreak 11 Hardware assisted breakpoint 8 at 0x8394: file /tmp/helloworld.c, line 11. (gdb) hbreak 12 Hardware assisted breakpoint 9 at 0x83a0: file /tmp/helloworld.c, line 12. (gdb) hbreak 13 Hardware assisted breakpoint 10 at 0x83ac: file /tmp/helloworld.c, line 13. (gdb) hbreak 14 Hardware breakpoints used exceeds limit. (gdb) hbreak 15 Hardware breakpoints used exceeds limit. Firstly, before the program run, we can not set the hardware breakpoint. For gdb use ptrace to get the debug register information, and thread id is needed. hardware watchpoint can only be set to 1, and hardware breakpoint can be set to 6. If more than 6, gdb will complain with "Hardware breakpoints used exceeds limit." So I think it works fine in the arm arch. But in x86, I took a look at my CentOS 5.5 7.0.1-23.el5. We can set the hardware breakpoint before program runs, it's not the standard gdb function. There is a patch named gdb-bz541866-rwatch-before-run.patch, in the patch, target_can_use_hardware_watchpoint is forced to be 1. --- /dev/null +++ b/gdb/config/ia64/nm-linux.h @@ -0,0 +1,28 @@ +/* Native support for GNU/Linux ia64. + + Copyright 2010 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef NM_LINUX_H +#define NM_LINUX_H + +#include "config/nm-linux.h" + +/* Red Hat backward compatibility with gdb-6.8. */ +#define target_can_use_hardware_watchpoint(type, cnt, ot) 1 + +#endif /* NM_LINUX_H */ --- a/gdb/target.h +++ b/gdb/target.h @@ -1257,8 +1257,10 @@ extern char *normal_pid_to_str (ptid_t ptid); bp_hardware_breakpoint. CNT is the number of such watchpoints used so far (including this one?). OTHERTYPE is who knows what... */ +#ifndef target_can_use_hardware_watchpoint #define target_can_use_hardware_watchpoint(TYPE,CNT,OTHERTYPE) \ (*current_target.to_can_use_hw_breakpoint) (TYPE, CNT, OTHERTYPE); +#endif So the problem is because of the previous patch of this distribution ????? Regards, robert