From patchwork Sun Feb 25 16:32:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 26044 Received: (qmail 41062 invoked by alias); 25 Feb 2018 16:32:56 -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 41036 invoked by uid 89); 25 Feb 2018 16:32:55 -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=sk:deleted, Hx-languages-length:4778 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; Sun, 25 Feb 2018 16:32:54 +0000 X-ASG-Debug-ID: 1519576370-0c856e6189e3b00001-fS2M51 Received: from smtp.ebox.ca (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id Mvmf5OHI3FBQYS5v (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 25 Feb 2018 11:32:50 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.lan (192-222-251-162.qc.cable.ebox.net [192.222.251.162]) by smtp.ebox.ca (Postfix) with ESMTP id 39587441D80; Sun, 25 Feb 2018 11:32:50 -0500 (EST) From: Simon Marchi X-Barracuda-Effective-Source-IP: 192-222-251-162.qc.cable.ebox.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 3/5] Make program_space::deleted_solibs a vector of std::string Date: Sun, 25 Feb 2018 11:32:45 -0500 X-ASG-Orig-Subj: [PATCH 3/5] Make program_space::deleted_solibs a vector of std::string Message-Id: <20180225163247.20157-3-simon.marchi@polymtl.ca> In-Reply-To: <20180225163247.20157-1-simon.marchi@polymtl.ca> References: <20180225163247.20157-1-simon.marchi@polymtl.ca> X-Barracuda-Connect: smtp.electronicbox.net[96.127.255.82] X-Barracuda-Start-Time: 1519576370 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: 5195 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.48309 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-IsSubscribed: yes This allows removing a usage of free_char_ptr_vec. gdb/ChangeLog: * progspace.h (struct program_space) : Change type to std::vector. * progspace.c (clear_program_space_solib_cache): Adjust. * breakpoint.c (print_solib_event): Adjust. (check_status_catch_solib): Adjust. * solib.c (update_solib_list): Adjust. * ui-out.h (class ui_out) : New overload. * ui-out.c (ui_out::field_string): New overload. --- gdb/breakpoint.c | 25 +++++++------------------ gdb/progspace.c | 3 +-- gdb/progspace.h | 2 +- gdb/solib.c | 3 +-- gdb/ui-out.c | 6 ++++++ gdb/ui-out.h | 1 + 6 files changed, 17 insertions(+), 23 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index c56084cce3..454fda7684 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4604,8 +4604,7 @@ print_bp_stop_message (bpstat bs) static void print_solib_event (int is_catchpoint) { - int any_deleted - = !VEC_empty (char_ptr, current_program_space->deleted_solibs); + bool any_deleted = !current_program_space->deleted_solibs.empty (); int any_added = !VEC_empty (so_list_ptr, current_program_space->added_solibs); @@ -4624,16 +4623,12 @@ print_solib_event (int is_catchpoint) if (any_deleted) { - char *name; - int ix; - current_uiout->text (_(" Inferior unloaded ")); ui_out_emit_list list_emitter (current_uiout, "removed"); - for (ix = 0; - VEC_iterate (char_ptr, current_program_space->deleted_solibs, - ix, name); - ++ix) + for (int ix = 0; ix < current_program_space->deleted_solibs.size (); ix++) { + const std::string &name = current_program_space->deleted_solibs[ix]; + if (ix > 0) current_uiout->text (" "); current_uiout->field_string ("library", name); @@ -8050,13 +8045,12 @@ check_status_catch_solib (struct bpstats *bs) { struct solib_catchpoint *self = (struct solib_catchpoint *) bs->breakpoint_at; - int ix; if (self->is_load) { struct so_list *iter; - for (ix = 0; + for (int ix = 0; VEC_iterate (so_list_ptr, current_program_space->added_solibs, ix, iter); ++ix) @@ -8068,15 +8062,10 @@ check_status_catch_solib (struct bpstats *bs) } else { - char *iter; - - for (ix = 0; - VEC_iterate (char_ptr, current_program_space->deleted_solibs, - ix, iter); - ++ix) + for (const std::string &iter : current_program_space->deleted_solibs) { if (!self->regex - || self->compiled->exec (iter, 0, NULL, 0) == 0) + || self->compiled->exec (iter.c_str (), 0, NULL, 0) == 0) return; } } diff --git a/gdb/progspace.c b/gdb/progspace.c index f6da7e7da2..e0bcc5a18d 100644 --- a/gdb/progspace.c +++ b/gdb/progspace.c @@ -401,8 +401,7 @@ clear_program_space_solib_cache (struct program_space *pspace) { VEC_free (so_list_ptr, pspace->added_solibs); - free_char_ptr_vec (pspace->deleted_solibs); - pspace->deleted_solibs = NULL; + pspace->deleted_solibs.clear (); } diff --git a/gdb/progspace.h b/gdb/progspace.h index c64209c5df..67c0a240da 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -207,7 +207,7 @@ struct program_space /* When an solib is removed, its name is added to this vector. This is so we can properly report solib changes to the user. */ - VEC (char_ptr) *deleted_solibs = NULL; + std::vector deleted_solibs; /* Per pspace data-pointers required by other GDB modules. */ REGISTRY_FIELDS {}; diff --git a/gdb/solib.c b/gdb/solib.c index f3eea399e0..1c78845938 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -828,8 +828,7 @@ update_solib_list (int from_tty) unloaded before we remove it from GDB's tables. */ observer_notify_solib_unloaded (gdb); - VEC_safe_push (char_ptr, current_program_space->deleted_solibs, - xstrdup (gdb->so_name)); + current_program_space->deleted_solibs.push_back (gdb->so_name); *gdb_link = gdb->next; diff --git a/gdb/ui-out.c b/gdb/ui-out.c index 8785bfbfa6..0340a44a83 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -552,6 +552,12 @@ ui_out::field_string (const char *fldname, const char *string) do_field_string (fldno, width, align, fldname, string); } +void +ui_out::field_string (const char *fldname, const std::string &string) +{ + field_string (fldname, string.c_str ()); +} + /* VARARGS */ void ui_out::field_fmt (const char *fldname, const char *format, ...) diff --git a/gdb/ui-out.h b/gdb/ui-out.h index ce224ed225..1708542e7e 100644 --- a/gdb/ui-out.h +++ b/gdb/ui-out.h @@ -104,6 +104,7 @@ class ui_out void field_core_addr (const char *fldname, struct gdbarch *gdbarch, CORE_ADDR address); void field_string (const char *fldname, const char *string); + void field_string (const char *fldname, const std::string &string); void field_stream (const char *fldname, string_file &stream); void field_skip (const char *fldname); void field_fmt (const char *fldname, const char *format, ...)