From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10216 invoked by alias); 19 Nov 2006 04:39:03 -0000 Received: (qmail 10205 invoked by uid 22791); 19 Nov 2006 04:39:02 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 19 Nov 2006 04:38:54 +0000 Received: from kahikatea.snap.net.nz (p202-124-125-182.snap.net.nz [202.124.125.182]) by viper.snap.net.nz (Postfix) with ESMTP id D77A03D917A; Sun, 19 Nov 2006 17:39:14 +1300 (NZDT) Received: by kahikatea.snap.net.nz (Postfix, from userid 500) id 53649BE447; Sun, 19 Nov 2006 17:34:41 +1300 (NZDT) From: Nick Roberts To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com, Ulrich.Weigand@de.ibm.com Subject: Re: [PATCH] PR mi/2086 -break-insert missing error diagnostic In-Reply-To: <20061117211556.GA13961@nevyn.them.org> References: <17717.17922.450312.898237@kahikatea.snap.net.nz> <20061017213119.GA14010@nevyn.them.org> <17717.20397.279496.222573@kahikatea.snap.net.nz> <20061017215754.GA15210@nevyn.them.org> <17717.27348.977065.613551@kahikatea.snap.net.nz> <20061018153109.GB10436@nevyn.them.org> <17718.19901.569519.210795@kahikatea.snap.net.nz> <20061117211556.GA13961@nevyn.them.org> X-Mailer: VM 7.19 under Emacs 22.0.90.14 Message-Id: <20061119043442.53649BE447@kahikatea.snap.net.nz> Date: Sun, 19 Nov 2006 04:39:00 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-11/txt/msg00208.txt.bz2 > > OK, how about just using the hack in mi_cmd_thread_select for > > mi_cmd_break_insert for the moment. > > This is just nasty. I believe I pointed you at Ulrich's analysis of > this problem upthread: > > http://sources.redhat.com/ml/gdb/2006-10/msg00021.html > > It seems pretty clear to me that the patch which switched things to > return the result of catch_exceptions_with_msg was wrong. The > functions are defined to return an enum gdb_rc. Can't we make > them do that again? Simple, obviously correct. Well we need to propagate the error message back to captured_mi_execute_command. The best I can do is create a new function catch_errors_with_msg (gdb_breakpoint used catch_errors previously). We can also change mi_cmd_thread_list_ids accordingly. Also do_captured_breakpoint, do_captured_breakpoint_query, do_captured_thread_select and do_captured_list_thread_ids should really be type enum gdb_rc. -- Nick http://www.inet.net.nz/~nickrob** *** exceptions.h 22 Sep 2006 10:00:57 +1200 1.19 --- exceptions.h 19 Nov 2006 17:09:58 +1300 *************** *** 227,236 **** indication of the exact exception that it caught - quit_flag might help. ! This function is superseeded by catch_exceptions(). */ typedef int (catch_errors_ftype) (void *); extern int catch_errors (catch_errors_ftype *, void *, char *, return_mask); /* Template to catch_errors() that wraps calls to command functions. */ --- 227,238 ---- indication of the exact exception that it caught - quit_flag might help. ! This function is superseded by catch_exceptions(). */ typedef int (catch_errors_ftype) (void *); extern int catch_errors (catch_errors_ftype *, void *, char *, return_mask); + extern int catch_errors_with_msg (catch_errors_ftype *, void *, char *, + char **, return_mask); /* Template to catch_errors() that wraps calls to command functions. */ *** exceptions.c 04 Feb 2006 10:50:25 +1300 1.24 --- exceptions.c 19 Nov 2006 17:00:36 +1300 *************** *** 508,513 **** --- 508,520 ---- catch_errors (catch_errors_ftype *func, void *func_args, char *errstring, return_mask mask) { + return catch_errors_with_msg (func, func_args, errstring, NULL, mask); + } + + int + catch_errors_with_msg (catch_errors_ftype *func, void *func_args, char *errstring, + char **gdberrmsg, return_mask mask) + { volatile int val = 0; volatile struct gdb_exception exception; TRY_CATCH (exception, mask) *************** *** 516,522 **** } print_any_exception (gdb_stderr, errstring, exception); if (exception.reason != 0) ! return 0; return val; } --- 523,541 ---- } print_any_exception (gdb_stderr, errstring, exception); if (exception.reason != 0) ! { ! /* If caller wants a copy of the low-level error message, make ! one. This is used in the case of a silent error whereby the ! caller may optionally want to issue the message. */ ! if (gdberrmsg != NULL) ! { ! if (exception.message != NULL) ! *gdberrmsg = xstrdup (exception.message); ! else ! *gdberrmsg = NULL; ! } ! return 0; ! } return val; } *** breakpoint.c 23 Oct 2006 08:48:48 +1300 1.231 --- breakpoint.c 19 Nov 2006 17:19:52 +1300 *************** *** 3615,3621 **** }; static int ! do_captured_breakpoint_query (struct ui_out *uiout, void *data) { struct captured_breakpoint_query_args *args = data; struct breakpoint *b; --- 3615,3621 ---- }; static int ! do_captured_breakpoint_query (void *data) { struct captured_breakpoint_query_args *args = data; struct breakpoint *b; *************** *** 3632,3645 **** } enum gdb_rc ! gdb_breakpoint_query (struct ui_out *uiout, int bnum, char **error_message) { struct captured_breakpoint_query_args args; args.bnum = bnum; /* For the moment we don't trust print_one_breakpoint() to not throw an error. */ ! return catch_exceptions_with_msg (uiout, do_captured_breakpoint_query, &args, ! error_message, RETURN_MASK_ALL); } /* Return non-zero if B is user settable (breakpoints, watchpoints, --- 3632,3645 ---- } enum gdb_rc ! gdb_breakpoint_query (int bnum, char **error_message) { struct captured_breakpoint_query_args args; args.bnum = bnum; /* For the moment we don't trust print_one_breakpoint() to not throw an error. */ ! return catch_errors_with_msg (do_captured_breakpoint_query, &args, NULL, ! error_message, RETURN_MASK_ALL); } /* Return non-zero if B is user settable (breakpoints, watchpoints, *************** *** 5373,5379 **** }; static int ! do_captured_breakpoint (struct ui_out *uiout, void *data) { struct captured_breakpoint_args *args = data; struct symtabs_and_lines sals; --- 5373,5379 ---- }; static int ! do_captured_breakpoint (void *data) { struct captured_breakpoint_args *args = data; struct symtabs_and_lines sals; *************** *** 5481,5488 **** args.tempflag = tempflag; args.thread = thread; args.ignore_count = ignore_count; ! return catch_exceptions_with_msg (uiout, do_captured_breakpoint, &args, ! error_message, RETURN_MASK_ALL); } --- 5481,5488 ---- args.tempflag = tempflag; args.thread = thread; args.ignore_count = ignore_count; ! return catch_errors_with_msg (do_captured_breakpoint, &args, ! NULL, error_message, RETURN_MASK_ALL); } *** mi-cmd-break.c 24 Dec 2005 07:57:46 +1300 1.13 --- mi-cmd-break.c 19 Nov 2006 17:31:58 +1300 *************** *** 39,45 **** static void breakpoint_notify (int b) { ! gdb_breakpoint_query (uiout, b, NULL); } --- 39,45 ---- static void breakpoint_notify (int b) { ! gdb_breakpoint_query (b, NULL); } *** mi-main.c 18 Nov 2006 19:13:33 +1300 1.86 --- mi-main.c 19 Nov 2006 14:17:16 +1300 *************** *** 234,244 **** else rc = gdb_thread_select (uiout, argv[0], &mi_error_message); ! /* RC is enum gdb_rc if it is successful (>=0) ! enum return_reason if not (<0). */ ! if ((int) rc < 0 && (enum return_reason) rc == RETURN_ERROR) ! return MI_CMD_ERROR; ! else if ((int) rc >= 0 && rc == GDB_RC_FAIL) return MI_CMD_ERROR; else return MI_CMD_DONE; --- 234,240 ---- else rc = gdb_thread_select (uiout, argv[0], &mi_error_message); ! if (rc == GDB_RC_FAIL) return MI_CMD_ERROR; else return MI_CMD_DONE;