Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Fix initial language with -readnow, regressed by: RFC: add DWARF index support
@ 2011-09-28 23:08 Jan Kratochvil
  2011-09-28 23:12 ` Joel Brobecker
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2011-09-28 23:08 UTC (permalink / raw)
  To: gdb-patches

Hi,

if you use -readnow the common autodetection
	The current source language is "auto; currently c++".
fails
	The current source language is "auto; currently c".
causing various C++ handling problems.

dw2_find_symbol_file:
  /* index_table is NULL if OBJF_READNOW.  */
  if (!dwarf2_per_objfile->index_table)
    return NULL;

There are only 'skip'ped commits left to test.
The first bad commit could be any of:
28cfc710ba3d9959cedd0f345bb212666cc6890f
cf9fe5cf2be8b76820a05c966cdca6df5c2eee24
3363422556d95de01c4a262489fec8d6b5506d01
We cannot bisect more!
bisect run cannot continue any more

No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu.
I will check it in.


Thanks,
Jan


gdb/
2011-09-28  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix initial language detection with -readnow.
	* symtab.c (find_main_filename): New variables sym and readnow_seen.
	Use them for lookup_symbol.

gdb/testsuite/
2011-09-28  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix initial language detection with -readnow.
	* gdb.cp/readnow-language.cc: New file.
	* gdb.cp/readnow-language.exp: New file.

--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1687,17 +1687,30 @@ find_main_filename (void)
 {
   struct objfile *objfile;
   char *name = main_name ();
+  struct symbol *sym;
+  int readnow_seen = 0;
 
   ALL_OBJFILES (objfile)
   {
     const char *result;
 
+    readnow_seen |= (objfile->flags & OBJF_READNOW) != 0;
+
     if (!objfile->sf)
       continue;
     result = objfile->sf->qf->find_symbol_file (objfile, name);
     if (result)
       return result;
   }
+
+  /* OBJF_READNOW does not provide any index to look up above.  */
+  if (readnow_seen)
+    {
+      sym = lookup_symbol (name, NULL, VAR_DOMAIN, NULL);
+      if (sym)
+	return sym->symtab->filename;
+    }
+
   return (NULL);
 }
 
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/readnow-language.cc
@@ -0,0 +1,21 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+int
+main ()
+{
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/readnow-language.exp
@@ -0,0 +1,28 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+set testfile readnow-language
+set srcfile ${testfile}.cc
+set executable ${testfile}
+if {[build_executable ${testfile}.exp $executable ${testfile}.cc {c++ debug}] == -1} {
+    return -1
+}
+
+set old_gdbflags $GDBFLAGS
+set GDBFLAGS "$GDBFLAGS -readnow"
+clean_restart $executable
+set GDBFLAGS $old_gdbflags
+
+gdb_test "show language" {The current source language is "auto; currently c\+\+"\.}


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

* Re: [patch] Fix initial language with -readnow, regressed by: RFC: add DWARF index support
  2011-09-28 23:08 [patch] Fix initial language with -readnow, regressed by: RFC: add DWARF index support Jan Kratochvil
@ 2011-09-28 23:12 ` Joel Brobecker
  2011-09-28 23:20   ` Jan Kratochvil
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Joel Brobecker @ 2011-09-28 23:12 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

> if you use -readnow the common autodetection
> 	The current source language is "auto; currently c++".
> fails
> 	The current source language is "auto; currently c".
> causing various C++ handling problems.

Umpf.

> +  /* OBJF_READNOW does not provide any index to look up above.  */
> +  if (readnow_seen)
> +    {
> +      sym = lookup_symbol (name, NULL, VAR_DOMAIN, NULL);
> +      if (sym)
> +	return sym->symtab->filename;
> +    }

I keep dreaming of a world where there is one interface for lookups
and we don't have to worry whether there is an index, or psymtabs,
or whatever...

-- 
Joel


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

* Re: [patch] Fix initial language with -readnow, regressed by: RFC: add DWARF index support
  2011-09-28 23:12 ` Joel Brobecker
