From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7060 invoked by alias); 26 Jan 2008 19:58:00 -0000 Received: (qmail 7045 invoked by uid 22791); 26 Jan 2008 19:57:59 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 26 Jan 2008 19:57:40 +0000 Received: (qmail 21021 invoked from network); 26 Jan 2008 19:57:38 -0000 Received: from unknown (HELO 172.16.unknown.plus.ru) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 26 Jan 2008 19:57:38 -0000 From: Vladimir Prus Date: Sun, 27 Jan 2008 02:19:00 -0000 Subject: [RFA] Rethrow exception properly. To: gdb-patches@sources.redhat.com X-TUID: b63fb6d70e9c61a3 X-Length: 2094 X-UID: 128 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200801262257.36197.vladimir@codesourcery.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-01/txt/msg00630.txt.bz2 Nick has reported that my recent changes regressed MI error messages, and now we get: (gdb) -break-insert sqrt &"Function \"sqrt\" not defined.\n" ^error,msg="unknown error" (gdb) The problem is in rather old code in break_command_really -- when we can't parse breakpoint location, and pending breakpoints are off, we rethrow the exception using the deprecated_throw_reason. Unfortunately, that strips the message from the exception, so MI code gets rather useless exception. Such rethrowing is just wrong -- if we fully delegate handling of the error to our caller, we should just throw the original exception. The attached patch switches to using throw_exception and gets us back to sane MI error message. OK? - Volodya [gdb] Properly rethrow exception. This fixes errors about non-existent functions for -break-insert. * breakpoint.c (break_command_really): Use throw_exception for rethrowing. If rethrowing, don't print the exception. [gdb/testsuite] * gdb.mi/mi-break.exp (test_error): New. Call it. --- gdb/breakpoint.c | 6 +++--- gdb/testsuite/gdb.mi/mi-break.exp | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 9551bd5..d5de3e7 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5280,13 +5280,13 @@ break_command_really (char *arg, char *cond_string, int thread, { case NOT_FOUND_ERROR: - exception_print (gdb_stderr, e); - /* If pending breakpoint support is turned off, throw error. */ if (pending_break_support == AUTO_BOOLEAN_FALSE) - deprecated_throw_reason (RETURN_ERROR); + throw_exception (e); + + exception_print (gdb_stderr, e); /* If pending breakpoint support is auto query and the user selects no, then simply return the error code. */ diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp index af438b9..ca59348 100644 --- a/gdb/testsuite/gdb.mi/mi-break.exp +++ b/gdb/testsuite/gdb.mi/mi-break.exp @@ -175,10 +175,20 @@ proc test_ignore_count {} { } } +proc test_error {} { + global mi_gdb_prompt + + mi_gdb_test "-break-insert function_that_does_not_exit" \ + ".*\\^error,msg=\"Function \\\\\"function_that_does_not_exit\\\\\" not defined.\"" \ + "breakpoint at nonexistent function" +} + test_tbreak_creation_and_listing test_rbreak_creation_and_listing test_ignore_count +test_error + mi_gdb_exit return 0 -- 1.5.3.5