From: "Metzger, Markus T" <markus.t.metzger@intel.com>
To: "Wiederhake, Tim" <tim.wiederhake@intel.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: "simon.marchi@polymtl.ca" <simon.marchi@polymtl.ca>
Subject: RE: [PATCH v4 04/12] btrace: Use function segment index in call iterator.
Date: Thu, 11 May 2017 10:02:00 -0000 [thread overview]
Message-ID: <A78C989F6D9628469189715575E55B2340088704@IRSMSX104.ger.corp.intel.com> (raw)
In-Reply-To: <1494416867-19612-5-git-send-email-tim.wiederhake@intel.com>
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;
}
Regards,
Markus.
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
next prev parent reply other threads:[~2017-05-11 10:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-10 11:47 [PATCH v4 00/12] btrace: Turn linked list of function call segments into vector Tim Wiederhake
2017-05-10 11:48 ` [PATCH v4 02/12] btrace: Transfer ownership of pointers Tim Wiederhake
2017-05-10 11:48 ` [PATCH v4 06/12] btrace: Remove constant arguments Tim Wiederhake
2017-05-10 11:48 ` [PATCH v4 10/12] btrace: Replace struct btrace_function::segment Tim Wiederhake
2017-05-10 11:48 ` [PATCH v4 03/12] btrace: Add btinfo to instruction interator Tim Wiederhake
2017-05-10 11:48 ` [PATCH v4 08/12] btrace: Replace struct btrace_function::up Tim Wiederhake
2017-05-10 11:48 ` [PATCH v4 12/12] btrace: Store function segments as objects Tim Wiederhake
2017-05-10 11:48 ` [PATCH v4 07/12] btrace: Remove struct btrace_thread_info::{begin,end} Tim Wiederhake
2017-05-11 10:02 ` Metzger, Markus T
2017-05-10 11:48 ` [PATCH v4 04/12] btrace: Use function segment index in call iterator Tim Wiederhake
2017-05-11 10:02 ` Metzger, Markus T [this message]
2017-05-17 7:56 ` Wiederhake, Tim
2017-05-10 11:48 ` [PATCH v4 05/12] btrace: Use function segment index in insn iterator Tim Wiederhake
2017-05-10 11:48 ` [PATCH v4 01/12] btrace: Use std::vector in struct btrace_thread_information Tim Wiederhake
2017-05-10 11:48 ` [PATCH v4 11/12] btrace: Remove bfun_s vector Tim Wiederhake
2017-05-10 11:48 ` [PATCH v4 09/12] btrace: Remove struct btrace_function::flow Tim Wiederhake
2017-05-10 14:46 ` [PATCH v4 00/12] btrace: Turn linked list of function call segments into vector Simon Marchi
2017-05-11 7:20 ` Wiederhake, Tim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A78C989F6D9628469189715575E55B2340088704@IRSMSX104.ger.corp.intel.com \
--to=markus.t.metzger@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
--cc=tim.wiederhake@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox