From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58718 invoked by alias); 27 Sep 2017 19:43:25 -0000 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 Received: (qmail 57814 invoked by uid 89); 27 Sep 2017 19:43:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Sep 2017 19:43:23 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 816B224D0A7; Wed, 27 Sep 2017 19:43:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 816B224D0A7 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id D50156BEF4; Wed, 27 Sep 2017 19:43:21 +0000 (UTC) Subject: Re: [RFA] Change exceptions.h functions to use gdb::function_view To: Tom Tromey , gdb-patches@sourceware.org References: <20170927165302.30177-1-tom@tromey.com> From: Pedro Alves Message-ID: <4098e86f-d084-fb3b-ea9b-0d5565ddd930@redhat.com> Date: Wed, 27 Sep 2017 19:43:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170927165302.30177-1-tom@tromey.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-09/txt/msg00839.txt.bz2 On 09/27/2017 05:53 PM, Tom Tromey wrote: > This changes some functions in exceptions.h to use gdb::function_view, > then fixes up the fallout. This lead to some surprising places, like > a function pointer in target_so_ops. > > While writing this I found that catch_exception_ftype was unused, so I > removed this. > > Note that I did not compile the windows-nat.c change, so I don't know > if it works. > > Regression tested by the buildbot. > I'm borderline about this. I have to say that I question the value of catch_exceptions&co, over just using TRY/CATCH + a scoped_restore(current_uiout) in the try scope + printing the exception. A TRY/CATCH is likely to be easier to understand and debug, I think. I mean, take the print_symbol case [it was just the random one that I picked], and compare: TRY { print_symbol (gdbarch, sym, depth + 1, outfile); } CATCH (ex, RETURN_MASK_ERROR) { exception_fprintf (gdb_stderr, ex, "Error printing symbol:\n"); } vs catch_errors ([&] () { return print_symbol (gdbarch, sym, depth + 1, outfile); }, "Error printing symbol:\n", RETURN_MASK_ERROR); It seems like that case doesn't even need a scoped_restore for current_uiout. And with TRY/CATCH, print_symbol can be simplified further to return void. Did you consider this? > - if (catch_exceptions_with_msg (uiout, do_captured_breakpoint_query, &args, > - error_message, RETURN_MASK_ALL) < 0) > + if (catch_exceptions_with_msg > + (uiout, > + [&] (struct ui_out *) > + { > + return do_captured_breakpoint_query (bnum); > + }, We don't really need the ui_out * parameter in catch_exceptions_with_msg's callback anymore, since you can always access it via lambda capture. Would you consider removing it? > > static int > -do_captured_thread_select (struct ui_out *uiout, void *tidstr_v) > +do_captured_thread_select (struct ui_out *uiout, const char *tidstr) > { > + { > + return do_captured_thread_select (inner_uiout, tidstr); > + }, Note the patch has several cases of tabs vs spaces like above. > @@ -1540,7 +1540,7 @@ get_windows_debug_event (struct target_ops *ops, > CloseHandle (current_event.u.LoadDll.hFile); > if (saw_create != 1 || ! windows_initialization_done) > break; > - catch_errors (handle_load_dll, NULL, (char *) "", RETURN_MASK_ALL); > + catch_errors (handle_load_dll, (char *) "", RETURN_MASK_ALL); > ourstatus->kind = TARGET_WAITKIND_LOADED; > ourstatus->value.integer = 0; > thread_id = main_thread_id; > @@ -1553,7 +1553,7 @@ get_windows_debug_event (struct target_ops *ops, > "UNLOAD_DLL_DEBUG_EVENT")); > if (saw_create != 1 || ! windows_initialization_done) > break; > - catch_errors (handle_unload_dll, NULL, (char *) "", RETURN_MASK_ALL); > + catch_errors (handle_unload_dll, (char *) "", RETURN_MASK_ALL); > ourstatus->kind = TARGET_WAITKIND_LOADED; > ourstatus->value.integer = 0; > thread_id = main_thread_id; I don't think we need the casts nowadays. catch_errors takes a const string (since the -Wwrite-strings patch). Thanks, Pedro Alves