Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Markus Metzger <markus.t.metzger@intel.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] btrace: only search for lines in current symtab
Date: Fri, 21 Mar 2014 17:43:00 -0000	[thread overview]
Message-ID: <20140321174322.GA15430@host2.jankratochvil.net> (raw)
In-Reply-To: <1394182665-14164-2-git-send-email-markus.t.metzger@intel.com>

On Fri, 07 Mar 2014 09:57:44 +0100, Markus Metzger wrote:
[...]
> @@ -543,32 +532,39 @@ ftrace_update_function (struct gdbarch *gdbarch,
>  static void
>  ftrace_update_lines (struct btrace_function *bfun, CORE_ADDR pc)
>  {
> -  struct symtab_and_line sal;
> -  const char *fullname;
> +  struct linetable *lines;
> +  struct symtab *symtab;
> +  int i;
>  
> -  sal = find_pc_line (pc, 0);
> -  if (sal.symtab == NULL || sal.line == 0)
> -    {
> -      DEBUG_FTRACE ("no lines at %s", core_addr_to_string_nz (pc));
> -      return;
> -    }
> +  symtab = bfun->symtab;
> +  if (symtab == NULL)
> +    return;
> +
> +  lines = LINETABLE (symtab);
> +  if (lines == NULL)
> +    return;
>  
> -  /* Check if we switched files.  This could happen if, say, a macro that
> -     is defined in another file is expanded here.  */
> -  fullname = symtab_to_fullname (sal.symtab);
> -  if (ftrace_skip_file (bfun, fullname))
> +  for (i = 0; i < lines->nitems; ++i)

The line table has ordered PC values so one can find the right line in
logarithmic time.


>      {
> -      DEBUG_FTRACE ("ignoring file at %s, file=%s",
> -		    core_addr_to_string_nz (pc), fullname);
> -      return;
> -    }
> +      struct linetable_entry *entry;
>  
> -  /* Update the line range.  */
> -  bfun->lbegin = min (bfun->lbegin, sal.line);
> -  bfun->lend = max (bfun->lend, sal.line);
> +      entry = &lines->item[i];
> +      if (entry->pc == pc)

This is not right, PC can be between two ENTRY->PC values and it should match
the former line.  This implementation would not find a matching line.



> +	{
> +	  int line;
>  
> -  if (record_debug > 1)
> -    ftrace_debug (bfun, "update lines");
> +	  line = entry->line;
> +
> +	  /* Update the line range.  */
> +	  bfun->lbegin = min (bfun->lbegin, line);
> +	  bfun->lend = max (bfun->lend, line);
> +
> +	  if (record_debug > 1)
> +	    ftrace_debug (bfun, "update lines");
> +
> +	  break;
> +	}
> +    }
>  }
>  
>  /* Add the instruction at PC to BFUN's instructions.  */


I do not think this is the right approach, find_pc_sect_line() can be improved
to at least look up the lines in logarithmic time by bisecting the range.
It could also use some cache of recent lookups.

Also I am not sure this new implementation handles correctly include files and
their boundaries, which find_pc_sect_line() has to take care of.

This is my personal opinion unrelated to GDB project maintainers' opinion.


Regards,
Jan


      reply	other threads:[~2014-03-21 17:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07  8:57 [PATCH 0/2] btrace: perf improvements Markus Metzger
2014-03-07  8:57 ` [PATCH 2/2] btrace: avoid symbol lookup Markus Metzger
2014-03-07 15:55   ` Pedro Alves
2014-03-10  8:05     ` Metzger, Markus T
2014-03-07 15:56   ` Pedro Alves
2014-03-10 21:43   ` Jan Kratochvil
2014-03-11 10:08     ` Metzger, Markus T
2014-03-21 17:22       ` Jan Kratochvil
2014-03-24  7:57         ` Metzger, Markus T
2014-03-24  8:37           ` Jan Kratochvil
2014-03-24  9:21             ` Metzger, Markus T
2014-03-07  8:57 ` [PATCH 1/2] btrace: only search for lines in current symtab Markus Metzger
2014-03-21 17:43   ` Jan Kratochvil [this message]

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=20140321174322.GA15430@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=markus.t.metzger@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