From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 586FA3858280 for ; Tue, 5 Jul 2022 17:15:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 586FA3858280 Received: by mail-il1-x12f.google.com with SMTP id n9so3517951ilq.12 for ; Tue, 05 Jul 2022 10:15:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SYurlNDwBaLPSo842Ps8PkquCcU1AX2IU+3xej+n+a4=; b=W7EWg24jFfGsdHDYE4Bydgeen5LogKXjFDK336Utmk4FF/0C7l3C4DVPU7ZQEb5jSF Wgli0Dn1jh8VWPy78T+mKO/WInwC8Y7/OEx5dbYBzRE+WLE1YeiOkjMHJ+OvA3bMiCUo HwgjJasF5/e++fj8yznY0vs68ekK8vEVhUHKwISRQ0jKidaveaxqrPdjlPo3hdE0+sYo eOR+/5sJc/tFbQ3KwZayIHo1Td4ytGAEe3QYuYsLSDXahaG4f2XSRVJBUsTGtcnC0p1n T2BbN7IvSfzmefoQ97yUYwSnWKtXFkSlPZtG8X9a6UG/KVkBiDG1lQijDz6Cn6Sdevnf eF2g== X-Gm-Message-State: AJIora8MBus/U3heA04OZm+dFOpKbGZrGRvBkqwOtdN1aQNR9G2FBz/o c469nbpkSSM5TENgfUnawnvmcZh7qAEDcQ== X-Google-Smtp-Source: AGRyM1tJgfzRusoRv5e4K3c+UaMDmIah6BmLClh0cnMICr+HnlmSKX8Lqh0CJqyHkdxQdYrW/KbuQA== X-Received: by 2002:a92:c547:0:b0:2da:9950:1402 with SMTP id a7-20020a92c547000000b002da99501402mr20545086ilj.301.1657041333611; Tue, 05 Jul 2022 10:15:33 -0700 (PDT) Received: from murgatroyd.Home (71-211-187-180.hlrn.qwest.net. [71.211.187.180]) by smtp.gmail.com with ESMTPSA id k1-20020a926f01000000b002dbee570531sm4631034ilc.18.2022.07.05.10.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 10:15:33 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/4] Remove ui_register_input_event_handler Date: Tue, 5 Jul 2022 11:15:29 -0600 Message-Id: <20220705171532.1072851-2-tromey@adacore.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220705171532.1072851-1-tromey@adacore.com> References: <20220705171532.1072851-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Tue, 05 Jul 2022 17:15:35 -0000 This patch removes ui_register_input_event_handler and ui_unregister_input_event_handler, replacing them with methods on 'ui'. It also changes gdb to use these methods everywhere, rather than sometimes reaching in to the ui to manage the file descriptor directly. --- gdb/event-top.c | 20 ++++++++++---------- gdb/infcall.c | 6 +++--- gdb/infrun.c | 2 +- gdb/top.h | 12 ++++++------ gdb/utils.c | 4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/gdb/event-top.c b/gdb/event-top.c index 74960c8ed3c..2863a8aff69 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -491,7 +491,7 @@ stdin_event_handler (int error, gdb_client_data client_data) /* Switch to the main UI, so diagnostics always go there. */ current_ui = main_ui; - delete_file_handler (ui->input_fd); + ui->unregister_file_handler (); if (main_ui == ui) { /* If stdin died, we may as well kill gdb. */ @@ -531,18 +531,18 @@ stdin_event_handler (int error, gdb_client_data client_data) /* See top.h. */ void -ui_register_input_event_handler (struct ui *ui) +ui::register_file_handler () { - add_file_handler (ui->input_fd, stdin_event_handler, ui, - string_printf ("ui-%d", ui->num), true); + add_file_handler (input_fd, stdin_event_handler, this, + string_printf ("ui-%d", num), true); } /* See top.h. */ void -ui_unregister_input_event_handler (struct ui *ui) +ui::unregister_file_handler () { - delete_file_handler (ui->input_fd); + delete_file_handler (input_fd); } /* Re-enable stdin after the end of an execution command in @@ -557,7 +557,7 @@ async_enable_stdin (void) if (ui->prompt_state == PROMPT_BLOCKED) { target_terminal::ours (); - ui_register_input_event_handler (ui); + ui->register_file_handler (); ui->prompt_state = PROMPT_NEEDED; } } @@ -571,7 +571,7 @@ async_disable_stdin (void) struct ui *ui = current_ui; ui->prompt_state = PROMPT_BLOCKED; - delete_file_handler (ui->input_fd); + ui->unregister_file_handler (); } @@ -1366,7 +1366,7 @@ gdb_setup_readline (int editing) Another source is going to be the target program (inferior), but that must be registered only when it actually exists (I.e. after we say 'run' or after we connect to a remote target. */ - ui_register_input_event_handler (ui); + ui->register_file_handler (); } /* Disable command input through the standard CLI channels. Used in @@ -1393,7 +1393,7 @@ gdb_disable_readline (void) if (ui->command_editing) gdb_rl_callback_handler_remove (); - delete_file_handler (ui->input_fd); + ui->unregister_file_handler (); } scoped_segv_handler_restore::scoped_segv_handler_restore (segv_handler_t new_handler) diff --git a/gdb/infcall.c b/gdb/infcall.c index 9334648ac0e..2acceed4b07 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -581,7 +581,7 @@ run_inferior_call (std::unique_ptr sm, ptid_t call_thread_ptid = call_thread->ptid; int was_running = call_thread->state == THREAD_RUNNING; - delete_file_handler (current_ui->input_fd); + current_ui->unregister_file_handler (); scoped_restore restore_in_infcall = make_scoped_restore (&call_thread->control.in_infcall, 1); @@ -624,9 +624,9 @@ run_inferior_call (std::unique_ptr sm, state again here. In other cases, stdin will be re-enabled by inferior_event_handler, when an exception is thrown. */ if (current_ui->prompt_state == PROMPT_BLOCKED) - delete_file_handler (current_ui->input_fd); + current_ui->unregister_file_handler (); else - ui_register_input_event_handler (current_ui); + current_ui->register_file_handler (); /* If the infcall does NOT succeed, normal_stop will have already finished the thread states. However, on success, normal_stop diff --git a/gdb/infrun.c b/gdb/infrun.c index 02c98b50c8c..a6694230d29 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -4096,7 +4096,7 @@ check_curr_ui_sync_execution_done (void) { target_terminal::ours (); gdb::observers::sync_execution_done.notify (); - ui_register_input_event_handler (ui); + ui->register_file_handler (); } } diff --git a/gdb/top.h b/gdb/top.h index b26209e8c8d..18c49cc5513 100644 --- a/gdb/top.h +++ b/gdb/top.h @@ -148,6 +148,12 @@ struct ui /* The current ui_out. */ struct ui_out *m_current_uiout; + + /* Register the UI's input file descriptor in the event loop. */ + void register_file_handler (); + + /* Unregister the UI's input file descriptor from the event loop. */ + void unregister_file_handler (); }; /* The main UI. This is the UI that is bound to stdin/stdout/stderr. @@ -211,12 +217,6 @@ ui_range all_uis () return ui_range (ui_list); } -/* Register the UI's input file descriptor in the event loop. */ -extern void ui_register_input_event_handler (struct ui *ui); - -/* Unregister the UI's input file descriptor from the event loop. */ -extern void ui_unregister_input_event_handler (struct ui *ui); - /* From top.c. */ extern bool confirm; extern int inhibit_gdbinit; diff --git a/gdb/utils.c b/gdb/utils.c index 413a4f4d53b..5503acfd6bc 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -799,7 +799,7 @@ class scoped_input_handler m_ui (NULL) { target_terminal::ours (); - ui_register_input_event_handler (current_ui); + current_ui->register_file_handler (); if (current_ui->prompt_state == PROMPT_BLOCKED) m_ui = current_ui; } @@ -807,7 +807,7 @@ class scoped_input_handler ~scoped_input_handler () { if (m_ui != NULL) - ui_unregister_input_event_handler (m_ui); + m_ui->unregister_file_handler (); } DISABLE_COPY_AND_ASSIGN (scoped_input_handler); -- 2.34.1