From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13503 invoked by alias); 23 Aug 2002 15:53:26 -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 13491 invoked from network); 23 Aug 2002 15:53:22 -0000 Received: from unknown (HELO tomago.toronto.redhat.com) (216.138.202.10) by sources.redhat.com with SMTP; 23 Aug 2002 15:53:22 -0000 Received: (from graces@localhost) by tomago.toronto.redhat.com (8.11.6/8.11.6) id g7NFrGX13966; Fri, 23 Aug 2002 11:53:16 -0400 Date: Fri, 23 Aug 2002 09:27:00 -0000 From: Grace Sainsbury To: Michael Snyder Cc: gdb-patches@sources.redhat.com Subject: Re: breakpoint error messages Message-ID: <20020823115315.A13713@tomago.toronto.redhat.com> References: <20020821142627.A10117@tomago.toronto.redhat.com> <3D655542.AF3065A0@redhat.com> <20020822173220.A12466@tomago.toronto.redhat.com> <3D656355.E623B495@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="W/nzBZO5zC0uMSeA" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <3D656355.E623B495@redhat.com>; from msnyder@redhat.com on Thu, Aug 22, 2002 at 03:19:01PM -0700 X-SW-Source: 2002-08/txt/msg00754.txt.bz2 --W/nzBZO5zC0uMSeA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 283 How about this? The memory_error is only relevant for memory breakpoints, and only insert_breakpoint returns an errno (the hardware and catcpoint functions return -1 on error)-- so the call to strerror prints the error when it is relevant, and so replaces print_sys_errmsg. grace --W/nzBZO5zC0uMSeA Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch Content-length: 6217 Index: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.81 diff -u -r1.81 breakpoint.c --- breakpoint.c 20 Aug 2002 20:03:35 -0000 1.81 +++ breakpoint.c 23 Aug 2002 15:49:45 -0000 @@ -715,10 +715,17 @@ int return_val = 0; /* return success code. */ int val = 0; int disabled_breaks = 0; - + int hw_breakpoint_error = 0; + static char message1[] = "Error inserting catchpoint %d:\n"; static char message[sizeof (message1) + 30]; + struct ui_file *tmp_error_stream = mem_fileopen (); + make_cleanup_ui_file_delete (tmp_error_stream); + + /* Explicitly mark the warning -- this will only be printed if + there was an error. */ + fprintf_unfiltered (tmp_error_stream, "Warning:\n"); ALL_BREAKPOINTS_SAFE (b, temp) { @@ -776,8 +783,9 @@ /* 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); + fprintf_unfiltered (tmp_error_stream, + "Overlay breakpoint %d failed: in ROM?", + b->number); } } /* Shall we set a breakpoint at the VMA? */ @@ -810,22 +818,34 @@ b->enable_state = bp_shlib_disabled; if (!disabled_breaks) { - target_terminal_ours_for_output (); - warning ("Cannot insert breakpoint %d:", b->number); - warning ("Temporarily disabling shared library breakpoints:"); + fprintf_unfiltered (tmp_error_stream, + "Cannot insert breakpoint %d.\n", b->number); + fprintf_unfiltered (tmp_error_stream, + "Temporarily disabling shared library breakpoints:\n"); } disabled_breaks = 1; - warning ("breakpoint #%d ", b->number); + fprintf_unfiltered (tmp_error_stream, "breakpoint #%d\n", b->number); } else #endif { - target_terminal_ours_for_output (); - warning ("Cannot insert breakpoint %d:", b->number); -#ifdef ONE_PROCESS_WRITETEXT - warning ("The same program may be running in another process."); -#endif - memory_error (val, b->address); /* which bombs us out */ + if (b->type == bp_hardware_breakpoint) + { + hw_breakpoint_error = 1; + fprintf_unfiltered (tmp_error_stream, + "Cannot insert hardware breakpoint %d.\n", + b->number); + } + else + { + fprintf_unfiltered (tmp_error_stream, "Cannot insert breakpoint %d.\n", b->number); + fprintf_filtered (tmp_error_stream, "Error accessing memory address "); + print_address_numeric (b->address, 1, tmp_error_stream); + fprintf_filtered (tmp_error_stream, ": %s.\n", + safe_strerror (val)); + + } + } } else @@ -852,9 +872,13 @@ if (val) { /* Couldn't set breakpoint for some reason */ - target_terminal_ours_for_output (); - warning ("Cannot insert catchpoint %d; disabling it.", - b->number); + fprintf_unfiltered (tmp_error_stream, + "Cannot insert catchpoint %d; disabling it.\n", + b->number); + fprintf_filtered (tmp_error_stream, "Error accessing memory address "); + print_address_numeric (b->address, 1, tmp_error_stream); + fprintf_filtered (tmp_error_stream, ": %s.\n", + safe_strerror (val)); b->enable_state = bp_disabled; } else @@ -876,9 +900,9 @@ if (val == -1) { /* something went wrong */ - target_terminal_ours_for_output (); - warning ("Cannot insert catchpoint %d; disabling it.", - b->number); + fprintf_unfiltered (tmp_error_stream, + "Cannot insert catchpoint %d; disabling it.\n", + b->number); b->enable_state = bp_disabled; } } @@ -955,7 +979,7 @@ addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v); len = TYPE_LENGTH (VALUE_TYPE (v)); - type = hw_write; + type = hw_write; if (b->type == bp_read_watchpoint) type = hw_read; else if (b->type == bp_access_watchpoint) @@ -981,8 +1005,9 @@ if (!b->inserted) { remove_breakpoint (b, mark_uninserted); - warning ("Could not insert hardware watchpoint %d.", - b->number); + hw_breakpoint_error = 1; + fprintf_unfiltered (tmp_error_stream, + "Cannot insert hardware watchpoint %d.\n", b->number); val = -1; } } @@ -1029,8 +1054,7 @@ } if (val < 0) { - target_terminal_ours_for_output (); - warning ("Cannot insert catchpoint %d.", b->number); + fprintf_unfiltered (tmp_error_stream, "Cannot insert catchpoint %d.", b->number); } else b->inserted = 1; @@ -1039,11 +1063,23 @@ return_val = val; /* remember failure */ } } - + + if (return_val) + { + /* If a hardware breakpoint or watchpoint was inserted, add a + message about possibly exhausted resources. */ + if (hw_breakpoint_error) + { + fprintf_unfiltered (tmp_error_stream, "Could not insert hardware breakpoints:\n" + "You may have requested too many hardware breakpoints/watchpoints.\n"); + } + fprintf_unfiltered (tmp_error_stream,"The same program may be running in another process."); + target_terminal_ours_for_output (); + error_stream (tmp_error_stream); + } return return_val; } - int remove_breakpoints (void) { @@ -6681,11 +6717,24 @@ else val = target_insert_breakpoint (b->address, b->shadow_contents); + /* If there was an error in the insert, print a message, then stop execution. */ if (val != 0) { + struct ui_file *tmp_error_stream = mem_fileopen (); + make_cleanup_ui_file_delete (tmp_error_stream); + + if (b->type == bp_hardware_breakpoint) + { + fprintf_unfiltered (tmp_error_stream, + "Cannot insert hardware breakpoint %d:", b->number); + } + else + { + fprintf_unfiltered (tmp_error_stream, + "Cannot insert breakpoint %d:", b->number); + } target_terminal_ours_for_output (); - warning ("Cannot insert breakpoint %d:", b->number); - memory_error (val, b->address); /* which bombs us out */ + error_stream(tmp_error_stream); } else b->inserted = 1; --W/nzBZO5zC0uMSeA--