This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [PATCH v4 04/12] btrace: Use function segment index in call iterator.
Hi Markus,
Thanks for your input!
> -----Original Message-----
> From: Metzger, Markus T
> Sent: Thursday, May 11, 2017 12:03 PM
> To: Wiederhake, Tim <tim.wiederhake@intel.com>; gdb-patches@sourceware.org
> Cc: simon.marchi@polymtl.ca
> Subject: RE: [PATCH v4 04/12] btrace: Use function segment index in call
> iterator.
>
> Hello Tim,
>
> > /* See btrace.h. */
> > @@ -2702,26 +2684,14 @@ btrace_find_call_by_number (struct
> > btrace_call_iterator *it,
> > const struct btrace_thread_info *btinfo,
> > unsigned int number)
> > {
> > - const struct btrace_function *bfun;
> > + const unsigned int length = btinfo->functions.size ();
> >
> > - for (bfun = btinfo->end; bfun != NULL; bfun = bfun->flow.prev)
> > - {
> > - unsigned int bnum;
> > -
> > - bnum = bfun->number;
> > - if (number == bnum)
> > - {
> > - it->btinfo = btinfo;
> > - it->function = bfun;
> > - return 1;
> > - }
> > -
> > - /* Functions are ordered and numbered consecutively. We could
> bail out
> > - earlier. On the other hand, it is very unlikely that we search for
> > - a nonexistent function. */
> > - }
> > + if ((number == 0) || (number > length))
> > + return 0;
> >
> > - return 0;
> > + it->btinfo = btinfo;
> > + it->index = number - 1;
> > + return 1;
> > }
>
> We have those +1 and -1 operations throughout the code. Should we
> introduce
> some small helpers to document what we're doing? E.g.
>
> static inline unsigned int btrace_call_number_from_index (unsigned int
> call_index)
> {
> return call_index + 1;
> }
>
> and
>
> static inline unsigned int btrace_call_number_to_index (unsigned int
> call_number)
> {
> return call_number - 1;
> }
>
Most of these manual adjustments are temporary and are replaced in later patches in this series. I replaced the remaining adjustments in record-btrace.c with calls to find_call_by_number which leaves us with only three occurrences in btrace.c, where we actually write to btrace_call_iterator.
> Regards,
> Markus.
Tim
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928