From patchwork Sat Oct 21 07:01:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 23744 Received: (qmail 108264 invoked by alias); 21 Oct 2017 07:01:52 -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 107793 invoked by uid 89); 21 Oct 2017 07:01:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy= X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 21 Oct 2017 07:01:49 +0000 X-ASG-Debug-ID: 1508569301-0c856e65d438095f0001-fS2M51 Received: from smtp.electronicbox.net (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id mNkpCewoKHIZUo4i (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 21 Oct 2017 03:01:41 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.lan (cable-192.222.251.162.electronicbox.net [192.222.251.162]) by smtp.electronicbox.net (Postfix) with ESMTP id 202C6441D64; Sat, 21 Oct 2017 03:01:37 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: cable-192.222.251.162.electronicbox.net[192.222.251.162] X-Barracuda-Apparent-Source-IP: 192.222.251.162 X-Barracuda-RBL-IP: 192.222.251.162 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/2] Allocate breakpoint_objfile_data with new Date: Sat, 21 Oct 2017 03:01:33 -0400 X-ASG-Orig-Subj: [PATCH 1/2] Allocate breakpoint_objfile_data with new Message-Id: <20171021070134.3962-1-simon.marchi@polymtl.ca> X-Barracuda-Connect: smtp.electronicbox.net[96.127.255.82] X-Barracuda-Start-Time: 1508569301 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 3595 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.44080 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-IsSubscribed: yes From: Simon Marchi Allocate with new and free with delete. This allows using an std::vector in the following patch. I renamed free_breakpoint_probes to free_breakpoint_objfile_data, because it now doesn't only free the probes vector, but also the breakpoint_objfile_data structure itself. gdb/ChangeLog: * breakpoint.c (breakpoint_objfile_data): Initialize fields. (get_breakpoint_objfile_data): Allocate breakpoint_objfile_data with new. (free_breakpoint_probes): Rename to ... (free_breakpoint_objfile_data): ... this, and call delete on bp_objfile_data.. --- gdb/breakpoint.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 32ceea7c9b..301d7aabff 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3183,28 +3183,28 @@ static const char *const longjmp_names[] = struct breakpoint_objfile_data { /* Minimal symbol for "_ovly_debug_event" (if any). */ - struct bound_minimal_symbol overlay_msym; + struct bound_minimal_symbol overlay_msym {}; /* Minimal symbol(s) for "longjmp", "siglongjmp", etc. (if any). */ - struct bound_minimal_symbol longjmp_msym[NUM_LONGJMP_NAMES]; + struct bound_minimal_symbol longjmp_msym[NUM_LONGJMP_NAMES] {}; /* True if we have looked for longjmp probes. */ - int longjmp_searched; + int longjmp_searched = 0; /* SystemTap probe points for longjmp (if any). */ - VEC (probe_p) *longjmp_probes; + VEC (probe_p) *longjmp_probes = NULL; /* Minimal symbol for "std::terminate()" (if any). */ - struct bound_minimal_symbol terminate_msym; + struct bound_minimal_symbol terminate_msym {}; /* Minimal symbol for "_Unwind_DebugHook" (if any). */ - struct bound_minimal_symbol exception_msym; + struct bound_minimal_symbol exception_msym {}; /* True if we have looked for exception probes. */ - int exception_searched; + int exception_searched = 0; /* SystemTap probe points for unwinding (if any). */ - VEC (probe_p) *exception_probes; + VEC (probe_p) *exception_probes = NULL; }; static const struct objfile_data *breakpoint_objfile_key; @@ -3232,23 +3232,22 @@ get_breakpoint_objfile_data (struct objfile *objfile) objfile_data (objfile, breakpoint_objfile_key)); if (bp_objfile_data == NULL) { - bp_objfile_data = - XOBNEW (&objfile->objfile_obstack, struct breakpoint_objfile_data); - - memset (bp_objfile_data, 0, sizeof (*bp_objfile_data)); + bp_objfile_data = new breakpoint_objfile_data (); set_objfile_data (objfile, breakpoint_objfile_key, bp_objfile_data); } return bp_objfile_data; } static void -free_breakpoint_probes (struct objfile *obj, void *data) +free_breakpoint_objfile_data (struct objfile *obj, void *data) { struct breakpoint_objfile_data *bp_objfile_data = (struct breakpoint_objfile_data *) data; VEC_free (probe_p, bp_objfile_data->longjmp_probes); VEC_free (probe_p, bp_objfile_data->exception_probes); + + delete bp_objfile_data; } static void @@ -15540,7 +15539,7 @@ _initialize_breakpoint (void) observer_attach_memory_changed (invalidate_bp_value_on_memory_change); breakpoint_objfile_key - = register_objfile_data_with_cleanup (NULL, free_breakpoint_probes); + = register_objfile_data_with_cleanup (NULL, free_breakpoint_objfile_data); breakpoint_chain = 0; /* Don't bother to call set_breakpoint_count. $bpnum isn't useful