@ 2011-09-28 23:20   ` Jan Kratochvil
  2011-09-29 15:33   ` [patch#2] " Jan Kratochvil
  2011-10-03 19:49   ` [patch] " Tom Tromey
  2 siblings, 0 replies; 7+ messages in thread
From: Jan Kratochvil @ 2011-09-28 23:20 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Thu, 29 Sep 2011 01:07:42 +0200, Joel Brobecker wrote:
> I keep dreaming of a world where there is one interface for lookups
> and we don't have to worry whether there is an index, or psymtabs,
> or whatever...

I agree it should be rather fixed in dw2_find_symbol_file, I will post
a different patch.


Thanks,
Jan


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

* [patch#2] Fix initial language with -readnow, regressed by: RFC: add DWARF index support
  2011-09-28 23:12 ` Joel Brobecker
  2011-09-28 23:20   ` Jan Kratochvil
@ 2011-09-29 15:33   ` Jan Kratochvil
  2011-10-03 19:56     ` Tom Tromey
  2011-10-03 19:49   ` [patch] " Tom Tromey
  2 siblings, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2011-09-29 15:33 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Thu, 29 Sep 2011 01:07:42 +0200, Joel Brobecker wrote:
> I keep dreaming of a world where there is one interface for lookups
> and we don't have to worry whether there is an index, or psymtabs,
> or whatever...

So I fixed rather the method implementation than to workaround it in the caller.

BTW find_main_filename is the only caller of ->find_symbol_file.

dw2_find_symbol_file has an existing bug/regression as for !OBJF_READNOW it
searches even static symbols but for find_main_filename it should not matter.
psymtab.c find_symbol_file_from_partial searches only for global symbols.

No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu.


Thanks,
Jan


gdb/
2011-09-29  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix initial language detection with -readnow.
	* dwarf2read.c (dw2_find_symbol_file): Handle OBJF_READNOW case.
	* symfile.h (struct quick_symbol_functions): State find_symbol_file
	searches only for global symbols.

gdb/testsuite/
2011-09-29  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix initial language detection with -readnow.
	* gdb.cp/readnow-language.cc: New file.
	* gdb.cp/readnow-language.exp: New file.

--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -2650,7 +2650,21 @@ dw2_find_symbol_file (struct objfile *objfile, const char *name)
 
   /* index_table is NULL if OBJF_READNOW.  */
   if (!dwarf2_per_objfile->index_table)
-    return NULL;
+    {
+      struct symtab *s;
+
+      ALL_OBJFILE_SYMTABS (objfile, s)
+	if (s->primary)
+	  {
+	    struct blockvector *bv = BLOCKVECTOR (s);
+	    const struct block *block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+	    struct symbol *sym = lookup_block_symbol (block, name, VAR_DOMAIN);
+
+	    if (sym)
+	      return sym->symtab->filename;
+	  }
+      return NULL;
+    }
 
   if (!find_slot_in_mapped_hash (dwarf2_per_objfile->index_table,
 				 name, &vec))
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -222,7 +222,7 @@ struct quick_symbol_functions
   void (*expand_symtabs_with_filename) (struct objfile *objfile,
 					const char *filename);
 
-  /* Return the file name of the file holding the symbol in OBJFILE
+  /* Return the file name of the file holding the global symbol in OBJFILE
      named NAME.  If no such symbol exists in OBJFILE, return NULL.  */
   const char *(*find_symbol_file) (struct objfile *objfile, const char *name);
 
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/readnow-language.cc
@@ -0,0 +1,21 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+int
+main ()
+{
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/readnow-language.exp
@@ -0,0 +1,28 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+set testfile readnow-language
+set srcfile ${testfile}.cc
+set executable ${testfile}
+if {[build_executable ${testfile}.exp $executable ${testfile}.cc {c++ debug}] == -1} {
+    return -1
+}
+
+set old_gdbflags $GDBFLAGS
+set GDBFLAGS "$GDBFLAGS -readnow"
+clean_restart $executable
+set GDBFLAGS $old_gdbflags
+
+gdb_test "show language" {The current source language is "auto; currently c\+\+"\.}


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

* Re: [patch] Fix initial language with -readnow, regressed by: RFC: add DWARF index support
  2011-09-28 23:12 ` Joel Brobecker
  2011-09-28 23:20   ` Jan Kratochvil
  2011-09-29 15:33   ` [patch#2] " Jan Kratochvil
@ 2011-10-03 19:49   ` Tom Tromey
  2 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2011-10-03 19:49 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Jan Kratochvil, gdb-patches

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

Joel> I keep dreaming of a world where there is one interface for lookups
Joel> and we don't have to worry whether there is an index, or psymtabs,
Joel> or whatever...

I agree, and I think that any divergences from this ideal -- from the
caller's point of view -- are bugs.  I tried pretty hard to present a
uniform interface to psymtabs and the like; not a pretty interface, but
uniform :)

Tom


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

* Re: [patch#2] Fix initial language with -readnow, regressed by: RFC: add DWARF index support
  2011-09-29 15:33   ` [patch#2] " Jan Kratochvil
@ 2011-10-03 19:56     ` Tom Tromey
  2011-10-09 18:38       ` Jan Kratochvil
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2011-10-03 19:56 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Joel Brobecker, gdb-patches

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

Jan> So I fixed rather the method implementation than to workaround it
Jan> in the caller.

Thanks.

This looks good.

Jan> BTW find_main_filename is the only caller of ->find_symbol_file.

The main-finding code has caused issues for various laziness patches
I've worked on.  It would be nice to replace it.

Also I tripped across the call to set_main_name in dwarf2read.c ... it
seems bad for debuginfo reading to set global state.  (Instead it could,
say, set a field on the objfile...)

Tom


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

* Re: [patch#2] Fix initial language with -readnow, regressed by: RFC: add DWARF index support
  2011-10-03 19:56     ` Tom Tromey
@ 2011-10-09 18:38       ` Jan Kratochvil
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Kratochvil @ 2011-10-09 18:38 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Joel Brobecker, gdb-patches

On Mon, 03 Oct 2011 21:55:21 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> 
> Jan> So I fixed rather the method implementation than to workaround it
> Jan> in the caller.
> 
> Thanks.
> 
> This looks good.

Checked in:
	http://sourceware.org/ml/gdb-cvs/2011-10/msg00053.html


> The main-finding code has caused issues for various laziness patches
> I've worked on.  It would be nice to replace it.

Yes. :-)


Thanks,
Jan


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

end of thread, other threads:[~2011-10-09 18:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-28 23:08 [patch] Fix initial language with -readnow, regressed by: RFC: add DWARF index support Jan Kratochvil
2011-09-28 23:12 ` Joel Brobecker
2011-09-28 23:20   ` Jan Kratochvil
2011-09-29 15:33   ` [patch#2] " Jan Kratochvil
2011-10-03 19:56     ` Tom Tromey
2011-10-09 18:38       ` Jan Kratochvil
2011-10-03 19:49   ` [patch] " Tom Tromey

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