From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4118 invoked by alias); 11 Nov 2005 13:21:14 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 4106 invoked by uid 22791); 11 Nov 2005 13:21:12 -0000 Received: from zigzag.lvk.cs.msu.su (HELO zigzag.lvk.cs.msu.su) (158.250.17.23) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Fri, 11 Nov 2005 13:21:12 +0000 Received: from Debian-exim by zigzag.lvk.cs.msu.su with spam-scanned (Exim 4.50) id 1EaYq0-0003Xu-7K for gdb@sources.redhat.com; Fri, 11 Nov 2005 16:21:10 +0300 Received: from zigzag.lvk.cs.msu.su ([158.250.17.23]) by zigzag.lvk.cs.msu.su with esmtp (Exim 4.50) id 1EaYq0-0003Xp-57 for gdb@sources.redhat.com; Fri, 11 Nov 2005 16:21:04 +0300 From: Vladimir Prus To: gdb@sources.redhat.com Subject: read watchpoints broken with remote targets? Date: Fri, 11 Nov 2005 13:21:00 -0000 User-Agent: KMail/1.7.2 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200511111621.03372.ghost@cs.msu.su> X-SW-Source: 2005-11/txt/msg00227.txt.bz2 Hi, are read watchpoints supposed to work with remote targets? When I try to set read watchpoint with my custom remote server, even "next" does not work. Gdb sends "make a single asm step" command to remote server, server responds with "S.." packet (stopped), but gdb thinks it's read watchpoint that fired, turns off single stepping and reports read watchpoint. Here's exactly what happens: 1. handle_inferior_event (infrun.c) is called. 2. It contains: int stopped_by_watchpoint = -1; 3. The following code is executed: if (HAVE_CONTINUABLE_WATCHPOINT) stopped_by_watchpoint = STOPPED_BY_WATCHPOINT (ecs->ws); For remote targets, and for pretty much all other targets, HAVE_CONTINUABLE_WATCHPOINT is 0, so value of stopped_by_watchpoint is still -1 4. Function bpstat_stop_status (breakpoint.c) is called, and stopped_by_watchpoint is passed to it (the value is still -1). 5. bpstat_stop_status tries to create a list of stop reasons, by iterating over all breakpoints and trying to check if that's breakpoint that's fired. For read wathcpoints we arrive at this: if ((b->type == bp_hardware_watchpoint || b->type == bp_read_watchpoint || b->type == bp_access_watchpoint) && !stopped_by_watchpoint) continue; since stepped_by_watchpoint is -1 we continue with the loop body, and arrive at this: bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */ this adds a new element to the list of stop reasons. 6. We execute this code: if (!target_stopped_data_address (¤t_target, &addr)) continue; since there were no watchpoint, "continue" is executed. But the stop reasons list still has a new element corresponding to read watchpoint. 7. We return to handle_inhefiour_event, which notices the stop reasons list and stops stepping. I've fixed this by replacing code in (6) with: if (!target_stopped_data_address (¤t_target, &addr)) { bs->print_it = print_it_noop; bs->stop = 0; continue; } Could somebody comment if this is the right fix? BTW, HAVE_CONTINUABLE_WATCHPOINT is only set for x86, it seems, so read watchpoint might be broken for more targets then just remote. - Volodya