From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11404 invoked by alias); 5 Apr 2002 02:48:01 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 11381 invoked from network); 5 Apr 2002 02:47:58 -0000 Received: from unknown (HELO cygnus.com) (205.180.230.5) by sources.redhat.com with SMTP; 5 Apr 2002 02:47:58 -0000 Received: from reddwarf.cygnus.com (notinuse.cygnus.com [205.180.231.12]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id SAA23614; Thu, 4 Apr 2002 18:47:56 -0800 (PST) Received: (from msnyder@localhost) by reddwarf.cygnus.com (8.11.2/8.11.2) id g352aUC24365; Thu, 4 Apr 2002 18:36:30 -0800 Date: Thu, 04 Apr 2002 18:48:00 -0000 From: Michael Snyder Message-Id: <200204050236.g352aUC24365@reddwarf.cygnus.com> To: gdb-patches@sources.redhat.com Subject: [PATCH] Support HW breakpoints in overlays. Cc: cagney@redhat.com X-SW-Source: 2002-04/txt/msg00149.txt.bz2 Tested with Z0, Z1, and memory/trap breakpoints, remote protocol and target sim. 2002-04-04 Michael Snyder * breakpoint.c: Add support for hardware breakpoints in overlays. (overlay_events_enabled): New state variable. (insert_breakpoints): Use overlay_events_enabled to decide whether to attempt to set a breakpoint at the overlay load addr. Handle bp_hardware_breakpoint as well as bp_breakpoint. (remove_breakpoint): Use overlay_events_enabled to decide whether breakpoints need to be removed from overlay load addr. Handle bp_hardware_breakpoint as well as bp_breakpoint. (bpstat_stop_status): Handle bp_hardware_breakpoint in overlays. (create_overlay_event_breakpoint, enable_overlay_breakpoints, disable_overlay_breakpoints): Update overlay_events_enabled. Index: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.68 diff -p -r1.68 breakpoint.c *** breakpoint.c 2002/03/28 01:35:55 1.68 --- breakpoint.c 2002/04/05 02:29:45 *************** extern int addressprint; /* Print machin *** 217,222 **** --- 217,225 ---- /* Are we executing breakpoint commands? */ static int executing_breakpoint_commands; + /* Are overlay event breakpoints enabled? */ + static int overlay_events_enabled; + /* Walk the following statement or block through all breakpoints. ALL_BREAKPOINTS_SAFE does so even if the statment deletes the current breakpoint. */ *************** insert_breakpoints (void) *** 735,767 **** && !b->inserted && !b->duplicate) { ! if (b->type == bp_hardware_breakpoint) ! val = target_insert_hw_breakpoint (b->address, b->shadow_contents); else { ! /* Check to see if breakpoint is in an overlay section; ! if so, we should set the breakpoint at the LMA address. ! Only if the section is currently mapped should we ALSO ! set a break at the VMA address. */ ! if (overlay_debugging && b->section ! && section_is_overlay (b->section)) { ! CORE_ADDR addr; ! ! addr = overlay_unmapped_address (b->address, b->section); ! val = target_insert_breakpoint (addr, b->shadow_contents); ! /* This would be the time to check val, to see if the ! breakpoint write to the load address succeeded. ! However, this might be an ordinary occurrance, eg. if ! the unmapped overlay is in ROM. */ ! val = 0; /* in case unmapped address failed */ ! if (section_is_mapped (b->section)) val = target_insert_breakpoint (b->address, b->shadow_contents); } ! else /* ordinary (non-overlay) address */ ! val = target_insert_breakpoint (b->address, b->shadow_contents); } if (val) { /* Can't set the breakpoint. */ --- 738,802 ---- && !b->inserted && !b->duplicate) { ! /* "Normal" instruction breakpoint: either the standard ! trap-instruction bp (bp_breakpoint), or a ! bp_hardware_breakpoint. */ ! ! /* First check to see if we have to handle an overlay. */ ! if (overlay_debugging == ovly_off ! || b->section == NULL ! || !(section_is_overlay (b->section))) ! { ! /* No overlay handling: just set the breakpoint. */ ! ! if (b->type == bp_hardware_breakpoint) ! val = target_insert_hw_breakpoint (b->address, ! b->shadow_contents); ! else ! val = target_insert_breakpoint (b->address, b->shadow_contents); ! } else { ! /* This breakpoint is in an overlay section. ! Shall we set a breakpoint at the LMA? */ ! if (!overlay_events_enabled) { ! /* Yes -- overlay event support is not active, ! so we must try to set a breakpoint at the LMA. ! This will not work for a hardware breakpoint. */ ! if (b->type == bp_hardware_breakpoint) ! warning ("hw breakpoint %d not supported in overlay!\n", ! b->number); ! else ! { ! CORE_ADDR addr = overlay_unmapped_address (b->address, ! b->section); ! /* Set a software (trap) breakpoint at the LMA. */ ! val = target_insert_breakpoint (addr, b->shadow_contents); ! if (val != 0) ! warning ("overlay breakpoint %d failed: in ROM?", ! b->number); ! } ! } ! /* Shall we set a breakpoint at the VMA? */ ! if (section_is_mapped (b->section)) ! { ! /* Yes. This overlay section is mapped into memory. */ ! if (b->type == bp_hardware_breakpoint) ! val = target_insert_hw_breakpoint (b->address, ! b->shadow_contents); ! else val = target_insert_breakpoint (b->address, b->shadow_contents); } ! else ! { ! /* No. This breakpoint will not be inserted. ! No error, but do not mark the bp as 'inserted'. */ ! continue; ! } } + if (val) { /* Can't set the breakpoint. */ *************** remove_breakpoint (struct breakpoint *b, *** 1266,1297 **** && b->type != bp_catch_catch && b->type != bp_catch_throw) { ! if (b->type == bp_hardware_breakpoint) ! val = target_remove_hw_breakpoint (b->address, b->shadow_contents); else { ! /* Check to see if breakpoint is in an overlay section; ! if so, we should remove the breakpoint at the LMA address. ! If that is not equal to the raw address, then we should ! presumably remove the breakpoint there as well. */ ! if (overlay_debugging && b->section ! && section_is_overlay (b->section)) { ! CORE_ADDR addr; ! ! addr = overlay_unmapped_address (b->address, b->section); ! val = target_remove_breakpoint (addr, b->shadow_contents); ! /* This would be the time to check val, to see if the ! shadow breakpoint write to the load address succeeded. ! However, this might be an ordinary occurrance, eg. if ! the unmapped overlay is in ROM. */ ! val = 0; /* in case unmapped address failed */ ! if (section_is_mapped (b->section)) val = target_remove_breakpoint (b->address, b->shadow_contents); } ! else /* ordinary (non-overlay) address */ ! val = target_remove_breakpoint (b->address, b->shadow_contents); } if (val) return val; --- 1301,1361 ---- && b->type != bp_catch_catch && b->type != bp_catch_throw) { ! /* "Normal" instruction breakpoint: either the standard ! trap-instruction bp (bp_breakpoint), or a ! bp_hardware_breakpoint. */ ! ! /* First check to see if we have to handle an overlay. */ ! if (overlay_debugging == ovly_off ! || b->section == NULL ! || !(section_is_overlay (b->section))) ! { ! /* No overlay handling: just remove the breakpoint. */ ! ! if (b->type == bp_hardware_breakpoint) ! val = target_remove_hw_breakpoint (b->address, ! b->shadow_contents); ! else ! val = target_remove_breakpoint (b->address, b->shadow_contents); ! } else { ! /* This breakpoint is in an overlay section. ! Did we set a breakpoint at the LMA? */ ! if (!overlay_events_enabled) ! { ! /* Yes -- overlay event support is not active, so we ! should have set a breakpoint at the LMA. Remove it. ! */ ! CORE_ADDR addr = overlay_unmapped_address (b->address, ! b->section); ! /* Ignore any failures: if the LMA is in ROM, we will ! have already warned when we failed to insert it. */ ! if (b->type != bp_hardware_breakpoint) ! target_remove_hw_breakpoint (addr, b->shadow_contents); ! else ! target_remove_breakpoint (addr, b->shadow_contents); ! } ! /* Did we set a breakpoint at the VMA? ! If so, we will have marked the breakpoint 'inserted'. */ ! if (b->inserted) { ! /* Yes -- remove it. Previously we did not bother to ! remove the breakpoint if the section had been ! unmapped, but let's not rely on that being safe. We ! don't know what the overlay manager might do. */ ! if (b->type == bp_hardware_breakpoint) ! val = target_remove_hw_breakpoint (b->address, ! b->shadow_contents); ! else val = target_remove_breakpoint (b->address, b->shadow_contents); } ! else ! { ! /* No -- not inserted, so no need to remove. No error. */ ! val = 0; ! } } if (val) return val; *************** bpstat_stop_status (CORE_ADDR *pc, int n *** 2398,2406 **** continue; } ! if (b->type == bp_hardware_breakpoint ! && b->address != (*pc - DECR_PC_AFTER_HW_BREAK)) ! continue; /* Is this a catchpoint of a load or unload? If so, did we get a load or unload of the specified library? If not, --- 2462,2476 ---- continue; } ! if (b->type == bp_hardware_breakpoint) ! { ! if (b->address != (*pc - DECR_PC_AFTER_HW_BREAK)) ! continue; ! if (overlay_debugging /* unmapped overlay section */ ! && section_is_overlay (b->section) ! && !section_is_mapped (b->section)) ! continue; ! } /* Is this a catchpoint of a load or unload? If so, did we get a load or unload of the specified library? If not, *************** create_overlay_event_breakpoint (char *f *** 3824,3832 **** b->addr_string = xstrdup (func_name); if (overlay_debugging == ovly_auto) ! b->enable_state = bp_enabled; else ! b->enable_state = bp_disabled; } void --- 3894,3908 ---- b->addr_string = xstrdup (func_name); if (overlay_debugging == ovly_auto) ! { ! b->enable_state = bp_enabled; ! overlay_events_enabled = 1; ! } else ! { ! b->enable_state = bp_disabled; ! overlay_events_enabled = 0; ! } } void *************** enable_overlay_breakpoints (void) *** 3839,3844 **** --- 3915,3921 ---- { b->enable_state = bp_enabled; check_duplicates (b); + overlay_events_enabled = 1; } } *************** disable_overlay_breakpoints (void) *** 3852,3857 **** --- 3929,3935 ---- { b->enable_state = bp_disabled; check_duplicates (b); + overlay_events_enabled = 0; } }