Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@codesourcery.com>
To: Jean-Marc Saffroy <saffroy@gmail.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH] gdb script performance
Date: Thu, 30 Nov 2006 01:04:00 -0000	[thread overview]
Message-ID: <m38xhtagmk.fsf@codesourcery.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0611300025340.5248@erda.mds> (Jean-Marc Saffroy's message of "Thu, 30 Nov 2006 01:33:02 +0100 (CET)")


Jean-Marc Saffroy <saffroy@gmail.com> writes:
> Index: gdb-6.5-prof/gdb/symtab.c
> ===================================================================
> --- gdb-6.5-prof.orig/gdb/symtab.c	2006-11-29 03:27:18.000000000 +0100
> +++ gdb-6.5-prof/gdb/symtab.c	2006-11-29 03:27:20.000000000 +0100
> @@ -2022,8 +2022,8 @@
>  /* Find the symtab associated with PC and SECTION.  Look through the
>     psymtabs and read in another symtab if necessary. */
>
> -struct symtab *
> -find_pc_sect_symtab (CORE_ADDR pc, asection *section)
> +static struct symtab *
> +find_pc_sect_symtab_uncached (CORE_ADDR pc, asection *section)
>  {
>    struct block *b;
>    struct blockvector *bv;
> @@ -2123,6 +2123,24 @@
>    return (s);
>  }
>
> +struct symtab *
> +find_pc_sect_symtab (CORE_ADDR pc, asection *section)
> +{
> +  static CORE_ADDR cached_pc;
> +  static asection *cached_section;
> +  static struct symtab *cached_symtab;
> +  static int try_cache = 0;
> +
> +  if (try_cache && (cached_pc == pc) && (cached_section == section))
> +    return cached_symtab;
> +
> +  try_cache = 1;
> +  cached_pc = pc;
> +  cached_section = section;
> +  cached_symtab = find_pc_sect_symtab_uncached (pc, section);
> +  return cached_symtab;
> +}
> +
>  /* Find the symtab associated with PC.  Look through the psymtabs and
>     read in another symtab if necessary.  Backward compatibility, no section */

When the user changes the symbol file (or when GDB notices it has
changed and automatically re-reads it), the section and symtab objects
your static variables are pointing to will be freed.  If you then get
a spurious cache hit, you'll hand out a pointer to garbage.  So you'll
need to invalidate the cache whenever the section or symtab get freed.


  reply	other threads:[~2006-11-30  1:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-30  0:33 Jean-Marc Saffroy
2006-11-30  1:04 ` Jim Blandy [this message]
2006-11-30 13:19   ` Jean-Marc Saffroy
2006-11-30 21:54     ` Michael Snyder
2006-11-30  3:13 ` Daniel Jacobowitz
2006-11-30 13:57   ` Jean-Marc Saffroy
2006-12-05 21:02     ` Daniel Jacobowitz

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=m38xhtagmk.fsf@codesourcery.com \
    --to=jimb@codesourcery.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=saffroy@gmail.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