Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFC: extend symtabs_from_filename skipping for C++
@ 2012-02-08 20:10 Tom Tromey
  2012-02-08 22:06 ` Joel Brobecker
  2012-02-10 13:34 ` Jan Kratochvil
  0 siblings, 2 replies; 4+ messages in thread
From: Tom Tromey @ 2012-02-08 20:10 UTC (permalink / raw)
  To: gdb-patches

I'd appreciate comments on this.  Barring comments I will check it in
after a couple days.

A while ago Doug committed a patch to change linespec to skip
symtabs_from_filename when possible.  This was an important performance
improvement.

We got a bug report in Red Hat bugzilla asking that this be extended to
C++ qualified names:

    https://bugzilla.redhat.com/show_bug.cgi?id=787487

This patch implements this idea.

Built and regtested on x86-64 Fedora 15.

Tom

2012-02-08  Tom Tromey  <tromey@redhat.com>

	* linespec.c (decode_line_internal): Skip symtabs_from_filename
	when we have a C++ qualified name.

diff --git a/gdb/linespec.c b/gdb/linespec.c
index da88d17..3f53b8e 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -912,9 +912,11 @@ decode_line_internal (struct linespec_state *self, char **argptr)
   /* First things first: if ARGPTR starts with a filename, get its
      symtab and strip the filename from ARGPTR.
      Avoid calling symtab_from_filename if we know can,
-     it can be expensive.  */
+     it can be expensive.  We know we can avoid the call if we see a
+     single word (e.g., "break NAME") or if we see a qualified C++
+     name ("break QUAL::NAME").  */
 
-  if (*p != '\0')
+  if (*p != '\0' && p[1] != ':')
     {
       TRY_CATCH (file_exception, RETURN_MASK_ERROR)
 	{


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFC: extend symtabs_from_filename skipping for C++
  2012-02-08 20:10 RFC: extend symtabs_from_filename skipping for C++ Tom Tromey
@ 2012-02-08 22:06 ` Joel Brobecker
  2012-02-10 13:34 ` Jan Kratochvil
  1 sibling, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2012-02-08 22:06 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> 2012-02-08  Tom Tromey  <tromey@redhat.com>
> 
> 	* linespec.c (decode_line_internal): Skip symtabs_from_filename
> 	when we have a C++ qualified name.

FWIW, I don't see a problem with this enhancement.

> diff --git a/gdb/linespec.c b/gdb/linespec.c
> index da88d17..3f53b8e 100644
> --- a/gdb/linespec.c
> +++ b/gdb/linespec.c
> @@ -912,9 +912,11 @@ decode_line_internal (struct linespec_state *self, char **argptr)
>    /* First things first: if ARGPTR starts with a filename, get its
>       symtab and strip the filename from ARGPTR.
>       Avoid calling symtab_from_filename if we know can,
> -     it can be expensive.  */
> +     it can be expensive.  We know we can avoid the call if we see a
> +     single word (e.g., "break NAME") or if we see a qualified C++
> +     name ("break QUAL::NAME").  */
>  
> -  if (*p != '\0')
> +  if (*p != '\0' && p[1] != ':')
>      {
>        TRY_CATCH (file_exception, RETURN_MASK_ERROR)
>  	{

-- 
Joel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFC: extend symtabs_from_filename skipping for C++
  2012-02-08 20:10 RFC: extend symtabs_from_filename skipping for C++ Tom Tromey
  2012-02-08 22:06 ` Joel Brobecker
@ 2012-02-10 13:34 ` Jan Kratochvil
  2012-02-10 17:30   ` Tom Tromey
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Kratochvil @ 2012-02-10 13:34 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Wed, 08 Feb 2012 21:09:59 +0100, Tom Tromey wrote:
> --- a/gdb/linespec.c
> +++ b/gdb/linespec.c
> @@ -912,9 +912,11 @@ decode_line_internal (struct linespec_state *self, char **argptr)
>    /* First things first: if ARGPTR starts with a filename, get its
>       symtab and strip the filename from ARGPTR.
>       Avoid calling symtab_from_filename if we know can,
> -     it can be expensive.  */
> +     it can be expensive.  We know we can avoid the call if we see a
> +     single word (e.g., "break NAME") or if we see a qualified C++
> +     name ("break QUAL::NAME").  */
>  
> -  if (*p != '\0')
> +  if (*p != '\0' && p[1] != ':')

I failed to find a countercase but wouldn't you prefer:
-  if (*p != '\0')
+  if (*p != '\0' && !(p[0] == ':' && p[1] == ':'))

(I did not regression test it.)

I find it OK either way.


Thanks,
Jan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFC: extend symtabs_from_filename skipping for C++
  2012-02-10 13:34 ` Jan Kratochvil
@ 2012-02-10 17:30   ` Tom Tromey
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2012-02-10 17:30 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> I failed to find a countercase but wouldn't you prefer:
Jan> -  if (*p != '\0')
Jan> +  if (*p != '\0' && !(p[0] == ':' && p[1] == ':'))

Yeah, that is what I will check in.

Tom


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-10 17:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-08 20:10 RFC: extend symtabs_from_filename skipping for C++ Tom Tromey
2012-02-08 22:06 ` Joel Brobecker
2012-02-10 13:34 ` Jan Kratochvil
2012-02-10 17:30   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox