From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4965 invoked by alias); 29 Sep 2011 15:15:10 -0000 Received: (qmail 4955 invoked by uid 22791); 29 Sep 2011 15:15:08 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 29 Sep 2011 15:14:50 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8TFESYp030230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 29 Sep 2011 11:14:28 -0400 Received: from host1.jankratochvil.net (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p8TFEPhq024812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 29 Sep 2011 11:14:27 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p8TFEOuB001294; Thu, 29 Sep 2011 17:14:24 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p8TFENg7001293; Thu, 29 Sep 2011 17:14:23 +0200 Date: Thu, 29 Sep 2011 15:33:00 -0000 From: Jan Kratochvil To: Joel Brobecker Cc: gdb-patches@sourceware.org Subject: [patch#2] Fix initial language with -readnow, regressed by: RFC: add DWARF index support Message-ID: <20110929151423.GA1124@host1.jankratochvil.net> References: <20110928220344.GA17977@host1.jankratochvil.net> <20110928230742.GB19246@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110928230742.GB19246@adacore.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-09/txt/msg00549.txt.bz2 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 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 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 . */ + +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 . + +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\+\+"\.}