From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 259D73857C74 for ; Sat, 28 Aug 2021 14:58:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 259D73857C74 X-ASG-Debug-ID: 1630162726-0c856e0388104780001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id wVirrEZDtjxsngFF (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 28 Aug 2021 10:58:46 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id 4FC4E441D64; Sat, 28 Aug 2021 10:58:46 -0400 (EDT) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Subject: [PATCH 1/3] gdb: make lwp_info non-POD Date: Sat, 28 Aug 2021 10:58:43 -0400 X-ASG-Orig-Subj: [PATCH 1/3] gdb: make lwp_info non-POD Message-Id: <20210828145845.1034686-2-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210828145845.1034686-1-simon.marchi@polymtl.ca> References: <20210828145845.1034686-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1630162726 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 5647 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.92222 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-16.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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, 28 Aug 2021 14:59:00 -0000 Initialize all fields in the class declaration directly. This opens the door to using intrusive_list, done in the following patch. Change-Id: I38bb27410cd9ebf511d310bb86fe2ea1872c3b05 --- gdb/linux-nat.c | 27 ++++++--------------------- gdb/linux-nat.h | 38 ++++++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 37 deletions(-) diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index e9433b2206bc..26324af3cfa2 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -845,19 +845,10 @@ purge_lwp_list (int pid) static struct lwp_info * add_initial_lwp (ptid_t ptid) { - struct lwp_info *lp; - gdb_assert (ptid.lwp_p ()); - lp = XNEW (struct lwp_info); - - memset (lp, 0, sizeof (struct lwp_info)); - - lp->last_resume_kind = resume_continue; - lp->waitstatus.kind = TARGET_WAITKIND_IGNORE; + lwp_info *lp = new lwp_info (ptid); - lp->ptid = ptid; - lp->core = -1; /* Add to sorted-by-reverse-creation-order list. */ lwp_list_add (lp); @@ -893,16 +884,13 @@ add_lwp (ptid_t ptid) static void delete_lwp (ptid_t ptid) { - struct lwp_info *lp; - void **slot; - struct lwp_info dummy; + lwp_info dummy (ptid); - dummy.ptid = ptid; - slot = htab_find_slot (lwp_lwpid_htab, &dummy, NO_INSERT); + void **slot = htab_find_slot (lwp_lwpid_htab, &dummy, NO_INSERT); if (slot == NULL) return; - lp = *(struct lwp_info **) slot; + lwp_info *lp = *(struct lwp_info **) slot; gdb_assert (lp != NULL); htab_clear_slot (lwp_lwpid_htab, slot); @@ -920,18 +908,15 @@ delete_lwp (ptid_t ptid) static struct lwp_info * find_lwp_pid (ptid_t ptid) { - struct lwp_info *lp; int lwp; - struct lwp_info dummy; if (ptid.lwp_p ()) lwp = ptid.lwp (); else lwp = ptid.pid (); - dummy.ptid = ptid_t (0, lwp, 0); - lp = (struct lwp_info *) htab_find (lwp_lwpid_htab, &dummy); - return lp; + lwp_info dummy (ptid_t (0, lwp, 0)); + return (struct lwp_info *) htab_find (lwp_lwpid_htab, &dummy); } /* See nat/linux-nat.h. */ diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h index 83bd6d4a6786..050b8046da48 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -202,20 +202,26 @@ struct arch_lwp_info; struct lwp_info { + lwp_info (ptid_t ptid) + : ptid (ptid) + { + waitstatus.kind = TARGET_WAITKIND_IGNORE; + } + /* The process id of the LWP. This is a combination of the LWP id and overall process id. */ ptid_t ptid; /* If this flag is set, we need to set the event request flags the next time we see this LWP stop. */ - int must_set_ptrace_flags; + int must_set_ptrace_flags = 0; /* Non-zero if we sent this LWP a SIGSTOP (but the LWP didn't report it back yet). */ - int signalled; + int signalled = 0; /* Non-zero if this LWP is stopped. */ - int stopped; + int stopped = 0; /* Non-zero if this LWP will be/has been resumed. Note that an LWP can be marked both as stopped and resumed at the same time. This @@ -223,38 +229,38 @@ struct lwp_info pending. We shouldn't let the LWP run until that wait status has been processed, but we should not report that wait status if GDB didn't try to let the LWP run. */ - int resumed; + int resumed = 0; /* The last resume GDB requested on this thread. */ - enum resume_kind last_resume_kind; + resume_kind last_resume_kind = resume_continue; /* If non-zero, a pending wait status. */ - int status; + int status = 0; /* When 'stopped' is set, this is where the lwp last stopped, with decr_pc_after_break already accounted for. If the LWP is running and stepping, this is the address at which the lwp was resumed (that is, it's the previous stop PC). If the LWP is running and not stepping, this is 0. */ - CORE_ADDR stop_pc; + CORE_ADDR stop_pc = 0; /* Non-zero if we were stepping this LWP. */ - int step; + int step = 0; /* The reason the LWP last stopped, if we need to track it (breakpoint, watchpoint, etc.). */ - enum target_stop_reason stop_reason; + target_stop_reason stop_reason = TARGET_STOPPED_BY_NO_REASON; /* On architectures where it is possible to know the data address of a triggered watchpoint, STOPPED_DATA_ADDRESS_P is non-zero, and STOPPED_DATA_ADDRESS contains such data address. Otherwise, STOPPED_DATA_ADDRESS_P is false, and STOPPED_DATA_ADDRESS is undefined. Only valid if STOPPED_BY_WATCHPOINT is true. */ - int stopped_data_address_p; - CORE_ADDR stopped_data_address; + int stopped_data_address_p = 0; + CORE_ADDR stopped_data_address = 0; /* Non-zero if we expect a duplicated SIGINT. */ - int ignore_sigint; + int ignore_sigint = 0; /* If WAITSTATUS->KIND != TARGET_WAITKIND_SPURIOUS, the waitstatus for this LWP's last event. This may correspond to STATUS above, @@ -269,15 +275,15 @@ struct lwp_info enum target_waitkind syscall_state; /* The processor core this LWP was last seen on. */ - int core; + int core = -1; /* Arch-specific additions. */ - struct arch_lwp_info *arch_private; + struct arch_lwp_info *arch_private = nullptr; /* Previous and next pointers in doubly-linked list of known LWPs, sorted by reverse creation order. */ - struct lwp_info *prev; - struct lwp_info *next; + struct lwp_info *prev = nullptr; + struct lwp_info *next = nullptr; }; /* The global list of LWPs, for ALL_LWPS. Unlike the threads list, -- 2.33.0