From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120325 invoked by alias); 10 May 2017 04:27:35 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 120052 invoked by uid 89); 10 May 2017 04:27:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=is! X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 May 2017 04:27:09 +0000 Received: by simark.ca (Postfix, from userid 33) id 00C9E1E4A4; Wed, 10 May 2017 00:27:10 -0400 (EDT) To: Tim Wiederhake Subject: Re: [PATCH v3 11/12] btrace: Remove bfun_s vector. X-PHP-Originating-Script: 33:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 10 May 2017 04:27:00 -0000 From: Simon Marchi Cc: gdb-patches@sourceware.org, markus.t.metzger@intel.com In-Reply-To: <1494312929-22749-12-git-send-email-tim.wiederhake@intel.com> References: <1494312929-22749-1-git-send-email-tim.wiederhake@intel.com> <1494312929-22749-12-git-send-email-tim.wiederhake@intel.com> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.2.5 X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00241.txt.bz2 On 2017-05-09 02:55, Tim Wiederhake wrote: > 2017-05-09 Tim Wiederhake > > gdb/ChangeLog: > > * btrace.c: Remove typedef bfun_s. > (ftrace_new_gap): Directly add gaps to the list of gaps. > (btrace_bridge_gaps, btrace_compute_ftrace_bts, pt_btrace_insn_flags, > ftrace_add_pt, btrace_compute_ftrace_pt, btrace_compute_ftrace_1, > btrace_finalize_ftrace, btrace_compute_ftrace): Use std::vector > instead of gdb VEC. Looks good, just two nits. > @@ -527,15 +524,15 @@ ftrace_new_gap (struct btrace_thread_info > *btinfo, int errcode) > } > > bfun->errcode = errcode; > + gaps.push_back (bfun->number); > > ftrace_debug (bfun, "new gap"); > > return bfun; > } > > -/* Update BFUN with respect to the instruction at PC. BTINFO is the > branch > - trace information for the current thread. This may create new > function > - segments. > +/* Update the current function segment at the end of the trace in > BTINFO with > + respect to the instruction at PC. This may create new function > segments. > Return the chronologically latest function segment, never NULL. */ Ah here it is! Please move it to the appropriate patch (#6 I believe). > @@ -978,16 +970,15 @@ btrace_bridge_gaps (struct thread_info *tp, VEC > (bfun_s) **gaps) > { > /* Let's try to bridge as many gaps as we can. In some cases, > we need to > skip a gap and revisit it again after we closed later gaps. */ > - while (!VEC_empty (bfun_s, *gaps)) > + while (!gaps.empty ()) > { > - struct btrace_function *gap; > - unsigned int idx; > - > - for (idx = 0; VEC_iterate (bfun_s, *gaps, idx, gap); ++idx) > + for (const auto& number : gaps) If you don't intend to modify number (the value in the vector), I think it would be actually more efficient to not use a reference to iterate on ints. Also, I agree with using auto when the type it replaces is visually scary, but in this case I think it would be as readable and more informative to use the actual type: for (unsigned int number : gaps) Thanks, Simon