From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway20.websitewelcome.com (gateway20.websitewelcome.com [192.185.64.36]) by sourceware.org (Postfix) with ESMTPS id 5E514394B01E for ; Sat, 14 Mar 2020 18:52:04 +0000 (GMT) Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway20.websitewelcome.com (Postfix) with ESMTP id BAB09400C74DA for ; Sat, 14 Mar 2020 12:36:48 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id DBtBjU2dERP4zDBtBjpdVD; Sat, 14 Mar 2020 13:52:01 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=eDwCVx7X6Z3d+xBWsDbGHLwxot8ViUKn0iH3SO6CYvg=; b=GjXFgRud2sztyqvG5oL/+wBRiU URM4i8UsGKTTTuMhMlmOvZt0wpiANPQ1BzuS7gyYP2yzL/wkMS6lHxG5xv+OUb2BOHpSt04Gnx6/2 2xiamG4u9xzcKrL7iQuCZ2gjb; Received: from 184-96-250-69.hlrn.qwest.net ([184.96.250.69]:39174 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jDBtB-001Khw-CB; Sat, 14 Mar 2020 12:52:01 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 01/12] Move start_event_loop out of event-loop.c Date: Sat, 14 Mar 2020 12:51:47 -0600 Message-Id: <20200314185158.7816-2-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200314185158.7816-1-tom@tromey.com> References: <20200314185158.7816-1-tom@tromey.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 184.96.250.69 X-Source-L: No X-Exim-ID: 1jDBtB-001Khw-CB X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 184-96-250-69.hlrn.qwest.net (bapiya.Home) [184.96.250.69]:39174 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-24.2 required=5.0 tests=DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2020 18:52:06 -0000 A subsequent patch is going to move event-loop.c to gdbsupport. In a review of an earlier version of this series, Pedro pointed out that the resulting code would be cleaner if start_event_loop were not shared -- because gdb and gdbserver have some different needs here -- and so this moves start_event_loop to main.c. Because the only caller is there, it is also now static. gdb/ChangeLog 2020-03-14 Tom Tromey * event-loop.h (start_event_loop): Don't declare. * event-loop.c (start_event_loop): Move... * main.c (start_event_loop): ...here. Now static. --- gdb/ChangeLog | 6 ++++++ gdb/event-loop.c | 54 ---------------------------------------------- gdb/event-loop.h | 1 - gdb/main.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 55 deletions(-) diff --git a/gdb/event-loop.c b/gdb/event-loop.c index af8f80b6a2c..36df4767aa9 100644 --- a/gdb/event-loop.c +++ b/gdb/event-loop.c @@ -318,60 +318,6 @@ gdb_do_one_event (void) return 1; } -/* Start up the event loop. This is the entry point to the event loop - from the command loop. */ - -void -start_event_loop (void) -{ - /* Loop until there is nothing to do. This is the entry point to - the event loop engine. gdb_do_one_event will process one event - for each invocation. It blocks waiting for an event and then - processes it. */ - while (1) - { - int result = 0; - - try - { - result = gdb_do_one_event (); - } - catch (const gdb_exception &ex) - { - exception_print (gdb_stderr, ex); - - /* If any exception escaped to here, we better enable - stdin. Otherwise, any command that calls async_disable_stdin, - and then throws, will leave stdin inoperable. */ - SWITCH_THRU_ALL_UIS () - { - async_enable_stdin (); - } - /* If we long-jumped out of do_one_event, we probably didn't - get around to resetting the prompt, which leaves readline - in a messed-up state. Reset it here. */ - current_ui->prompt_state = PROMPT_NEEDED; - gdb::observers::command_error.notify (); - /* This call looks bizarre, but it is required. If the user - entered a command that caused an error, - after_char_processing_hook won't be called from - rl_callback_read_char_wrapper. Using a cleanup there - won't work, since we want this function to be called - after a new prompt is printed. */ - if (after_char_processing_hook) - (*after_char_processing_hook) (); - /* Maybe better to set a flag to be checked somewhere as to - whether display the prompt or not. */ - } - - if (result < 0) - break; - } - - /* We are done with the event loop. There are no more event sources - to listen to. So we exit GDB. */ - return; -} /* Wrapper function for create_file_handler, so that the caller diff --git a/gdb/event-loop.h b/gdb/event-loop.h index 64f3712786d..52740c3b9af 100644 --- a/gdb/event-loop.h +++ b/gdb/event-loop.h @@ -80,7 +80,6 @@ typedef void (timer_handler_func) (gdb_client_data); /* Exported functions from event-loop.c */ -extern void start_event_loop (void); extern int gdb_do_one_event (void); extern void delete_file_handler (int fd); extern void add_file_handler (int fd, handler_func *proc, diff --git a/gdb/main.c b/gdb/main.c index a03ed8117ab..67a3d0027e1 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -53,6 +53,7 @@ #include "gdbtk/generic/gdbtk.h" #endif #include "gdbsupport/alt-stack.h" +#include "observable.h" /* The selected interpreter. This will be used as a set command variable, so it should always be malloc'ed - since @@ -336,6 +337,61 @@ get_init_files (std::vector *system_gdbinit, *local_gdbinit = localinit; } +/* Start up the event loop. This is the entry point to the event loop + from the command loop. */ + +static void +start_event_loop () +{ + /* Loop until there is nothing to do. This is the entry point to + the event loop engine. gdb_do_one_event will process one event + for each invocation. It blocks waiting for an event and then + processes it. */ + while (1) + { + int result = 0; + + try + { + result = gdb_do_one_event (); + } + catch (const gdb_exception &ex) + { + exception_print (gdb_stderr, ex); + + /* If any exception escaped to here, we better enable + stdin. Otherwise, any command that calls async_disable_stdin, + and then throws, will leave stdin inoperable. */ + SWITCH_THRU_ALL_UIS () + { + async_enable_stdin (); + } + /* If we long-jumped out of do_one_event, we probably didn't + get around to resetting the prompt, which leaves readline + in a messed-up state. Reset it here. */ + current_ui->prompt_state = PROMPT_NEEDED; + gdb::observers::command_error.notify (); + /* This call looks bizarre, but it is required. If the user + entered a command that caused an error, + after_char_processing_hook won't be called from + rl_callback_read_char_wrapper. Using a cleanup there + won't work, since we want this function to be called + after a new prompt is printed. */ + if (after_char_processing_hook) + (*after_char_processing_hook) (); + /* Maybe better to set a flag to be checked somewhere as to + whether display the prompt or not. */ + } + + if (result < 0) + break; + } + + /* We are done with the event loop. There are no more event sources + to listen to. So we exit GDB. */ + return; +} + /* Call command_loop. */ /* Prevent inlining this function for the benefit of GDB's selftests -- 2.17.2