From patchwork Wed Jul 18 14:09:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 28454 Received: (qmail 51016 invoked by alias); 18 Jul 2018 14:09:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 50916 invoked by uid 89); 18 Jul 2018 14:09:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Inclusive, sk:handle_, Reset, 90617 X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.143.31) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Jul 2018 14:09:11 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway31.websitewelcome.com (Postfix) with ESMTP id AA1F632C8 for ; Wed, 18 Jul 2018 09:09:09 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id fn8ffmUcH79N3fn8ff8mSY; Wed, 18 Jul 2018 09:09:09 -0500 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=sixv21A2UFWKXQ+jghk7lvVwxl6T4IGq1AOQkpZBRO8=; b=PQyk85cUefTv19viD9+qZMt4eT sVzDiFMnunBtQj7c2prw6fmTfaAZVUKEwTi/+AEcF81QI7lLFbsqxd9fWpYRlFQ7VoQNnROsOC3m9 EV/kJl/x0RLI7KKd0ktghnURX; Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:57494 helo=pokyo.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1ffn8f-000r59-FP; Wed, 18 Jul 2018 09:09:09 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v2 3/6] Use new and delete for struct infcall_control_state Date: Wed, 18 Jul 2018 08:09:01 -0600 Message-Id: <20180718140904.16811-4-tom@tromey.com> In-Reply-To: <20180718140904.16811-1-tom@tromey.com> References: <20180718140904.16811-1-tom@tromey.com> This changes infrun.c to use new and delete for infcall_control_state. gdb/ChangeLog 2018-07-18 Tom Tromey * gdbthread.h (struct thread_control_state): Add initializer. (class thread_info) : Remove initializer. * inferior.h (struct inferior_control_state): Add initializer. (class inferior) : Remove initializer. (exit_inferior_1): Update. * infrun.c (struct infcall_control_state): Add constructors. (save_infcall_control_state): Use new. (restore_infcall_control_state, discard_infcall_control_state): Use delete. --- gdb/ChangeLog | 12 ++++++++++++ gdb/gdbthread.h | 34 +++++++++++++++++----------------- gdb/inferior.c | 2 +- gdb/inferior.h | 12 +++++++++++- gdb/infrun.c | 13 ++++++------- 5 files changed, 47 insertions(+), 26 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 86bb06f0776..ee2c4051e77 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2018-07-18 Tom Tromey + + * gdbthread.h (struct thread_control_state): Add initializer. + (class thread_info) : Remove initializer. + * inferior.h (struct inferior_control_state): Add initializer. + (class inferior) : Remove initializer. + (exit_inferior_1): Update. + * infrun.c (struct infcall_control_state): Add constructors. + (save_infcall_control_state): Use new. + (restore_infcall_control_state, discard_infcall_control_state): + Use delete. + 2018-07-18 Tom Tromey * infrun.c (struct infcall_suspend_state) : Now a diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 99de5ff0d80..2738e44da9f 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -52,17 +52,17 @@ struct thread_control_state /* User/external stepping state. */ /* Step-resume or longjmp-resume breakpoint. */ - struct breakpoint *step_resume_breakpoint; + struct breakpoint *step_resume_breakpoint = nullptr; /* Exception-resume breakpoint. */ - struct breakpoint *exception_resume_breakpoint; + struct breakpoint *exception_resume_breakpoint = nullptr; /* Breakpoints used for software single stepping. Plural, because it may have multiple locations. E.g., if stepping over a conditional branch instruction we can't decode the condition for, we'll need to put a breakpoint at the branch destination, and another at the instruction after the branch. */ - struct breakpoint *single_step_breakpoints; + struct breakpoint *single_step_breakpoints = nullptr; /* Range to single step within. @@ -74,11 +74,11 @@ struct thread_control_state wait_for_inferior in a minor way if this were changed to the address of the instruction and that address plus one. But maybe not). */ - CORE_ADDR step_range_start; /* Inclusive */ - CORE_ADDR step_range_end; /* Exclusive */ + CORE_ADDR step_range_start = 0; /* Inclusive */ + CORE_ADDR step_range_end = 0; /* Exclusive */ /* Function the thread was in as of last it started stepping. */ - struct symbol *step_start_function; + struct symbol *step_start_function = nullptr; /* If GDB issues a target step request, and this is nonzero, the target should single-step this thread once, and then continue @@ -86,16 +86,16 @@ struct thread_control_state thread stops in the step range above. If this is zero, the target should ignore the step range, and only issue one single step. */ - int may_range_step; + int may_range_step = 0; /* Stack frame address as of when stepping command was issued. This is how we know when we step into a subroutine call, and how to set the frame for the breakpoint used to step out. */ - struct frame_id step_frame_id; + struct frame_id step_frame_id {}; /* Similarly, the frame ID of the underlying stack frame (skipping any inlined frames). */ - struct frame_id step_stack_frame_id; + struct frame_id step_stack_frame_id {}; /* Nonzero if we are presently stepping over a breakpoint. @@ -119,29 +119,29 @@ struct thread_control_state wait_for_inferior, which calls handle_inferior_event in a loop, and until wait_for_inferior exits, this variable is changed only by keep_going. */ - int trap_expected; + int trap_expected = 0; /* Nonzero if the thread is being proceeded for a "finish" command or a similar situation when return value should be printed. */ - int proceed_to_finish; + int proceed_to_finish = 0; /* Nonzero if the thread is being proceeded for an inferior function call. */ - int in_infcall; + int in_infcall = 0; - enum step_over_calls_kind step_over_calls; + enum step_over_calls_kind step_over_calls = STEP_OVER_NONE; /* Nonzero if stopped due to a step command. */ - int stop_step; + int stop_step = 0; /* Chain containing status of breakpoint(s) the thread stopped at. */ - bpstat stop_bpstat; + bpstat stop_bpstat = nullptr; /* Whether the command that started the thread was a stepping command. This is used to decide whether "set scheduler-locking step" behaves like "on" or "off". */ - int stepping_command; + int stepping_command = 0; }; /* Inferior thread specific part of `struct infcall_suspend_state'. */ @@ -296,7 +296,7 @@ public: /* State of GDB control of inferior thread execution. See `struct thread_control_state'. */ - thread_control_state control {}; + thread_control_state control; /* State of inferior thread to restore after GDB is done with an inferior call. See `struct thread_suspend_state'. */ diff --git a/gdb/inferior.c b/gdb/inferior.c index 16991d41b3b..58c892586d2 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -226,7 +226,7 @@ exit_inferior_1 (struct inferior *inftoex, int silent) inf->pending_detach = 0; /* Reset it. */ - inf->control = {NO_STOP_QUIETLY}; + inf->control = inferior_control_state (NO_STOP_QUIETLY); } void diff --git a/gdb/inferior.h b/gdb/inferior.h index c5dc324fa39..e79c17ea8cd 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -283,6 +283,16 @@ struct private_inferior struct inferior_control_state { + inferior_control_state () + : stop_soon (NO_STOP_QUIETLY) + { + } + + explicit inferior_control_state (enum stop_kind when) + : stop_soon (when) + { + } + /* See the definition of stop_kind above. */ enum stop_kind stop_soon; }; @@ -341,7 +351,7 @@ public: /* State of GDB control of inferior process execution. See `struct inferior_control_state'. */ - inferior_control_state control {NO_STOP_QUIETLY}; + inferior_control_state control; /* True if this was an auto-created inferior, e.g. created from following a fork; false, if this inferior was manually added by diff --git a/gdb/infrun.c b/gdb/infrun.c index b430a731693..f6bf86e5a19 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -8931,11 +8931,11 @@ struct infcall_control_state struct inferior_control_state inferior_control; /* Other fields: */ - enum stop_stack_kind stop_stack_dummy; - int stopped_by_random_signal; + enum stop_stack_kind stop_stack_dummy = STOP_NONE; + int stopped_by_random_signal = 0; /* ID if the selected frame when the inferior function call was made. */ - struct frame_id selected_frame_id; + struct frame_id selected_frame_id {}; }; /* Save all of the information associated with the inferior<==>gdb @@ -8944,8 +8944,7 @@ struct infcall_control_state struct infcall_control_state * save_infcall_control_state (void) { - struct infcall_control_state *inf_status = - XNEW (struct infcall_control_state); + struct infcall_control_state *inf_status = new struct infcall_control_state; struct thread_info *tp = inferior_thread (); struct inferior *inf = current_inferior (); @@ -9031,7 +9030,7 @@ restore_infcall_control_state (struct infcall_control_state *inf_status) END_CATCH } - xfree (inf_status); + delete inf_status; } static void @@ -9061,7 +9060,7 @@ discard_infcall_control_state (struct infcall_control_state *inf_status) /* See save_infcall_control_state for info on stop_bpstat. */ bpstat_clear (&inf_status->thread_control.stop_bpstat); - xfree (inf_status); + delete inf_status; } /* See infrun.h. */