public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [0/4] RFC: add DWARF index support
@ 2010-06-30 22:33 Tom Tromey
  2010-07-09 17:31 ` Tom Tromey
  2010-07-13 20:42 ` Tom Tromey
  0 siblings, 2 replies; 34+ messages in thread
From: Tom Tromey @ 2010-06-30 22:33 UTC (permalink / raw)
  To: gdb-patches

This patch series adds support for a DWARF index to gdb.

The idea is to speed up gdb startup time by constructing a read-only
mmap()able index for the DWARF.  Then, rather than create psymtabs, we
simply map in this index and use it.

You can see some performance results for the index here (read the whole
thread, some initial results were wrong):

    http://sourceware.org/ml/archer/2010-q2/msg00055.html

This code is somewhat complementary to my earlier series to read
psymtabs in the background.  I haven't yet merged the two; but when I do
so I think I will also arrange for the index file to be mapped in a
background thread (to avoid needless I/O waits during startup).

I did investigate some other approaches before discarding them:

* Use the existing .debug_pubnames and .debug_pubtypes sections.  These
  are specified by DWARF, so they would be preferable.

  However, they don't include all the information that gdb needs (in
  particular, static symbols and enum constants), and due to C++ name
  canonicalization, actually reading these sections is just as slow as
  using psymtabs.

* Use sqlite instead of our own format.  sqlite is just too slow for our
  purposes (it takes way too long to make the index) and also the
  resulting database files are much bigger.

I'd appreciate comments on this.  

Tom

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

* Re: [0/4] RFC: add DWARF index support
  2010-06-30 22:33 [0/4] RFC: add DWARF index support Tom Tromey
@ 2010-07-09 17:31 ` Tom Tromey
  2010-07-09 17:45   ` Eli Zaretskii
                     ` (2 more replies)
  2010-07-13 20:42 ` Tom Tromey
  1 sibling, 3 replies; 34+ messages in thread
From: Tom Tromey @ 2010-07-09 17:31 UTC (permalink / raw)
  To: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> This patch series adds support for a DWARF index to gdb.

Roland suggested we wrap up the index-creation code into a helper
script.

I'm not sure if this is something people would want in gdb proper, but I
figured I would send it here just in case.

Tom

2010-07-09  Tom Tromey  <tromey@redhat.com>

	* Makefile.in (install-only): Install gdb-add-index.
	* gdb-add-index: New file.

2010-07-09  Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (Index Files): Mention gdb-add-index.

From 30714fe719e61baea03d0dc5793eb0d564faebb7 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Fri, 9 Jul 2010 11:17:54 -0600
Subject: [PATCH 4/4] add gdb-add-index

---
 gdb/ChangeLog       |    5 +++++
 gdb/Makefile.in     |   11 ++++++++++-
 gdb/doc/ChangeLog   |    4 ++++
 gdb/doc/gdb.texinfo |    8 ++++++++
 gdb/gdb-add-index   |   30 ++++++++++++++++++++++++++++++
 5 files changed, 57 insertions(+), 1 deletions(-)
 create mode 100755 gdb/gdb-add-index

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 6dbb284..8210a2c 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1018,7 +1018,16 @@ install-only: $(CONFIG_INSTALL) xml-syscall-install
 		$(SHELL) $(srcdir)/../mkinstalldirs \
 			$(DESTDIR)$(man1dir) ; \
 		$(INSTALL_DATA) $(srcdir)/gdb.1 \
-			$(DESTDIR)$(man1dir)/$$transformed_name.1
+			$(DESTDIR)$(man1dir)/$$transformed_name.1; \
+	transformed_name=`t='$(program_transform_name)'; \
+			  echo gdb-add-index | sed -e "$$t"` ; \
+		if test "x$$transformed_name" = x; then \
+		  transformed_name=gdb-add-index ; \
+		else \
+		  true ; \
+		fi ; \
+		$(INSTALL_PROGRAM) $(srcdir)/gdb-add-index \
+			$(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT)
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 .PHONY: install-tui
 install-tui:
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 69141e3..457e6b4 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -15045,6 +15045,14 @@ There are currently some limitation on indices.  They only work when
 for DWARF debugging information, not stabs.  And, they do not
 currently work for programs using Ada.
 
+@value{GDBN} comes with a program, @command{gdb-add-index}, which can
+be used to add the index to a symbol file.  It takes the symbol file
+as its only argument:
+
+@smallexample
+$ gdb-add-index symfile
+@end smallexample
+
 
 @node Symbol Errors
 @section Errors Reading Symbol Files
diff --git a/gdb/gdb-add-index b/gdb/gdb-add-index
new file mode 100755
index 0000000..c9a03b0
--- /dev/null
+++ b/gdb/gdb-add-index
@@ -0,0 +1,30 @@
+#! /bin/sh
+
+# Add a .gdb_index section to a file.
+
+# Copyright (C) 2010 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/>.
+
+file="$1"
+dir="${file%/*}"
+
+# We don't care if gdb gives an error.
+gdb --batch-silent -ex "file $file" -ex "save gdb-index $d" > /dev/null 2>&1
+
+if test -f "${file}.gdb-index"; then
+   objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file"
+   rm -f "${file}.gdb-index"
+fi
+
+exit 0
-- 
1.6.2.5

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-09 17:31 ` Tom Tromey
@ 2010-07-09 17:45   ` Eli Zaretskii
  2010-07-09 20:26     ` Tom Tromey
  2010-07-22 11:31   ` Jan Kratochvil
  2010-07-30 20:46   ` Tom Tromey
  2 siblings, 1 reply; 34+ messages in thread
From: Eli Zaretskii @ 2010-07-09 17:45 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tromey@redhat.com>
> Date: Fri, 09 Jul 2010 11:31:04 -0600
> 
> +@value{GDBN} comes with a program, @command{gdb-add-index}, which can
> +be used to add the index to a symbol file.  It takes the symbol file
> +as its only argument:
> +
> +@smallexample
> +$ gdb-add-index symfile
> +@end smallexample

OK, but I would suggest to add an index entry for gdb-add-index.

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-09 17:45   ` Eli Zaretskii
@ 2010-07-09 20:26     ` Tom Tromey
  2010-07-10  7:03       ` Eli Zaretskii
  0 siblings, 1 reply; 34+ messages in thread
From: Tom Tromey @ 2010-07-09 20:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

Eli> OK, but I would suggest to add an index entry for gdb-add-index.

Thanks, good idea.
I added:

@kindex gdb-add-index

Tom

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-09 20:26     ` Tom Tromey
@ 2010-07-10  7:03       ` Eli Zaretskii
  2010-07-12 16:52         ` Tom Tromey
  0 siblings, 1 reply; 34+ messages in thread
From: Eli Zaretskii @ 2010-07-10  7:03 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

> From: Tom Tromey <tromey@redhat.com>
> Cc: gdb-patches@sourceware.org
> Date: Fri, 09 Jul 2010 14:26:47 -0600
> 
> >>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
> 
> Eli> OK, but I would suggest to add an index entry for gdb-add-index.
> 
> Thanks, good idea.
> I added:
> 
> @kindex gdb-add-index

Not that it matters with the current arrangement (only one Index
section), but it's better to use @pindex, since this is an external
program.  Either that, or "@cindex @command{gdb-add-index}".

Thanks.

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-10  7:03       ` Eli Zaretskii
@ 2010-07-12 16:52         ` Tom Tromey
  0 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2010-07-12 16:52 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

>> @kindex gdb-add-index

Eli> Not that it matters with the current arrangement (only one Index
Eli> section), but it's better to use @pindex, since this is an external
Eli> program.  Either that, or "@cindex @command{gdb-add-index}".

Thanks, I changed it to use @pindex.

Tom

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

* Re: [0/4] RFC: add DWARF index support
  2010-06-30 22:33 [0/4] RFC: add DWARF index support Tom Tromey
  2010-07-09 17:31 ` Tom Tromey
@ 2010-07-13 20:42 ` Tom Tromey
  2010-07-22  4:28   ` Paul Pluzhnikov
  1 sibling, 1 reply; 34+ messages in thread
From: Tom Tromey @ 2010-07-13 20:42 UTC (permalink / raw)
  To: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> This patch series adds support for a DWARF index to gdb.

I am going to check in patches 1, 3, and 4 on the trunk.
I'm dropping the completely bogus patch #2.

I am holding off on the patch to add "gdb-add-index" for a little while
longer.

Tom

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-13 20:42 ` Tom Tromey
@ 2010-07-22  4:28   ` Paul Pluzhnikov
  2010-07-22 14:14     ` Tom Tromey
  0 siblings, 1 reply; 34+ messages in thread
From: Paul Pluzhnikov @ 2010-07-22  4:28 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Tue, Jul 13, 2010 at 1:42 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
>
> Tom> This patch series adds support for a DWARF index to gdb.

I am seeing crashes in code which appears to have been committed in this patch:

(top) r
warning: no loadable sections found in added symbol-file
/usr/lib/debug/lib/ld-2.7.so
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
GNU gdb (GDB) 7.2.50.20100722-cvs
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/local/google/fortuneseeker...done.
(gdb) b eventmanager::TaskInfo::GetThreadState

Program received signal SIGSEGV, Segmentation fault.
0x0000000000582ce5 in process_full_comp_unit (per_cu=0x2c9c640) at
../../src/gdb/dwarf2read.c:4106
4106	  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
(top) p objfile
$9 = (struct objfile *) 0x0
(top) p *per_cu
$10 = {offset = 603943, length = 425, queued = 1, load_all_dies = 0,
from_debug_types = 1, cu = 0x47cec30, type_hash = 0x0, objfile = 0x0,
v = {psymtab = 0x2710fe0, quick = 0x2710fe0}}

I've briefly perused dwarf2read.c, and didn't find a place that
insures that per_cu->objfile is initialized :-(

Clues appreciated.

(top) bt
#0  0x0000000000582ce5 in process_full_comp_unit (per_cu=0x2c9c640)
    at ../../src/gdb/dwarf2read.c:4106
#1  0x00000000005828a7 in process_queue (objfile=0xd09a40)
    at ../../src/gdb/dwarf2read.c:3943

... Note: objfile here is not NULL, and is the "fortuneseeker"
executable I am debugging...

#2  0x000000000057d6c6 in dw2_do_instantiate_symtab (
    objfile=0xd09a40, per_cu=0x2c9c640)
    at ../../src/gdb/dwarf2read.c:1582
#3  0x0000000000582aaf in psymtab_to_symtab_1 (pst=0x2710fe0)
    at ../../src/gdb/dwarf2read.c:4019
#4  0x0000000000582775 in dwarf2_psymtab_to_symtab (pst=0x2710fe0)
    at ../../src/gdb/dwarf2read.c:3900
#5  0x000000000050f8e6 in psymtab_to_symtab (pst=0x2710fe0)
    at ../../src/gdb/psymtab.c:531
#6  0x000000000050f59b in lookup_symbol_aux_psymtabs (
    objfile=0xd09a40, block_index=0,
    name=0x7fffffffd020 "eventmanager::TaskInfo",
    domain=STRUCT_DOMAIN) at ../../src/gdb/psymtab.c:418
#7  0x0000000000508c60 in lookup_symbol_aux_quick (objfile=0xd09a40,
    kind=0, name=0x7fffffffd020 "eventmanager::TaskInfo",
    domain=STRUCT_DOMAIN) at ../../src/gdb/symtab.c:1387
#8  0x0000000000508e9d in lookup_symbol_global (
    name=0x7fffffffd020 "eventmanager::TaskInfo", block=0x0,
    domain=STRUCT_DOMAIN) at ../../src/gdb/symtab.c:1505
#9  0x00000000006081b2 in lookup_symbol_file (
    name=0x7fffffffd020 "eventmanager::TaskInfo", block=0x0,
    domain=STRUCT_DOMAIN, anonymous_namespace=0)
    at ../../src/gdb/cp-namespace.c:528
#10 0x0000000000607ba6 in cp_lookup_symbol_in_namespace (
    namespace=0x7fffffffce40 "",
    name=0x7fffffffd020 "eventmanager::TaskInfo", block=0x0,
    domain=STRUCT_DOMAIN) at ../../src/gdb/cp-namespace.c:261
#11 0x000000000060810e in lookup_namespace_scope (
    name=0x7fffffffd020 "eventmanager::TaskInfo", block=0x0,
    domain=STRUCT_DOMAIN, scope=0x7779c9 "", scope_len=0)
    at ../../src/gdb/cp-namespace.c:495
#12 0x0000000000607b2c in cp_lookup_symbol_nonlocal (
    name=0x7fffffffd020 "eventmanager::TaskInfo", block=0x0,
    domain=STRUCT_DOMAIN) at ../../src/gdb/cp-namespace.c:243
#13 0x0000000000508762 in lookup_symbol_aux (
    name=0x7fffffffd020 "eventmanager::TaskInfo", block=0x0,
    domain=STRUCT_DOMAIN, language=language_cplus,
    is_a_field_of_this=0x0) at ../../src/gdb/symtab.c:1170
#14 0x0000000000508537 in lookup_symbol_in_language (
    name=0x7fffffffd020 "eventmanager::TaskInfo", block=0x0,
    domain=STRUCT_DOMAIN, lang=language_cplus,
    is_a_field_of_this=0x0) at ../../src/gdb/symtab.c:1077
#15 0x000000000050859a in lookup_symbol (
    name=0x7fffffffd020 "eventmanager::TaskInfo", block=0x0,
    domain=STRUCT_DOMAIN, is_a_field_of_this=0x0)
    at ../../src/gdb/symtab.c:1091
#16 0x000000000051d53e in lookup_prefix_sym (argptr=0x7fffffffd4c0,
    p=0xb4422a "GetThreadState") at ../../src/gdb/linespec.c:1522
#17 0x000000000051cc48 in decode_compound (argptr=0x7fffffffd4c0,
    funfirstline=1, canonical=0x7fffffffd588,
    saved_arg=0xb44212 "eventmanager::TaskInfo::GetThreadState",
    p=0xb44238 "", not_found_ptr=0x7fffffffd5b4)
    at ../../src/gdb/linespec.c:1337
#18 0x000000000051bd16 in decode_line_1 (argptr=0x7fffffffd4c0,
    funfirstline=1, default_symtab=0x0, default_line=0,
    canonical=0x7fffffffd588, not_found_ptr=0x7fffffffd5b4)
    at ../../src/gdb/linespec.c:800
#19 0x00000000004d28d2 in parse_breakpoint_sals (
    address=0x7fffffffd4c0, sals=0x7fffffffd540,
    addr_string=0x7fffffffd588, not_found_ptr=0x7fffffffd5b4)
    at ../../src/gdb/breakpoint.c:7250
#20 0x00000000004d2b29 in do_captured_parse_breakpoint (ui=0xcdc7f0,
    data=0x7fffffffd510) at ../../src/gdb/breakpoint.c:7320
#21 0x000000000053b5d1 in catch_exception (uiout=0xcdc7f0,
    func=0x4d2aed <do_captured_parse_breakpoint>,
    func_args=0x7fffffffd510, mask=6)
    at ../../src/gdb/exceptions.c:468
#22 0x00000000004d32a4 in create_breakpoint (gdbarch=0xcf5e20,
    arg=0xb4422a "GetThreadState", cond_string=0x0, thread=0,
    parse_condition_and_thread=1, tempflag=0,
    type_wanted=bp_breakpoint, ignore_count=0,
    pending_break_support=AUTO_BOOLEAN_AUTO, ops=0x0, from_tty=0,
    enabled=1) at ../../src/gdb/breakpoint.c:7502
#23 0x00000000004d39ef in break_command_1 (
    arg=0xb44212 "eventmanager::TaskInfo::GetThreadState", flag=0,
    from_tty=0) at ../../src/gdb/breakpoint.c:7723
#24 0x00000000004d3b83 in break_command (
    arg=0xb44212 "eventmanager::TaskInfo::GetThreadState",
    from_tty=0) at ../../src/gdb/breakpoint.c:7795
#25 0x000000000048d460 in do_cfunc (c=0xb87870,
    args=0xb44212 "eventmanager::TaskInfo::GetThreadState",
    from_tty=0) at ../../src/gdb/cli/cli-decode.c:67
#26 0x0000000000490306 in cmd_func (cmd=0xb87870,
    args=0xb44212 "eventmanager::TaskInfo::GetThreadState",
    from_tty=0) at ../../src/gdb/cli/cli-decode.c:1771
#27 0x0000000000412d86 in execute_command (p=0xb44237 "e",
    from_tty=1) at ../../src/gdb/top.c:422
#28 0x00000000005430b7 in command_handler (
    command=0xb44210 "b eventmanager::TaskInfo::GetThreadState")
    at ../../src/gdb/event-top.c:498
#29 0x000000000054365b in command_line_handler (
    rl=0xbbc4e0 " \257\326") at ../../src/gdb/event-top.c:702
#30 0x000000000064da01 in rl_callback_read_char ()
    at ../../src/readline/callback.c:205
#31 0x0000000000542711 in rl_callback_read_char_wrapper (
    client_data=0x0) at ../../src/gdb/event-top.c:178
#32 0x0000000000542fb0 in stdin_event_handler (error=0,
    client_data=0x0) at ../../src/gdb/event-top.c:433
#33 0x00000000005417a1 in handle_file_event (data=...)
    at ../../src/gdb/event-loop.c:817
#34 0x0000000000540e0d in process_event ()
    at ../../src/gdb/event-loop.c:399
#35 0x0000000000540eed in gdb_do_one_event (data=0x0)
    at ../../src/gdb/event-loop.c:464
#36 0x000000000053b77f in catch_errors (
    func=0x540e22 <gdb_do_one_event>, func_args=0x0,
    errstring=0x75ad6f "", mask=6) at ../../src/gdb/exceptions.c:518
#37 0x00000000004a39ff in tui_command_loop (data=0x0)
    at ../../src/gdb/tui/tui-interp.c:171
#38 0x000000000053bf27 in current_interp_command_loop ()
    at ../../src/gdb/interps.c:291
#39 0x0000000000408cd7 in captured_command_loop (data=0x0)
    at ../../src/gdb/main.c:227
#40 0x000000000053b77f in catch_errors (
    func=0x408cc6 <captured_command_loop>, func_args=0x0,
    errstring=0x737f3f "", mask=6) at ../../src/gdb/exceptions.c:518
#41 0x0000000000409c02 in captured_main (data=0x7fffffffdb80)
    at ../../src/gdb/main.c:910
#42 0x000000000053b77f in catch_errors (
    func=0x408d09 <captured_main>, func_args=0x7fffffffdb80,
    errstring=0x737f3f "", mask=6) at ../../src/gdb/exceptions.c:518
#43 0x0000000000409c35 in gdb_main (args=0x7fffffffdb80)
    at ../../src/gdb/main.c:919
#44 0x0000000000408a20 in main (argc=2, argv=0x7fffffffdc88)
    at ../../src/gdb/gdb.c:34


-- 
Paul Pluzhnikov

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-09 17:31 ` Tom Tromey
  2010-07-09 17:45   ` Eli Zaretskii
@ 2010-07-22 11:31   ` Jan Kratochvil
  2010-07-22 15:54     ` Tom Tromey
  2010-07-30 20:46   ` Tom Tromey
  2 siblings, 1 reply; 34+ messages in thread
From: Jan Kratochvil @ 2010-07-22 11:31 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Fri, 09 Jul 2010 19:31:04 +0200, Tom Tromey wrote:
> --- /dev/null
> +++ b/gdb/gdb-add-index
[...]
> +dir="${file%/*}"
> +
> +# We don't care if gdb gives an error.
> +gdb --batch-silent -ex "file $file" -ex "save gdb-index $d" > /dev/null 2>&1
                                                           ^^
$d -> $dir

Also I would prefer removing the /dev/null redirection, normally GDB does not
produce any message anyway.  Suppressing messages by the caller is always
easier than unsuppressing them.


Thanks,
Jan

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-22  4:28   ` Paul Pluzhnikov
@ 2010-07-22 14:14     ` Tom Tromey
  2010-07-22 15:54       ` Tom Tromey
  0 siblings, 1 reply; 34+ messages in thread
From: Tom Tromey @ 2010-07-22 14:14 UTC (permalink / raw)
  To: Paul Pluzhnikov; +Cc: gdb-patches

>>>>> "Paul" == Paul Pluzhnikov <ppluzhnikov@google.com> writes:

Paul> I am seeing crashes in code which appears to have been committed
Paul> in this patch:

Paul> I've briefly perused dwarf2read.c, and didn't find a place that
Paul> insures that per_cu->objfile is initialized :-(

Sorry about that.

The immediate problem is that a dwarf2_per_cu_data is embedded in struct
signatured_type, and initialized in create_debug_types_hash_table.  This
embedded struct doesn't get its objfile member initialized.

The other places allocating a dwarf2_per_cu_data are
create_all_comp_units and create_cus_from_index.  Those places do
initialize that member.

The bigger problem is that I completely forgot about .debug_types.
I am not certain that a simple fix will work if we have both
.debug_types and .gdb_index.  I will try that out.

Tom

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-22 11:31   ` Jan Kratochvil
@ 2010-07-22 15:54     ` Tom Tromey
  0 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2010-07-22 15:54 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

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

Jan> $d -> $dir

Thanks.

Jan> Also I would prefer removing the /dev/null redirection, normally
Jan> GDB does not produce any message anyway.  Suppressing messages by
Jan> the caller is always easier than unsuppressing them.

Sounds good.

Tom

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-22 14:14     ` Tom Tromey
@ 2010-07-22 15:54       ` Tom Tromey
  2010-07-22 16:20         ` Paul Pluzhnikov
  2010-07-22 20:54         ` Tom Tromey
  0 siblings, 2 replies; 34+ messages in thread
From: Tom Tromey @ 2010-07-22 15:54 UTC (permalink / raw)
  To: Paul Pluzhnikov; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> The immediate problem is that a dwarf2_per_cu_data is embedded in struct
Tom> signatured_type, and initialized in create_debug_types_hash_table.  This
Tom> embedded struct doesn't get its objfile member initialized.

Here is the fix for the immediate problem.  It prevents gdb from dying.

I am checking this in.  Bootstrapped & regtested on x86-64 (compile
farm), and also tested locally against an executable with .debug_types.

Tom> The bigger problem is that I completely forgot about .debug_types.
Tom> I am not certain that a simple fix will work if we have both
Tom> .debug_types and .gdb_index.  I will try that out.

I think this is going to need an index version bump.
I am still looking into it.

Tom

2010-07-22  Tom Tromey  <tromey@redhat.com>

	* dwarf2read.c (create_debug_types_hash_table): Set objfile on
	type signature's per-CU data.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.421
diff -u -r1.421 dwarf2read.c
--- dwarf2read.c	21 Jul 2010 18:08:26 -0000	1.421
+++ dwarf2read.c	22 Jul 2010 15:42:38 -0000
@@ -2678,6 +2678,7 @@
       type_sig->signature = signature;
       type_sig->offset = offset;
       type_sig->type_offset = type_offset;
+      type_sig->per_cu.objfile = objfile;
 
       slot = htab_find_slot (types_htab, type_sig, INSERT);
       gdb_assert (slot != NULL);

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-22 15:54       ` Tom Tromey
@ 2010-07-22 16:20         ` Paul Pluzhnikov
  2010-07-22 20:54         ` Tom Tromey
  1 sibling, 0 replies; 34+ messages in thread
From: Paul Pluzhnikov @ 2010-07-22 16:20 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Thu, Jul 22, 2010 at 8:53 AM, Tom Tromey <tromey@redhat.com> wrote:

> I am checking this in.  Bootstrapped & regtested on x86-64 (compile
> farm), and also tested locally against an executable with .debug_types.

That it fixes the crash for me as well.

Thanks,
-- 
Paul Pluzhnikov

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-22 15:54       ` Tom Tromey
  2010-07-22 16:20         ` Paul Pluzhnikov
@ 2010-07-22 20:54         ` Tom Tromey
  2010-07-23 22:12           ` Tom Tromey
  1 sibling, 1 reply; 34+ messages in thread
From: Tom Tromey @ 2010-07-22 20:54 UTC (permalink / raw)
  To: Paul Pluzhnikov; +Cc: gdb-patches

Tom> The bigger problem is that I completely forgot about .debug_types.
Tom> I am not certain that a simple fix will work if we have both
Tom> .debug_types and .gdb_index.  I will try that out.

Tom> I think this is going to need an index version bump.
Tom> I am still looking into it.

Here is what I am testing.

This also fixes a bug in dwarf2_initialize_objfile that prevents
-readnow from working when .debug_types exists.  If necessary this can
be fixed separately, though such a fix would have to be backed out when
this patch goes in.

I bumped the index version number because I believe we've built some
version 1 indices in the Fedora buildroots already.

Tom

2010-07-22  Tom Tromey  <tromey@redhat.com>

	* dwarf2read.c (dwarf2_per_cu_data_ptr): Remove.
	(struct dwarf2_per_objfile) <n_type_comp_units, type_comp_units>:
	New fields.
	(dw2_get_cu): New function.
	(create_cus_from_index): Remove unused argument.
	(create_signatured_type_hash_from_index): New function.
	(create_addrmap_from_index): Update.
	(dwarf2_read_index): Handle version 2.
	(dw2_find_last_source_symtab, dw2_forget_cached_source_info)
	(dw2_lookup_symtab, dw2_do_expand_symtabs_matching)
	(dw2_print_stats, dw2_expand_all_symtabs)
	(dw2_expand_symtabs_with_filename, dw2_find_symbol_file)
	(dw2_expand_symtabs_matching, dw2_map_symbol_filenames): Update.
	(dwarf2_initialize_objfile): Call create_debug_types_hash_table.
	(allocate_signatured_type_hash_table): New function.
	(add_signatured_type_cu_to_list): Likewise.
	(create_debug_types_hash_table): Use them.  Set type_comp_units.
	(read_signatured_type): Ensure section data is available.
	(add_address_entry): Don't record empty ranges.
	(struct signatured_type_index_data): New.
	(write_one_signatured_type): New function.
	(write_psymtabs_to_index): Write type CUs.
	(save_gdb_index_command): Update comment.

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 8084f42..7ab18e4 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -155,9 +155,6 @@ struct mapped_index
   const char *constant_pool;
 };
 
-typedef struct dwarf2_per_cu_data *dwarf2_per_cu_data_ptr;
-DEF_VEC_P (dwarf2_per_cu_data_ptr);
-
 struct dwarf2_per_objfile
 {
   struct dwarf2_section_info info;
@@ -182,6 +179,12 @@ struct dwarf2_per_objfile
   /* The number of compilation units in ALL_COMP_UNITS.  */
   int n_comp_units;
 
+  /* The number of .debug_types-related CUs.  */
+  int n_type_comp_units;
+
+  /* The .debug_types-related CUs.  */
+  struct dwarf2_per_cu_data **type_comp_units;
+
   /* A chain of compilation units that are currently read in, so that
      they can be freed later.  */
   struct dwarf2_per_cu_data *read_in_chain;
@@ -1192,6 +1195,8 @@ static struct type *set_die_type (struct die_info *, struct type *,
 
 static void create_all_comp_units (struct objfile *);
 
+static int create_debug_types_hash_table (struct objfile *objfile);
+
 static void load_full_comp_unit (struct dwarf2_per_cu_data *,
 				 struct objfile *);
 
@@ -1229,6 +1234,8 @@ static gdb_byte *partial_read_comp_unit_head (struct comp_unit_head *header,
 static void init_cu_die_reader (struct die_reader_specs *reader,
 				struct dwarf2_cu *cu);
 
+static htab_t allocate_signatured_type_hash_table (struct objfile *objfile);
+
 #if WORDS_BIGENDIAN
 
 /* Convert VALUE between big- and little-endian.  */
@@ -1605,6 +1612,18 @@ dw2_instantiate_symtab (struct objfile *objfile,
   return per_cu->v.quick->symtab;
 }
 
+/* Return the CU given its index.  */
+static struct dwarf2_per_cu_data *
+dw2_get_cu (int index)
+{
+  if (index >= dwarf2_per_objfile->n_comp_units)
+    {
+      index -= dwarf2_per_objfile->n_comp_units;
+      return dwarf2_per_objfile->type_comp_units[index];
+    }
+  return dwarf2_per_objfile->all_comp_units[index];
+}
+
 /* A helper function that knows how to read a 64-bit value in a way
    that doesn't make gdb die.  Returns 1 if the conversion went ok, 0
    otherwise.  */
@@ -1631,11 +1650,10 @@ extract_cu_value (const char *bytes, ULONGEST *result)
    the CU objects for this objfile.  Return 0 if something went wrong,
    1 if everything went ok.  */
 static int
-create_cus_from_index (struct objfile *objfile, struct mapped_index *index,
-		       const gdb_byte *cu_list, offset_type cu_list_elements)
+create_cus_from_index (struct objfile *objfile, const gdb_byte *cu_list,
+		       offset_type cu_list_elements)
 {
   offset_type i;
-  const char *entry;
 
   dwarf2_per_objfile->n_comp_units = cu_list_elements / 2;
   dwarf2_per_objfile->all_comp_units
@@ -1666,6 +1684,58 @@ create_cus_from_index (struct objfile *objfile, struct mapped_index *index,
   return 1;
 }
 
+/* Create the signatured type hash table from the index.  */
+static int
+create_signatured_type_hash_from_index (struct objfile *objfile,
+					const gdb_byte *bytes,
+					offset_type elements)
+{
+  offset_type i;
+  htab_t type_hash;
+
+  dwarf2_per_objfile->n_type_comp_units = elements / 3;
+  dwarf2_per_objfile->type_comp_units
+    = obstack_alloc (&objfile->objfile_obstack,
+		     dwarf2_per_objfile->n_type_comp_units
+		     * sizeof (struct dwarf2_per_cu_data *));
+
+  type_hash = allocate_signatured_type_hash_table (objfile);
+
+  for (i = 0; i < elements; i += 3)
+    {
+      struct signatured_type *type_sig;
+      ULONGEST offset, type_offset, signature;
+      void **slot;
+
+      if (!extract_cu_value (bytes, &offset)
+	  || !extract_cu_value (bytes + 8, &type_offset))
+	return 0;
+      signature = extract_unsigned_integer (bytes + 16, 8, BFD_ENDIAN_LITTLE);
+      bytes += 3 * 8;
+
+      type_sig = OBSTACK_ZALLOC (&objfile->objfile_obstack,
+				 struct signatured_type);
+      type_sig->signature = signature;
+      type_sig->offset = offset;
+      type_sig->type_offset = type_offset;
+      type_sig->per_cu.from_debug_types = 1;
+      type_sig->per_cu.offset = offset;
+      type_sig->per_cu.objfile = objfile;
+      type_sig->per_cu.v.quick
+	= OBSTACK_ZALLOC (&objfile->objfile_obstack,
+			  struct dwarf2_per_cu_quick_data);
+
+      slot = htab_find_slot (type_hash, type_sig, INSERT);
+      *slot = type_sig;
+
+      dwarf2_per_objfile->type_comp_units[i / 3] = &type_sig->per_cu;
+    }
+
+  dwarf2_per_objfile->signatured_types = type_hash;
+
+  return 1;
+}
+
 /* Read the address map data from the mapped index, and use it to
    populate the objfile's psymtabs_addrmap.  */
 static void
@@ -1697,7 +1767,7 @@ create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
       iter += 4;
       
       addrmap_set_empty (mutable_map, lo + baseaddr, hi + baseaddr - 1,
-			 dwarf2_per_objfile->all_comp_units[cu_index]);
+			 dw2_get_cu (cu_index));
     }
 
   objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
@@ -1767,8 +1837,9 @@ dwarf2_read_index (struct objfile *objfile)
   struct mapped_index *map;
   offset_type val, *metadata;
   char buf1[8], buf2[8];
-  const gdb_byte *cu_list;
-  offset_type cu_list_elements;
+  const gdb_byte *cu_list, *types_list;
+  offset_type version, cu_list_elements, types_list_elements;
+  int i;
 
   if (dwarf2_per_objfile->gdb_index.asection == NULL
       || dwarf2_per_objfile->gdb_index.size == 0)
@@ -1777,26 +1848,58 @@ dwarf2_read_index (struct objfile *objfile)
 
   addr = dwarf2_per_objfile->gdb_index.buffer;
   /* Version check.  */
-  if (MAYBE_SWAP (*(offset_type *) addr) != 1)
+  version = MAYBE_SWAP (*(offset_type *) addr);
+  if (version == 1)
+    {
+      /* Index version 1 neglected to account for .debug_types.  So,
+	 if we see .debug_types, we cannot use this index.  */
+      if (dwarf2_per_objfile->types.asection != NULL
+	  && dwarf2_per_objfile->types.size != 0)
+	return 0;
+    }
+  else if (version != 2)
     return 0;
 
   map = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct mapped_index);
   map->total_size = st.st_size;
 
   metadata = (offset_type *) (addr + sizeof (offset_type));
-  cu_list = addr + MAYBE_SWAP (metadata[0]);
-  cu_list_elements = ((MAYBE_SWAP (metadata[1]) - MAYBE_SWAP (metadata[0]))
+
+  i = 0;
+  cu_list = addr + MAYBE_SWAP (metadata[i]);
+  cu_list_elements = ((MAYBE_SWAP (metadata[i + 1]) - MAYBE_SWAP (metadata[i]))
 		      / 8);
-  map->address_table = addr + MAYBE_SWAP (metadata[1]);
-  map->address_table_size = (MAYBE_SWAP (metadata[2])
-			     - MAYBE_SWAP (metadata[1]));
-  map->index_table = (offset_type *) (addr + MAYBE_SWAP (metadata[2]));
-  map->index_table_slots = ((MAYBE_SWAP (metadata[3])
-			     - MAYBE_SWAP (metadata[2]))
+  ++i;
+
+  if (version == 2)
+    {
+      types_list = addr + MAYBE_SWAP (metadata[i]);
+      types_list_elements = ((MAYBE_SWAP (metadata[i + 1])
+			      - MAYBE_SWAP (metadata[i]))
+			     / 8);
+      ++i;
+    }
+
+  map->address_table = addr + MAYBE_SWAP (metadata[i]);
+  map->address_table_size = (MAYBE_SWAP (metadata[i + 1])
+			     - MAYBE_SWAP (metadata[i]));
+  ++i;
+
+  map->index_table = (offset_type *) (addr + MAYBE_SWAP (metadata[i]));
+  map->index_table_slots = ((MAYBE_SWAP (metadata[i + 1])
+			     - MAYBE_SWAP (metadata[i]))
 			    / (2 * sizeof (offset_type)));
-  map->constant_pool = addr + MAYBE_SWAP (metadata[3]);
+  ++i;
+
+  map->constant_pool = addr + MAYBE_SWAP (metadata[i]);
 
-  if (!create_cus_from_index (objfile, map, cu_list, cu_list_elements))
+  if (!create_cus_from_index (objfile, cu_list, cu_list_elements))
+    return 0;
+
+  if (version == 2
+      && types_list_elements
+      && !create_signatured_type_hash_from_index (objfile, types_list,
+						  types_list_elements))
     return 0;
 
   create_addrmap_from_index (objfile, map);
@@ -1923,8 +2026,7 @@ dw2_find_last_source_symtab (struct objfile *objfile)
   int index;
   dw2_setup (objfile);
   index = dwarf2_per_objfile->n_comp_units - 1;
-  return dw2_instantiate_symtab (objfile,
-				 dwarf2_per_objfile->all_comp_units[index]);
+  return dw2_instantiate_symtab (objfile, dw2_get_cu (index));
 }
 
 static void
@@ -1933,9 +2035,10 @@ dw2_forget_cached_source_info (struct objfile *objfile)
   int i;
 
   dw2_setup (objfile);
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       if (cu->v.quick->full_names)
 	{
@@ -1957,10 +2060,11 @@ dw2_lookup_symtab (struct objfile *objfile, const char *name,
   struct dwarf2_per_cu_data *base_cu = NULL;
 
   dw2_setup (objfile);
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
       int j;
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       if (cu->v.quick->symtab)
 	continue;
@@ -2052,8 +2156,8 @@ dw2_do_expand_symtabs_matching (struct objfile *objfile, const char *name)
 	  for (i = 0; i < len; ++i)
 	    {
 	      offset_type cu_index = MAYBE_SWAP (vec[i + 1]);
-	      struct dwarf2_per_cu_data *cu;
-	      cu = dwarf2_per_objfile->all_comp_units[cu_index];
+	      struct dwarf2_per_cu_data *cu = dw2_get_cu (cu_index);
+
 	      dw2_instantiate_symtab (objfile, cu);
 	    }
 	}
@@ -2075,9 +2179,10 @@ dw2_print_stats (struct objfile *objfile)
 
   dw2_setup (objfile);
   count = 0;
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       if (!cu->v.quick->symtab)
 	++count;
@@ -2111,9 +2216,11 @@ dw2_expand_all_symtabs (struct objfile *objfile)
   int i;
 
   dw2_setup (objfile);
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       dw2_instantiate_symtab (objfile, cu);
     }
@@ -2126,10 +2233,11 @@ dw2_expand_symtabs_with_filename (struct objfile *objfile,
   int i;
 
   dw2_setup (objfile);
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
       int j;
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       if (cu->v.quick->symtab)
 	continue;
@@ -2170,7 +2278,7 @@ dw2_find_symbol_file (struct objfile *objfile, const char *name)
      should be rewritten so that it doesn't require a custom hook.  It
      could just use the ordinary symbol tables.  */
   /* vec[0] is the length, which must always be >0.  */
-  cu = dwarf2_per_objfile->all_comp_units[MAYBE_SWAP (vec[1])];
+  cu = dw2_get_cu (MAYBE_SWAP (vec[1]));
 
   dw2_require_line_header (objfile, cu);
   if (!cu->v.quick->lines)
@@ -2209,10 +2317,11 @@ dw2_expand_symtabs_matching (struct objfile *objfile,
   if (!dwarf2_per_objfile->index_table)
     return;
 
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
       int j;
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       cu->v.quick->mark = 0;
       if (cu->v.quick->symtab)
@@ -2257,8 +2366,9 @@ dw2_expand_symtabs_matching (struct objfile *objfile,
       vec_len = MAYBE_SWAP (vec[0]);
       for (vec_idx = 0; vec_idx < vec_len; ++vec_idx)
 	{
-	  struct dwarf2_per_cu_data *cu
-	    = dwarf2_per_objfile->all_comp_units[MAYBE_SWAP (vec[vec_idx + 1])];
+	  struct dwarf2_per_cu_data *cu;
+
+	  cu = dw2_get_cu (MAYBE_SWAP (vec[vec_idx + 1]));
 	  if (cu->v.quick->mark)
 	    dw2_instantiate_symtab (objfile, cu);
 	}
@@ -2328,10 +2438,11 @@ dw2_map_symbol_filenames (struct objfile *objfile,
   int i;
 
   dw2_setup (objfile);
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
       int j;
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       if (cu->v.quick->symtab)
 	continue;
@@ -2392,10 +2503,12 @@ dwarf2_initialize_objfile (struct objfile *objfile)
 
       dwarf2_per_objfile->using_index = 1;
       create_all_comp_units (objfile);
+      create_debug_types_hash_table (objfile);
 
-      for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+      for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		       + dwarf2_per_objfile->n_type_comp_units); ++i)
 	{
-	  struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+	  struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
 	  cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
 					struct dwarf2_per_cu_quick_data);
@@ -2609,6 +2722,34 @@ eq_type_signature (const void *item_lhs, const void *item_rhs)
   return lhs->signature == rhs->signature;
 }
 
+/* Allocate a hash table for signatured types.  */
+
+static htab_t
+allocate_signatured_type_hash_table (struct objfile *objfile)
+{
+  return htab_create_alloc_ex (41,
+			       hash_type_signature,
+			       eq_type_signature,
+			       NULL,
+			       &objfile->objfile_obstack,
+			       hashtab_obstack_allocate,
+			       dummy_obstack_deallocate);
+}
+
+/* A helper function to add a signatured type CU to a list.  */
+
+static int
+add_signatured_type_cu_to_list (void **slot, void *datum)
+{
+  struct signatured_type *sigt = *slot;
+  struct dwarf2_per_cu_data ***datap = datum;
+
+  **datap = &sigt->per_cu;
+  ++*datap;
+
+  return 1;
+}
+
 /* Create the hash table of all entries in the .debug_types section.
    The result is zero if there is an error (e.g. missing .debug_types section),
    otherwise non-zero.	*/
@@ -2618,6 +2759,7 @@ create_debug_types_hash_table (struct objfile *objfile)
 {
   gdb_byte *info_ptr;
   htab_t types_htab;
+  struct dwarf2_per_cu_data **iter;
 
   dwarf2_read_section (objfile, &dwarf2_per_objfile->types);
   info_ptr = dwarf2_per_objfile->types.buffer;
@@ -2628,13 +2770,7 @@ create_debug_types_hash_table (struct objfile *objfile)
       return 0;
     }
 
-  types_htab = htab_create_alloc_ex (41,
-				     hash_type_signature,
-				     eq_type_signature,
-				     NULL,
-				     &objfile->objfile_obstack,
-				     hashtab_obstack_allocate,
-				     dummy_obstack_deallocate);
+  types_htab = allocate_signatured_type_hash_table (objfile);
 
   if (dwarf2_die_debug)
     fprintf_unfiltered (gdb_stdlog, "Signatured types:\n");
@@ -2695,6 +2831,16 @@ create_debug_types_hash_table (struct objfile *objfile)
 
   dwarf2_per_objfile->signatured_types = types_htab;
 
+  dwarf2_per_objfile->n_type_comp_units = htab_elements (types_htab);
+  dwarf2_per_objfile->type_comp_units
+    = obstack_alloc (&objfile->objfile_obstack,
+		     dwarf2_per_objfile->n_type_comp_units
+		     * sizeof (struct dwarf2_per_cu_data *));
+  iter = &dwarf2_per_objfile->type_comp_units[0];
+  htab_traverse_noresize (types_htab, add_signatured_type_cu_to_list, &iter);
+  gdb_assert (iter - &dwarf2_per_objfile->type_comp_units[0]
+	      == dwarf2_per_objfile->n_type_comp_units);
+
   return 1;
 }
 
@@ -12051,13 +12197,16 @@ static void
 read_signatured_type (struct objfile *objfile,
 		      struct signatured_type *type_sig)
 {
-  gdb_byte *types_ptr = dwarf2_per_objfile->types.buffer + type_sig->offset;
+  gdb_byte *types_ptr;
   struct die_reader_specs reader_specs;
   struct dwarf2_cu *cu;
   ULONGEST signature;
   struct cleanup *back_to, *free_cu_cleanup;
   struct attribute *attr;
 
+  dwarf2_read_section (objfile, &dwarf2_per_objfile->types);
+  types_ptr = dwarf2_per_objfile->types.buffer + type_sig->offset;
+
   gdb_assert (type_sig->per_cu.cu == NULL);
 
   cu = xmalloc (sizeof (struct dwarf2_cu));
@@ -13881,6 +14030,10 @@ add_address_entry (struct objfile *objfile,
   char addr[8];
   CORE_ADDR baseaddr;
 
+  /* Don't bother recording empty ranges.  */
+  if (pst->textlow == pst->texthigh)
+    return;
+
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
   store_unsigned_integer (addr, 8, BFD_ENDIAN_LITTLE, pst->textlow - baseaddr);
@@ -13926,13 +14079,53 @@ unlink_if_set (void *p)
     unlink (*filename);
 }
 
+/* A helper struct used when iterating over debug_types.  */
+struct signatured_type_index_data
+{
+  struct objfile *objfile;
+  struct mapped_symtab *symtab;
+  struct obstack *types_list;
+  int cu_index;
+};
+
+/* A helper function that writes a single signatured_type to an
+   obstack.  */
+static int
+write_one_signatured_type (void **slot, void *d)
+{
+  struct signatured_type_index_data *info = d;
+  struct signatured_type *entry = (struct signatured_type *) *slot;
+  struct dwarf2_per_cu_data *cu = &entry->per_cu;
+  struct partial_symtab *psymtab = cu->v.psymtab;
+  gdb_byte val[8];
+
+  write_psymbols (info->symtab,
+		  info->objfile->global_psymbols.list + psymtab->globals_offset,
+		  psymtab->n_global_syms, info->cu_index);
+  write_psymbols (info->symtab,
+		  info->objfile->static_psymbols.list + psymtab->statics_offset,
+		  psymtab->n_static_syms, info->cu_index);
+
+  store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->offset);
+  obstack_grow (info->types_list, val, 8);
+  store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->type_offset);
+  obstack_grow (info->types_list, val, 8);
+  store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->signature);
+  obstack_grow (info->types_list, val, 8);
+
+  ++info->cu_index;
+
+  return 1;
+}
+
 /* Create an index file for OBJFILE in the directory DIR.  */
 static void
 write_psymtabs_to_index (struct objfile *objfile, const char *dir)
 {
   struct cleanup *cleanup;
   char *filename, *cleanup_filename;
-  struct obstack contents, addr_obstack, constant_pool, symtab_obstack, cu_list;
+  struct obstack contents, addr_obstack, constant_pool, symtab_obstack;
+  struct obstack cu_list, types_cu_list;
   int i;
   FILE *out_file;
   struct mapped_symtab *symtab;
@@ -13968,6 +14161,12 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
   obstack_init (&cu_list);
   make_cleanup_obstack_free (&cu_list);
 
+  obstack_init (&types_cu_list);
+  make_cleanup_obstack_free (&types_cu_list);
+
+  /* The list is already sorted, so we don't need to do additional
+     work here.  Also, the debug_types entries do not appear in
+     all_comp_units, but only in their own hash table.  */
   for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
     {
       struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
@@ -13989,6 +14188,19 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
       obstack_grow (&cu_list, val, 8);
     }
 
+  /* Write out the .debug_type entries, if any.  */
+  if (dwarf2_per_objfile->signatured_types)
+    {
+      struct signatured_type_index_data sig_data;
+
+      sig_data.objfile = objfile;
+      sig_data.symtab = symtab;
+      sig_data.types_list = &types_cu_list;
+      sig_data.cu_index = dwarf2_per_objfile->n_comp_units;
+      htab_traverse_noresize (dwarf2_per_objfile->signatured_types,
+			      write_one_signatured_type, &sig_data);
+    }
+
   obstack_init (&constant_pool);
   make_cleanup_obstack_free (&constant_pool);
   obstack_init (&symtab_obstack);
@@ -13997,11 +14209,11 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
 
   obstack_init (&contents);
   make_cleanup_obstack_free (&contents);
-  size_of_contents = 5 * sizeof (offset_type);
+  size_of_contents = 6 * sizeof (offset_type);
   total_len = size_of_contents;
 
   /* The version number.  */
-  val = MAYBE_SWAP (1);
+  val = MAYBE_SWAP (2);
   obstack_grow (&contents, &val, sizeof (val));
 
   /* The offset of the CU list from the start of the file.  */
@@ -14009,6 +14221,11 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
   obstack_grow (&contents, &val, sizeof (val));
   total_len += obstack_object_size (&cu_list);
 
+  /* The offset of the types CU list from the start of the file.  */
+  val = MAYBE_SWAP (total_len);
+  obstack_grow (&contents, &val, sizeof (val));
+  total_len += obstack_object_size (&types_cu_list);
+
   /* The offset of the address table from the start of the file.  */
   val = MAYBE_SWAP (total_len);
   obstack_grow (&contents, &val, sizeof (val));
@@ -14028,6 +14245,7 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
 
   write_obstack (out_file, &contents);
   write_obstack (out_file, &cu_list);
+  write_obstack (out_file, &types_cu_list);
   write_obstack (out_file, &addr_obstack);
   write_obstack (out_file, &symtab_obstack);
   write_obstack (out_file, &constant_pool);
@@ -14052,18 +14270,33 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
 
    1. The file header.  This is a sequence of values, of offset_type
    unless otherwise noted:
-   [0] The version number.  Currently 1.
+   [0] The version number.  Currently 1 or 2.  The differences are
+   noted below.  Version 1 did not account for .debug_types sections;
+   the presence of a .debug_types section invalidates any version 1
+   index that may exist.
    [1] The offset, from the start of the file, of the CU list.
+   [1.5] In version 2, the offset, from the start of the file, of the
+   types CU list.  This offset does not appear in version 1.  Note
+   that this can be empty, in which case this offset will be equal to
+   the next offset.
    [2] The offset, from the start of the file, of the address section.
    [3] The offset, from the start of the file, of the symbol table.
    [4] The offset, from the start of the file, of the constant pool.
 
    2. The CU list.  This is a sequence of pairs of 64-bit
-   little-endian values.  The first element in each pair is the offset
-   of a CU in the .debug_info section.  The second element in each
-   pair is the length of that CU.  References to a CU elsewhere in the
-   map are done using a CU index, which is just the 0-based index into
-   this table.
+   little-endian values, sorted by the CU offset.  The first element
+   in each pair is the offset of a CU in the .debug_info section.  The
+   second element in each pair is the length of that CU.  References
+   to a CU elsewhere in the map are done using a CU index, which is
+   just the 0-based index into this table.  Note that if there are
+   type CUs, then conceptually CUs and type CUs form a single list for
+   the purposes of CU indices.
+
+   2.5 The types CU list.  This does not appear in a version 1 index.
+   This is a sequence of triplets of 64-bit little values.  In a
+   triplet, the first value is the CU offset, the second value is the
+   type offset in the CU, and the third value is the type signature.
+   The types CU list is not sorted.
 
    3. The address section.  The address section consists of a sequence
    of address entries.  Each address entry has three elements.

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-22 20:54         ` Tom Tromey
@ 2010-07-23 22:12           ` Tom Tromey
  2010-07-26 18:41             ` Ken Werner
  0 siblings, 1 reply; 34+ messages in thread
From: Tom Tromey @ 2010-07-23 22:12 UTC (permalink / raw)
  To: Paul Pluzhnikov; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> Here is what I am testing.

Here is the variant I am checking it.  It seems to work with all
combinations of .debug_types, .gdb_index, and -readnow.

Let me know if you hit any more problems.

Tom

2010-07-23  Tom Tromey  <tromey@redhat.com>

	* dwarf2read.c (struct dwarf2_per_objfile) <n_type_comp_units,
	type_comp_units>: New fields.
	(dw2_get_cu): New function.
	(create_cus_from_index): Remove unused argument.
	(create_signatured_type_hash_from_index): New function.
	(create_addrmap_from_index): Update.
	(dwarf2_read_index): Handle version 2.
	(dw2_find_last_source_symtab, dw2_forget_cached_source_info)
	(dw2_lookup_symtab, dw2_do_expand_symtabs_matching)
	(dw2_print_stats, dw2_expand_all_symtabs)
	(dw2_expand_symtabs_with_filename, dw2_find_symbol_file)
	(dw2_expand_symtabs_matching, dw2_map_symbol_filenames): Update.
	(dwarf2_initialize_objfile): Call create_debug_types_hash_table.
	(allocate_signatured_type_hash_table): New function.
	(add_signatured_type_cu_to_list): Likewise.
	(create_debug_types_hash_table): Use them.  Set type_comp_units.
	(read_signatured_type): Ensure section data is available.
	(add_address_entry): Don't record empty ranges.
	(struct signatured_type_index_data): New.
	(write_one_signatured_type): New function.
	(write_psymtabs_to_index): Write type CUs.
	(save_gdb_index_command): Update comment.
	(process_type_comp_unit): Move inititalization of
	from_debug_types...
	(create_debug_types_hash_table): ... here.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.424
diff -u -r1.424 dwarf2read.c
--- dwarf2read.c	23 Jul 2010 14:43:33 -0000	1.424
+++ dwarf2read.c	23 Jul 2010 22:07:16 -0000
@@ -180,6 +180,12 @@
   /* The number of compilation units in ALL_COMP_UNITS.  */
   int n_comp_units;
 
+  /* The number of .debug_types-related CUs.  */
+  int n_type_comp_units;
+
+  /* The .debug_types-related CUs.  */
+  struct dwarf2_per_cu_data **type_comp_units;
+
   /* A chain of compilation units that are currently read in, so that
      they can be freed later.  */
   struct dwarf2_per_cu_data *read_in_chain;
@@ -1190,6 +1196,8 @@
 
 static void create_all_comp_units (struct objfile *);
 
+static int create_debug_types_hash_table (struct objfile *objfile);
+
 static void load_full_comp_unit (struct dwarf2_per_cu_data *,
 				 struct objfile *);
 
@@ -1227,6 +1235,8 @@
 static void init_cu_die_reader (struct die_reader_specs *reader,
 				struct dwarf2_cu *cu);
 
+static htab_t allocate_signatured_type_hash_table (struct objfile *objfile);
+
 #if WORDS_BIGENDIAN
 
 /* Convert VALUE between big- and little-endian.  */
@@ -1603,6 +1613,18 @@
   return per_cu->v.quick->symtab;
 }
 
+/* Return the CU given its index.  */
+static struct dwarf2_per_cu_data *
+dw2_get_cu (int index)
+{
+  if (index >= dwarf2_per_objfile->n_comp_units)
+    {
+      index -= dwarf2_per_objfile->n_comp_units;
+      return dwarf2_per_objfile->type_comp_units[index];
+    }
+  return dwarf2_per_objfile->all_comp_units[index];
+}
+
 /* A helper function that knows how to read a 64-bit value in a way
    that doesn't make gdb die.  Returns 1 if the conversion went ok, 0
    otherwise.  */
@@ -1629,11 +1651,10 @@
    the CU objects for this objfile.  Return 0 if something went wrong,
    1 if everything went ok.  */
 static int
-create_cus_from_index (struct objfile *objfile, struct mapped_index *index,
-		       const gdb_byte *cu_list, offset_type cu_list_elements)
+create_cus_from_index (struct objfile *objfile, const gdb_byte *cu_list,
+		       offset_type cu_list_elements)
 {
   offset_type i;
-  const char *entry;
 
   dwarf2_per_objfile->n_comp_units = cu_list_elements / 2;
   dwarf2_per_objfile->all_comp_units
@@ -1664,6 +1685,58 @@
   return 1;
 }
 
+/* Create the signatured type hash table from the index.  */
+static int
+create_signatured_type_hash_from_index (struct objfile *objfile,
+					const gdb_byte *bytes,
+					offset_type elements)
+{
+  offset_type i;
+  htab_t type_hash;
+
+  dwarf2_per_objfile->n_type_comp_units = elements / 3;
+  dwarf2_per_objfile->type_comp_units
+    = obstack_alloc (&objfile->objfile_obstack,
+		     dwarf2_per_objfile->n_type_comp_units
+		     * sizeof (struct dwarf2_per_cu_data *));
+
+  type_hash = allocate_signatured_type_hash_table (objfile);
+
+  for (i = 0; i < elements; i += 3)
+    {
+      struct signatured_type *type_sig;
+      ULONGEST offset, type_offset, signature;
+      void **slot;
+
+      if (!extract_cu_value (bytes, &offset)
+	  || !extract_cu_value (bytes + 8, &type_offset))
+	return 0;
+      signature = extract_unsigned_integer (bytes + 16, 8, BFD_ENDIAN_LITTLE);
+      bytes += 3 * 8;
+
+      type_sig = OBSTACK_ZALLOC (&objfile->objfile_obstack,
+				 struct signatured_type);
+      type_sig->signature = signature;
+      type_sig->offset = offset;
+      type_sig->type_offset = type_offset;
+      type_sig->per_cu.from_debug_types = 1;
+      type_sig->per_cu.offset = offset;
+      type_sig->per_cu.objfile = objfile;
+      type_sig->per_cu.v.quick
+	= OBSTACK_ZALLOC (&objfile->objfile_obstack,
+			  struct dwarf2_per_cu_quick_data);
+
+      slot = htab_find_slot (type_hash, type_sig, INSERT);
+      *slot = type_sig;
+
+      dwarf2_per_objfile->type_comp_units[i / 3] = &type_sig->per_cu;
+    }
+
+  dwarf2_per_objfile->signatured_types = type_hash;
+
+  return 1;
+}
+
 /* Read the address map data from the mapped index, and use it to
    populate the objfile's psymtabs_addrmap.  */
 static void
@@ -1695,7 +1768,7 @@
       iter += 4;
       
       addrmap_set_empty (mutable_map, lo + baseaddr, hi + baseaddr - 1,
-			 dwarf2_per_objfile->all_comp_units[cu_index]);
+			 dw2_get_cu (cu_index));
     }
 
   objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
@@ -1762,8 +1835,9 @@
   char *addr;
   struct mapped_index *map;
   offset_type *metadata;
-  const gdb_byte *cu_list;
-  offset_type cu_list_elements;
+  const gdb_byte *cu_list, *types_list;
+  offset_type version, cu_list_elements, types_list_elements;
+  int i;
 
   if (dwarf2_per_objfile->gdb_index.asection == NULL
       || dwarf2_per_objfile->gdb_index.size == 0)
@@ -1772,26 +1846,58 @@
 
   addr = dwarf2_per_objfile->gdb_index.buffer;
   /* Version check.  */
-  if (MAYBE_SWAP (*(offset_type *) addr) != 1)
+  version = MAYBE_SWAP (*(offset_type *) addr);
+  if (version == 1)
+    {
+      /* Index version 1 neglected to account for .debug_types.  So,
+	 if we see .debug_types, we cannot use this index.  */
+      if (dwarf2_per_objfile->types.asection != NULL
+	  && dwarf2_per_objfile->types.size != 0)
+	return 0;
+    }
+  else if (version != 2)
     return 0;
 
   map = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct mapped_index);
   map->total_size = dwarf2_per_objfile->gdb_index.size;
 
   metadata = (offset_type *) (addr + sizeof (offset_type));
-  cu_list = addr + MAYBE_SWAP (metadata[0]);
-  cu_list_elements = ((MAYBE_SWAP (metadata[1]) - MAYBE_SWAP (metadata[0]))
+
+  i = 0;
+  cu_list = addr + MAYBE_SWAP (metadata[i]);
+  cu_list_elements = ((MAYBE_SWAP (metadata[i + 1]) - MAYBE_SWAP (metadata[i]))
 		      / 8);
-  map->address_table = addr + MAYBE_SWAP (metadata[1]);
-  map->address_table_size = (MAYBE_SWAP (metadata[2])
-			     - MAYBE_SWAP (metadata[1]));
-  map->index_table = (offset_type *) (addr + MAYBE_SWAP (metadata[2]));
-  map->index_table_slots = ((MAYBE_SWAP (metadata[3])
-			     - MAYBE_SWAP (metadata[2]))
+  ++i;
+
+  if (version == 2)
+    {
+      types_list = addr + MAYBE_SWAP (metadata[i]);
+      types_list_elements = ((MAYBE_SWAP (metadata[i + 1])
+			      - MAYBE_SWAP (metadata[i]))
+			     / 8);
+      ++i;
+    }
+
+  map->address_table = addr + MAYBE_SWAP (metadata[i]);
+  map->address_table_size = (MAYBE_SWAP (metadata[i + 1])
+			     - MAYBE_SWAP (metadata[i]));
+  ++i;
+
+  map->index_table = (offset_type *) (addr + MAYBE_SWAP (metadata[i]));
+  map->index_table_slots = ((MAYBE_SWAP (metadata[i + 1])
+			     - MAYBE_SWAP (metadata[i]))
 			    / (2 * sizeof (offset_type)));
-  map->constant_pool = addr + MAYBE_SWAP (metadata[3]);
+  ++i;
 
-  if (!create_cus_from_index (objfile, map, cu_list, cu_list_elements))
+  map->constant_pool = addr + MAYBE_SWAP (metadata[i]);
+
+  if (!create_cus_from_index (objfile, cu_list, cu_list_elements))
+    return 0;
+
+  if (version == 2
+      && types_list_elements
+      && !create_signatured_type_hash_from_index (objfile, types_list,
+						  types_list_elements))
     return 0;
 
   create_addrmap_from_index (objfile, map);
@@ -1918,8 +2024,7 @@
   int index;
   dw2_setup (objfile);
   index = dwarf2_per_objfile->n_comp_units - 1;
-  return dw2_instantiate_symtab (objfile,
-				 dwarf2_per_objfile->all_comp_units[index]);
+  return dw2_instantiate_symtab (objfile, dw2_get_cu (index));
 }
 
 static void
@@ -1928,9 +2033,10 @@
   int i;
 
   dw2_setup (objfile);
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       if (cu->v.quick->full_names)
 	{
@@ -1952,10 +2058,11 @@
   struct dwarf2_per_cu_data *base_cu = NULL;
 
   dw2_setup (objfile);
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
       int j;
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       if (cu->v.quick->symtab)
 	continue;
@@ -2047,8 +2154,8 @@
 	  for (i = 0; i < len; ++i)
 	    {
 	      offset_type cu_index = MAYBE_SWAP (vec[i + 1]);
-	      struct dwarf2_per_cu_data *cu;
-	      cu = dwarf2_per_objfile->all_comp_units[cu_index];
+	      struct dwarf2_per_cu_data *cu = dw2_get_cu (cu_index);
+
 	      dw2_instantiate_symtab (objfile, cu);
 	    }
 	}
@@ -2070,9 +2177,10 @@
 
   dw2_setup (objfile);
   count = 0;
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       if (!cu->v.quick->symtab)
 	++count;
@@ -2106,9 +2214,11 @@
   int i;
 
   dw2_setup (objfile);
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       dw2_instantiate_symtab (objfile, cu);
     }
@@ -2121,10 +2231,11 @@
   int i;
 
   dw2_setup (objfile);
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
       int j;
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       if (cu->v.quick->symtab)
 	continue;
@@ -2165,7 +2276,7 @@
      should be rewritten so that it doesn't require a custom hook.  It
      could just use the ordinary symbol tables.  */
   /* vec[0] is the length, which must always be >0.  */
-  cu = dwarf2_per_objfile->all_comp_units[MAYBE_SWAP (vec[1])];
+  cu = dw2_get_cu (MAYBE_SWAP (vec[1]));
 
   dw2_require_line_header (objfile, cu);
   if (!cu->v.quick->lines)
@@ -2204,10 +2315,11 @@
   if (!dwarf2_per_objfile->index_table)
     return;
 
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
       int j;
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       cu->v.quick->mark = 0;
       if (cu->v.quick->symtab)
@@ -2252,8 +2364,9 @@
       vec_len = MAYBE_SWAP (vec[0]);
       for (vec_idx = 0; vec_idx < vec_len; ++vec_idx)
 	{
-	  struct dwarf2_per_cu_data *cu
-	    = dwarf2_per_objfile->all_comp_units[MAYBE_SWAP (vec[vec_idx + 1])];
+	  struct dwarf2_per_cu_data *cu;
+
+	  cu = dw2_get_cu (MAYBE_SWAP (vec[vec_idx + 1]));
 	  if (cu->v.quick->mark)
 	    dw2_instantiate_symtab (objfile, cu);
 	}
@@ -2323,10 +2436,11 @@
   int i;
 
   dw2_setup (objfile);
-  for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+  for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		   + dwarf2_per_objfile->n_type_comp_units); ++i)
     {
       int j;
-      struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+      struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
       if (cu->v.quick->symtab)
 	continue;
@@ -2387,10 +2501,12 @@
 
       dwarf2_per_objfile->using_index = 1;
       create_all_comp_units (objfile);
+      create_debug_types_hash_table (objfile);
 
-      for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+      for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+		       + dwarf2_per_objfile->n_type_comp_units); ++i)
 	{
-	  struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
+	  struct dwarf2_per_cu_data *cu = dw2_get_cu (i);
 
 	  cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
 					struct dwarf2_per_cu_quick_data);
@@ -2604,6 +2720,34 @@
   return lhs->signature == rhs->signature;
 }
 
+/* Allocate a hash table for signatured types.  */
+
+static htab_t
+allocate_signatured_type_hash_table (struct objfile *objfile)
+{
+  return htab_create_alloc_ex (41,
+			       hash_type_signature,
+			       eq_type_signature,
+			       NULL,
+			       &objfile->objfile_obstack,
+			       hashtab_obstack_allocate,
+			       dummy_obstack_deallocate);
+}
+
+/* A helper function to add a signatured type CU to a list.  */
+
+static int
+add_signatured_type_cu_to_list (void **slot, void *datum)
+{
+  struct signatured_type *sigt = *slot;
+  struct dwarf2_per_cu_data ***datap = datum;
+
+  **datap = &sigt->per_cu;
+  ++*datap;
+
+  return 1;
+}
+
 /* Create the hash table of all entries in the .debug_types section.
    The result is zero if there is an error (e.g. missing .debug_types section),
    otherwise non-zero.	*/
@@ -2613,6 +2757,7 @@
 {
   gdb_byte *info_ptr;
   htab_t types_htab;
+  struct dwarf2_per_cu_data **iter;
 
   dwarf2_read_section (objfile, &dwarf2_per_objfile->types);
   info_ptr = dwarf2_per_objfile->types.buffer;
@@ -2623,13 +2768,7 @@
       return 0;
     }
 
-  types_htab = htab_create_alloc_ex (41,
-				     hash_type_signature,
-				     eq_type_signature,
-				     NULL,
-				     &objfile->objfile_obstack,
-				     hashtab_obstack_allocate,
-				     dummy_obstack_deallocate);
+  types_htab = allocate_signatured_type_hash_table (objfile);
 
   if (dwarf2_die_debug)
     fprintf_unfiltered (gdb_stdlog, "Signatured types:\n");
@@ -2677,6 +2816,7 @@
       type_sig->offset = offset;
       type_sig->type_offset = type_offset;
       type_sig->per_cu.objfile = objfile;
+      type_sig->per_cu.from_debug_types = 1;
 
       slot = htab_find_slot (types_htab, type_sig, INSERT);
       gdb_assert (slot != NULL);
@@ -2691,6 +2831,16 @@
 
   dwarf2_per_objfile->signatured_types = types_htab;
 
+  dwarf2_per_objfile->n_type_comp_units = htab_elements (types_htab);
+  dwarf2_per_objfile->type_comp_units
+    = obstack_alloc (&objfile->objfile_obstack,
+		     dwarf2_per_objfile->n_type_comp_units
+		     * sizeof (struct dwarf2_per_cu_data *));
+  iter = &dwarf2_per_objfile->type_comp_units[0];
+  htab_traverse_noresize (types_htab, add_signatured_type_cu_to_list, &iter);
+  gdb_assert (iter - &dwarf2_per_objfile->type_comp_units[0]
+	      == dwarf2_per_objfile->n_type_comp_units);
+
   return 1;
 }
 
@@ -2959,7 +3109,6 @@
   struct dwarf2_per_cu_data *this_cu;
 
   this_cu = &entry->per_cu;
-  this_cu->from_debug_types = 1;
 
   gdb_assert (dwarf2_per_objfile->types.readin);
   process_psymtab_comp_unit (objfile, this_cu,
@@ -12067,13 +12216,16 @@
 read_signatured_type (struct objfile *objfile,
 		      struct signatured_type *type_sig)
 {
-  gdb_byte *types_ptr = dwarf2_per_objfile->types.buffer + type_sig->offset;
+  gdb_byte *types_ptr;
   struct die_reader_specs reader_specs;
   struct dwarf2_cu *cu;
   ULONGEST signature;
   struct cleanup *back_to, *free_cu_cleanup;
   struct attribute *attr;
 
+  dwarf2_read_section (objfile, &dwarf2_per_objfile->types);
+  types_ptr = dwarf2_per_objfile->types.buffer + type_sig->offset;
+
   gdb_assert (type_sig->per_cu.cu == NULL);
 
   cu = xmalloc (sizeof (struct dwarf2_cu));
@@ -13912,6 +14064,10 @@
   char addr[8];
   CORE_ADDR baseaddr;
 
+  /* Don't bother recording empty ranges.  */
+  if (pst->textlow == pst->texthigh)
+    return;
+
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
 
   store_unsigned_integer (addr, 8, BFD_ENDIAN_LITTLE, pst->textlow - baseaddr);
@@ -13957,13 +14113,53 @@
     unlink (*filename);
 }
 
+/* A helper struct used when iterating over debug_types.  */
+struct signatured_type_index_data
+{
+  struct objfile *objfile;
+  struct mapped_symtab *symtab;
+  struct obstack *types_list;
+  int cu_index;
+};
+
+/* A helper function that writes a single signatured_type to an
+   obstack.  */
+static int
+write_one_signatured_type (void **slot, void *d)
+{
+  struct signatured_type_index_data *info = d;
+  struct signatured_type *entry = (struct signatured_type *) *slot;
+  struct dwarf2_per_cu_data *cu = &entry->per_cu;
+  struct partial_symtab *psymtab = cu->v.psymtab;
+  gdb_byte val[8];
+
+  write_psymbols (info->symtab,
+		  info->objfile->global_psymbols.list + psymtab->globals_offset,
+		  psymtab->n_global_syms, info->cu_index);
+  write_psymbols (info->symtab,
+		  info->objfile->static_psymbols.list + psymtab->statics_offset,
+		  psymtab->n_static_syms, info->cu_index);
+
+  store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->offset);
+  obstack_grow (info->types_list, val, 8);
+  store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->type_offset);
+  obstack_grow (info->types_list, val, 8);
+  store_unsigned_integer (val, 8, BFD_ENDIAN_LITTLE, entry->signature);
+  obstack_grow (info->types_list, val, 8);
+
+  ++info->cu_index;
+
+  return 1;
+}
+
 /* Create an index file for OBJFILE in the directory DIR.  */
 static void
 write_psymtabs_to_index (struct objfile *objfile, const char *dir)
 {
   struct cleanup *cleanup;
   char *filename, *cleanup_filename;
-  struct obstack contents, addr_obstack, constant_pool, symtab_obstack, cu_list;
+  struct obstack contents, addr_obstack, constant_pool, symtab_obstack;
+  struct obstack cu_list, types_cu_list;
   int i;
   FILE *out_file;
   struct mapped_symtab *symtab;
@@ -13999,6 +14195,12 @@
   obstack_init (&cu_list);
   make_cleanup_obstack_free (&cu_list);
 
+  obstack_init (&types_cu_list);
+  make_cleanup_obstack_free (&types_cu_list);
+
+  /* The list is already sorted, so we don't need to do additional
+     work here.  Also, the debug_types entries do not appear in
+     all_comp_units, but only in their own hash table.  */
   for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
     {
       struct dwarf2_per_cu_data *cu = dwarf2_per_objfile->all_comp_units[i];
@@ -14020,6 +14222,19 @@
       obstack_grow (&cu_list, val, 8);
     }
 
+  /* Write out the .debug_type entries, if any.  */
+  if (dwarf2_per_objfile->signatured_types)
+    {
+      struct signatured_type_index_data sig_data;
+
+      sig_data.objfile = objfile;
+      sig_data.symtab = symtab;
+      sig_data.types_list = &types_cu_list;
+      sig_data.cu_index = dwarf2_per_objfile->n_comp_units;
+      htab_traverse_noresize (dwarf2_per_objfile->signatured_types,
+			      write_one_signatured_type, &sig_data);
+    }
+
   obstack_init (&constant_pool);
   make_cleanup_obstack_free (&constant_pool);
   obstack_init (&symtab_obstack);
@@ -14028,11 +14243,11 @@
 
   obstack_init (&contents);
   make_cleanup_obstack_free (&contents);
-  size_of_contents = 5 * sizeof (offset_type);
+  size_of_contents = 6 * sizeof (offset_type);
   total_len = size_of_contents;
 
   /* The version number.  */
-  val = MAYBE_SWAP (1);
+  val = MAYBE_SWAP (2);
   obstack_grow (&contents, &val, sizeof (val));
 
   /* The offset of the CU list from the start of the file.  */
@@ -14040,6 +14255,11 @@
   obstack_grow (&contents, &val, sizeof (val));
   total_len += obstack_object_size (&cu_list);
 
+  /* The offset of the types CU list from the start of the file.  */
+  val = MAYBE_SWAP (total_len);
+  obstack_grow (&contents, &val, sizeof (val));
+  total_len += obstack_object_size (&types_cu_list);
+
   /* The offset of the address table from the start of the file.  */
   val = MAYBE_SWAP (total_len);
   obstack_grow (&contents, &val, sizeof (val));
@@ -14059,6 +14279,7 @@
 
   write_obstack (out_file, &contents);
   write_obstack (out_file, &cu_list);
+  write_obstack (out_file, &types_cu_list);
   write_obstack (out_file, &addr_obstack);
   write_obstack (out_file, &symtab_obstack);
   write_obstack (out_file, &constant_pool);
@@ -14083,18 +14304,33 @@
 
    1. The file header.  This is a sequence of values, of offset_type
    unless otherwise noted:
-   [0] The version number.  Currently 1.
+   [0] The version number.  Currently 1 or 2.  The differences are
+   noted below.  Version 1 did not account for .debug_types sections;
+   the presence of a .debug_types section invalidates any version 1
+   index that may exist.
    [1] The offset, from the start of the file, of the CU list.
+   [1.5] In version 2, the offset, from the start of the file, of the
+   types CU list.  This offset does not appear in version 1.  Note
+   that this can be empty, in which case this offset will be equal to
+   the next offset.
    [2] The offset, from the start of the file, of the address section.
    [3] The offset, from the start of the file, of the symbol table.
    [4] The offset, from the start of the file, of the constant pool.
 
    2. The CU list.  This is a sequence of pairs of 64-bit
-   little-endian values.  The first element in each pair is the offset
-   of a CU in the .debug_info section.  The second element in each
-   pair is the length of that CU.  References to a CU elsewhere in the
-   map are done using a CU index, which is just the 0-based index into
-   this table.
+   little-endian values, sorted by the CU offset.  The first element
+   in each pair is the offset of a CU in the .debug_info section.  The
+   second element in each pair is the length of that CU.  References
+   to a CU elsewhere in the map are done using a CU index, which is
+   just the 0-based index into this table.  Note that if there are
+   type CUs, then conceptually CUs and type CUs form a single list for
+   the purposes of CU indices.
+
+   2.5 The types CU list.  This does not appear in a version 1 index.
+   This is a sequence of triplets of 64-bit little-endian values.  In
+   a triplet, the first value is the CU offset, the second value is
+   the type offset in the CU, and the third value is the type
+   signature.  The types CU list is not sorted.
 
    3. The address section.  The address section consists of a sequence
    of address entries.  Each address entry has three elements.

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-23 22:12           ` Tom Tromey
@ 2010-07-26 18:41             ` Ken Werner
  2010-07-26 18:50               ` Tom Tromey
  0 siblings, 1 reply; 34+ messages in thread
From: Ken Werner @ 2010-07-26 18:41 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

[-- Attachment #1: Type: Text/Plain, Size: 992 bytes --]

On Saturday, July 24, 2010 12:12:03 am Tom Tromey wrote:
> >>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
> Tom> Here is what I am testing.
> 
> Here is the variant I am checking it.  It seems to work with all
> combinations of .debug_types, .gdb_index, and -readnow.
> 
> Let me know if you hit any more problems.

Hi Tom,

It seems old GCCs do not recognize that the types_list_elements and types_list 
variables of dwarf2read.c:dwarf2_initialize_objfile are accessed under the 
same condition as they are initialized. GCC 4.1.2 (RHEL5) issues the following 
warning:
<snip>
src/gdb/dwarf2read.c: In function ‘dwarf2_initialize_objfile’:
src/gdb/dwarf2read.c:1839: warning: ‘types_list_elements’ may be used 
uninitialized in this function
src/gdb/dwarf2read.c:1838: warning: ‘types_list’ may be used uninitialized in 
this function
</snip>

The attached patch initializes the two variables to prevent the warnings.
OK to apply?

Regards
-ken

[-- Attachment #2: dwarf2read-warnings.patch --]
[-- Type: text/x-patch, Size: 893 bytes --]

Changelog:

2010-07-06  Ken Werner  <ken.werner@de.ibm.com>

	* valops.c (dwarf2_read_index): Initialize the types_list and 
	types_list_elements variables.


Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.425
diff -p -u -r1.425 dwarf2read.c
--- dwarf2read.c	23 Jul 2010 22:15:13 -0000	1.425
+++ dwarf2read.c	26 Jul 2010 18:06:02 -0000
@@ -1835,8 +1835,10 @@ dwarf2_read_index (struct objfile *objfi
   char *addr;
   struct mapped_index *map;
   offset_type *metadata;
-  const gdb_byte *cu_list, *types_list;
-  offset_type version, cu_list_elements, types_list_elements;
+  const gdb_byte *cu_list;
+  const gdb_byte *types_list = NULL;
+  offset_type version, cu_list_elements;
+  offset_type types_list_elements = 0;
   int i;
 
   if (dwarf2_per_objfile->gdb_index.asection == NULL

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-26 18:41             ` Ken Werner
@ 2010-07-26 18:50               ` Tom Tromey
  2010-07-27  7:58                 ` Ken Werner
  0 siblings, 1 reply; 34+ messages in thread
From: Tom Tromey @ 2010-07-26 18:50 UTC (permalink / raw)
  To: Ken Werner; +Cc: gdb-patches

>>>>> "Ken" == Ken Werner <ken@linux.vnet.ibm.com> writes:

Ken> It seems old GCCs do not recognize that the types_list_elements and
Ken> types_list variables of dwarf2read.c:dwarf2_initialize_objfile are
Ken> accessed under the same condition as they are initialized.

Ken> The attached patch initializes the two variables to prevent the warnings.
Ken> OK to apply?

Yes, thank you.

Tom

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-26 18:50               ` Tom Tromey
@ 2010-07-27  7:58                 ` Ken Werner
  0 siblings, 0 replies; 34+ messages in thread
From: Ken Werner @ 2010-07-27  7:58 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Monday, July 26, 2010 08:50:29 pm Tom Tromey wrote:
> >>>>> "Ken" == Ken Werner <ken@linux.vnet.ibm.com> writes:
> Ken> It seems old GCCs do not recognize that the types_list_elements and
> Ken> types_list variables of dwarf2read.c:dwarf2_initialize_objfile are
> Ken> accessed under the same condition as they are initialized.
> 
> Ken> The attached patch initializes the two variables to prevent the
> warnings. Ken> OK to apply?
> 
> Yes, thank you.

Patch checked in.
-ken

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-09 17:31 ` Tom Tromey
  2010-07-09 17:45   ` Eli Zaretskii
  2010-07-22 11:31   ` Jan Kratochvil
@ 2010-07-30 20:46   ` Tom Tromey
  2010-08-02 18:10     ` Doug Evans
  2 siblings, 1 reply; 34+ messages in thread
From: Tom Tromey @ 2010-07-30 20:46 UTC (permalink / raw)
  To: gdb-patches

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> Roland suggested we wrap up the index-creation code into a helper
Tom> script.

Tom> I'm not sure if this is something people would want in gdb proper, but I
Tom> figured I would send it here just in case.

I am going to check this in.
I'm actually committing the appended.  I addressed Eli's comments, and I
added ".sh" to the name of the file as it appears in the source tree.

Tom

2010-07-30  Tom Tromey  <tromey@redhat.com>

	* Makefile.in (install-only): Install gdb-add-index.
	* gdb-add-index.sh: New file.

2010-07-30  Tom Tromey  <tromey@redhat.com>

	* gdb.texinfo (Index Files): Mention gdb-add-index.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.1128
diff -u -r1.1128 Makefile.in
--- Makefile.in	28 Jul 2010 18:32:33 -0000	1.1128
+++ Makefile.in	30 Jul 2010 20:45:30 -0000
@@ -1018,7 +1018,16 @@
 		$(SHELL) $(srcdir)/../mkinstalldirs \
 			$(DESTDIR)$(man1dir) ; \
 		$(INSTALL_DATA) $(srcdir)/gdb.1 \
-			$(DESTDIR)$(man1dir)/$$transformed_name.1
+			$(DESTDIR)$(man1dir)/$$transformed_name.1; \
+	transformed_name=`t='$(program_transform_name)'; \
+			  echo gdb-add-index | sed -e "$$t"` ; \
+		if test "x$$transformed_name" = x; then \
+		  transformed_name=gdb-add-index ; \
+		else \
+		  true ; \
+		fi ; \
+		$(INSTALL_PROGRAM) $(srcdir)/gdb-add-index.sh \
+			$(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT)
 	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 .PHONY: install-tui
 install-tui:
Index: gdb-add-index.sh
===================================================================
RCS file: gdb-add-index.sh
diff -N gdb-add-index.sh
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gdb-add-index.sh	30 Jul 2010 20:45:30 -0000
@@ -0,0 +1,29 @@
+#! /bin/sh
+
+# Add a .gdb_index section to a file.
+
+# Copyright (C) 2010 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/>.
+
+file="$1"
+dir="${file%/*}"
+
+gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir"
+
+if test -f "${file}.gdb-index"; then
+   objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file"
+   rm -f "${file}.gdb-index"
+fi
+
+exit 0
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.745
diff -u -r1.745 gdb.texinfo
--- doc/gdb.texinfo	30 Jul 2010 14:32:02 -0000	1.745
+++ doc/gdb.texinfo	30 Jul 2010 20:45:34 -0000
@@ -15244,6 +15244,15 @@
 for DWARF debugging information, not stabs.  And, they do not
 currently work for programs using Ada.
 
+@pindex gdb-add-index
+@value{GDBN} comes with a program, @command{gdb-add-index}, which can
+be used to add the index to a symbol file.  It takes the symbol file
+as its only argument:
+
+@smallexample
+$ gdb-add-index symfile
+@end smallexample
+
 
 @node Symbol Errors
 @section Errors Reading Symbol Files

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

* Re: [0/4] RFC: add DWARF index support
  2010-07-30 20:46   ` Tom Tromey
@ 2010-08-02 18:10     ` Doug Evans
  2010-08-05 16:30       ` Tom Tromey
  0 siblings, 1 reply; 34+ messages in thread
From: Doug Evans @ 2010-08-02 18:10 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Fri, Jul 30, 2010 at 1:46 PM, Tom Tromey <tromey@redhat.com> wrote:
> [...]
> Index: gdb-add-index.sh
> ===================================================================
> RCS file: gdb-add-index.sh
> diff -N gdb-add-index.sh
> --- /dev/null   1 Jan 1970 00:00:00 -0000
> +++ gdb-add-index.sh    30 Jul 2010 20:45:30 -0000
> @@ -0,0 +1,29 @@
> +#! /bin/sh
> +
> +# Add a .gdb_index section to a file.
> +
> +# Copyright (C) 2010 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/>.
> +
> +file="$1"
> +dir="${file%/*}"
> +
> +gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir"
> +
> +if test -f "${file}.gdb-index"; then
> +   objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file"
> +   rm -f "${file}.gdb-index"
> +fi
> +
> +exit 0

Should this script be more robust w.r.t. errors?

e.g.
What happens if gdb exits with a non-zero exit code but still happens
to leave a .gdb-index for the `if' to find?
What happens if objcopy exits with a non-zero exit code?
What happens if the script is invoked with none or too many arguments?

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-02 18:10     ` Doug Evans
@ 2010-08-05 16:30       ` Tom Tromey
  2010-08-05 16:32         ` Doug Evans
  0 siblings, 1 reply; 34+ messages in thread
From: Tom Tromey @ 2010-08-05 16:30 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> What happens if gdb exits with a non-zero exit code but still happens
Doug> to leave a .gdb-index for the `if' to find?

I don't think this can happen.

Doug> What happens if objcopy exits with a non-zero exit code?
Doug> What happens if the script is invoked with none or too many arguments?

I will fix these up.

Tom

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-05 16:30       ` Tom Tromey
@ 2010-08-05 16:32         ` Doug Evans
  2010-08-05 19:55           ` Tom Tromey
  2010-08-05 19:57           ` Tom Tromey
  0 siblings, 2 replies; 34+ messages in thread
From: Doug Evans @ 2010-08-05 16:32 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Thu, Aug 5, 2010 at 9:29 AM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Doug" == Doug Evans <dje@google.com> writes:
>
> Doug> What happens if gdb exits with a non-zero exit code but still happens
> Doug> to leave a .gdb-index for the `if' to find?
>
> I don't think this can happen.

... assuming there are no bugs.

> Doug> What happens if objcopy exits with a non-zero exit code?
> Doug> What happens if the script is invoked with none or too many arguments?
>
> I will fix these up.

Thanks.

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-05 16:32         ` Doug Evans
@ 2010-08-05 19:55           ` Tom Tromey
  2010-08-05 19:57           ` Tom Tromey
  1 sibling, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2010-08-05 19:55 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

>> I don't think this can happen.

Doug> ... assuming there are no bugs.

Ok.

What do you think of this?

Tom

2010-08-05  Tom Tromey  <tromey@redhat.com>

	* gdb-add-index.sh: Add error checking.

Index: gdb-add-index.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdb-add-index.sh,v
retrieving revision 1.1
diff -u -r1.1 gdb-add-index.sh
--- gdb-add-index.sh	30 Jul 2010 20:46:34 -0000	1.1
+++ gdb-add-index.sh	5 Aug 2010 19:46:00 -0000
@@ -19,11 +19,19 @@
 file="$1"
 dir="${file%/*}"
 
-gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir"
+gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir" || {
+   # Just in case.
+   rm -f "${file}.gdb-index"
+   exit 1
+}
 
+# In some situation gdb can exit without creating an index.  This is
+# not an error.
+status=0
 if test -f "${file}.gdb-index"; then
    objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file"
+   status=$?
    rm -f "${file}.gdb-index"
 fi
 
-exit 0
+exit $status

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-05 16:32         ` Doug Evans
  2010-08-05 19:55           ` Tom Tromey
@ 2010-08-05 19:57           ` Tom Tromey
  2010-08-06 17:15             ` Doug Evans
  1 sibling, 1 reply; 34+ messages in thread
From: Tom Tromey @ 2010-08-05 19:57 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

Doug> What happens if the script is invoked with none or too many arguments?

Oops, forgot this one.

New patch.

Tom

2010-08-05  Tom Tromey  <tromey@redhat.com>

	* gdb-add-index.sh: Add error checking.

Index: gdb-add-index.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdb-add-index.sh,v
retrieving revision 1.1
diff -u -r1.1 gdb-add-index.sh
--- gdb-add-index.sh	30 Jul 2010 20:46:34 -0000	1.1
+++ gdb-add-index.sh	5 Aug 2010 19:56:24 -0000
@@ -16,14 +16,27 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+if test $# -ne 1; then
+   echo "Usage: gdb-add-index FILE" 1>&2
+   exit 1
+fi
+
 file="$1"
 dir="${file%/*}"
 
-gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir"
+gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir" || {
+   # Just in case.
+   rm -f "${file}.gdb-index"
+   exit 1
+}
 
+# In some situation gdb can exit without creating an index.  This is
+# not an error.
+status=0
 if test -f "${file}.gdb-index"; then
    objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file"
+   status=$?
    rm -f "${file}.gdb-index"
 fi
 
-exit 0
+exit $status

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-05 19:57           ` Tom Tromey
@ 2010-08-06 17:15             ` Doug Evans
  2010-08-06 17:40               ` Tom Tromey
  0 siblings, 1 reply; 34+ messages in thread
From: Doug Evans @ 2010-08-06 17:15 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Thu, Aug 5, 2010 at 12:56 PM, Tom Tromey <tromey@redhat.com> wrote:
> Doug> What happens if the script is invoked with none or too many arguments?
>
> Oops, forgot this one.
>
> New patch.
>
> Tom
>
> 2010-08-05  Tom Tromey  <tromey@redhat.com>
>
>        * gdb-add-index.sh: Add error checking.
>
> Index: gdb-add-index.sh
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdb-add-index.sh,v
> retrieving revision 1.1
> diff -u -r1.1 gdb-add-index.sh
> --- gdb-add-index.sh    30 Jul 2010 20:46:34 -0000      1.1
> +++ gdb-add-index.sh    5 Aug 2010 19:56:24 -0000
> @@ -16,14 +16,27 @@
>  # You should have received a copy of the GNU General Public License
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>
> +if test $# -ne 1; then
> +   echo "Usage: gdb-add-index FILE" 1>&2
> +   exit 1
> +fi
> +
>  file="$1"
>  dir="${file%/*}"
>
> -gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir"
> +gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir" || {
> +   # Just in case.

status=$?

> +   rm -f "${file}.gdb-index"
> +   exit 1

exit $status

> +}
>
> +# In some situation gdb can exit without creating an index.  This is
> +# not an error.
> +status=0
>  if test -f "${file}.gdb-index"; then
>    objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file"
> +   status=$?
>    rm -f "${file}.gdb-index"
>  fi
>
> -exit 0
> +exit $status
>

IWBN to add to the comment about exiting without creating an index not
being an error, e.g. provide an example.
Is it because the file could be stripped?  [If it is stripped, should
the script fail or pass?  Dunno.]

IWBN to put "${file}.gdb-index" in its own variable so that there's
just one instance.

LGTM with the above nits.

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-06 17:15             ` Doug Evans
@ 2010-08-06 17:40               ` Tom Tromey
  2010-08-06 20:53                 ` Doug Evans
                                   ` (2 more replies)
  0 siblings, 3 replies; 34+ messages in thread
From: Tom Tromey @ 2010-08-06 17:40 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

Doug> IWBN to add to the comment about exiting without creating an index not
Doug> being an error, e.g. provide an example.
Doug> Is it because the file could be stripped?  [If it is stripped, should
Doug> the script fail or pass?  Dunno.]

I don't want to do this, because the reasons may change.

Doug> IWBN to put "${file}.gdb-index" in its own variable so that there's
Doug> just one instance.

Ok.

Doug> LGTM with the above nits.

I don't know what LGTM means.

How about this?

Tom

2010-08-05  Tom Tromey  <tromey@redhat.com>

	* gdb-add-index.sh: Add error checking.

Index: gdb-add-index.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdb-add-index.sh,v
retrieving revision 1.1
diff -u -r1.1 gdb-add-index.sh
--- gdb-add-index.sh	30 Jul 2010 20:46:34 -0000	1.1
+++ gdb-add-index.sh	6 Aug 2010 17:39:20 -0000
@@ -16,14 +16,29 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+if test $# -ne 1; then
+   echo "Usage: gdb-add-index FILE" 1>&2
+   exit 1
+fi
+
 file="$1"
 dir="${file%/*}"
+index="${file}.gdb-index"
 
-gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir"
+gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir" || {
+   status=$?
+   # Just in case.
+   rm -f "$index"
+   exit $status
+}
 
-if test -f "${file}.gdb-index"; then
-   objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file"
-   rm -f "${file}.gdb-index"
+# In some situation gdb can exit without creating an index.  This is
+# not an error.
+status=0
+if test -f "${index}"; then
+   objcopy --add-section .gdb_index="${index}" --set-section-flags .gdb_index=readonly "$file" "$file"
+   status=$?
+   rm -f "${index}"
 fi
 
-exit 0
+exit $status

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-06 17:40               ` Tom Tromey
@ 2010-08-06 20:53                 ` Doug Evans
  2010-08-09 20:36                   ` Tom Tromey
  2010-08-09 20:25                 ` Jan Kratochvil
  2010-08-09 20:33                 ` Jan Kratochvil
  2 siblings, 1 reply; 34+ messages in thread
From: Doug Evans @ 2010-08-06 20:53 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Fri, Aug 6, 2010 at 10:39 AM, Tom Tromey <tromey@redhat.com> wrote:
> Doug> IWBN to add to the comment about exiting without creating an index not
> Doug> being an error, e.g. provide an example.
> Doug> Is it because the file could be stripped?  [If it is stripped, should
> Doug> the script fail or pass?  Dunno.]
>
> I don't want to do this, because the reasons may change.

I don't want to unnecessarily delay the patch (given, for example, its
size), but not generating an index file when asked to and not flagging
an error feels wrong at a gut level.
OTOH strip doesn't flag an error if the file is already stripped.
Maybe this is akin to that.
At any rate, the some examples of this behaviour may be things the
user could trip over, so we should document at least those reasons
somewhere, the script could just contain a reference to the docs.

E.g., I wonder what should happen if there isn't enough (or any) info
to generate .gdb-index.
Is that an error?
I just tried it, no index is saved and gdb doesn't flag an error.
I'm not sure I like that behaviour (but I wouldn't hold up the patch
because of it, I think we agree that the index generation should be
done elsewhere anyway), but can we agree that if we keep it it needs
to be documented (somewhere).  ["it" being cases like trying to
generate an index when there is no debug info present to begin with,
and anything else the user might easily trip over.]

[For completeness sake ...
OTOH, given that index generation should be done elsewhere anyway, I'm
more inclined to be rather strict with what is successful behaviour.
And if such things did flag an error, I think there's less need to
document them. :-)]

> Doug> IWBN to put "${file}.gdb-index" in its own variable so that there's
> Doug> just one instance.
>
> Ok.
>
> Doug> LGTM with the above nits.
>
> I don't know what LGTM means.

"Looks good to me."
[for reference sake, I did see where it ranked in google's search
results before using it. 1/2 :-)
I wasn't sure how common its use was (outside of google anyway).]

> How about this?
>
> Tom
>
> 2010-08-05  Tom Tromey  <tromey@redhat.com>
>
>        * gdb-add-index.sh: Add error checking.
>
> Index: gdb-add-index.sh
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdb-add-index.sh,v
> retrieving revision 1.1
> diff -u -r1.1 gdb-add-index.sh
> --- gdb-add-index.sh    30 Jul 2010 20:46:34 -0000      1.1
> +++ gdb-add-index.sh    6 Aug 2010 17:39:20 -0000
> @@ -16,14 +16,29 @@
>  # You should have received a copy of the GNU General Public License
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>
> +if test $# -ne 1; then
> +   echo "Usage: gdb-add-index FILE" 1>&2
> +   exit 1
> +fi
> +
>  file="$1"
>  dir="${file%/*}"
> +index="${file}.gdb-index"
>
> -gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir"
> +gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir" || {
> +   status=$?
> +   # Just in case.
> +   rm -f "$index"
> +   exit $status
> +}
>
> -if test -f "${file}.gdb-index"; then
> -   objcopy --add-section .gdb_index="${file}.gdb-index" --set-section-flags .gdb_index=readonly "$file" "$file"
> -   rm -f "${file}.gdb-index"
> +# In some situation gdb can exit without creating an index.  This is
> +# not an error.
> +status=0
> +if test -f "${index}"; then
> +   objcopy --add-section .gdb_index="${index}" --set-section-flags .gdb_index=readonly "$file" "$file"
> +   status=$?
> +   rm -f "${index}"
>  fi
>
> -exit 0
> +exit $status
>

Ok.

I hate to add another wrinkle, and thanks for bearing with me.
I just tried passing a file that doesn't exist.  gdb writes something
to stderr and then exits with a zero exit code.
That needs to be flagged as an error (presumably with test -r or some
such before invoking gdb) , but it could be deferred to another patch.

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-06 17:40               ` Tom Tromey
  2010-08-06 20:53                 ` Doug Evans
@ 2010-08-09 20:25                 ` Jan Kratochvil
  2010-08-09 20:43                   ` Tom Tromey
  2010-08-09 20:33                 ` Jan Kratochvil
  2 siblings, 1 reply; 34+ messages in thread
From: Jan Kratochvil @ 2010-08-09 20:25 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Fri, 06 Aug 2010 19:39:51 +0200, Tom Tromey wrote:
> -gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir"
> +gdb --batch-silent -ex "file $file" -ex "save gdb-index $dir" || {

-nx is missing here, breaking index generation for example in ... src/gdb/.


Thanks,
Jan

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-06 17:40               ` Tom Tromey
  2010-08-06 20:53                 ` Doug Evans
  2010-08-09 20:25                 ` Jan Kratochvil
@ 2010-08-09 20:33                 ` Jan Kratochvil
  2 siblings, 0 replies; 34+ messages in thread
From: Jan Kratochvil @ 2010-08-09 20:33 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Fri, 06 Aug 2010 19:39:51 +0200, Tom Tromey wrote:
> +if test $# -ne 1; then
> +   echo "Usage: gdb-add-index FILE" 1>&2
> +   exit 1
> +fi
> +
>  file="$1"
>  dir="${file%/*}"

And if someone runs:
	gdb-add-index namewithoutdirectoty

it also does not run.


Thanks,
Jan

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-06 20:53                 ` Doug Evans
@ 2010-08-09 20:36                   ` Tom Tromey
  2010-08-09 21:16                     ` Doug Evans
  0 siblings, 1 reply; 34+ messages in thread
From: Tom Tromey @ 2010-08-09 20:36 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> I don't want to unnecessarily delay the patch (given, for example, its
Doug> size), but not generating an index file when asked to and not flagging
Doug> an error feels wrong at a gut level.

For our particular use (RPM builds), we'll just ignore errors anyhow,
because (IMO) it is more important for the build to succeed than for
this optimization to be applied.

There are a few problems here if you want it to work the other way.

First, main.c doesn't play well with errors.  When processing -ex
arguments we just ignore error returns, and then later call quit_force,
which exits with status 0.  I think this makes sense to change, but I
have not thought through all the ramifications, or tried to research the
history.

Second, save_gdb_index_command prints the error but doesn't propagate
it.  Since it loops over all objfiles this seemed nicest.  But, we don't
use it that way from this script; maybe we could add a "-fail" option to
the command or something like that.

I think I will just revert the gdb-add-index.sh addition, since it has
too many problems.  I'll revisit it when I can spend some time fixing up
-batch.  I'll send a reversion patch tomorrow.

Doug> E.g., I wonder what should happen if there isn't enough (or any) info
Doug> to generate .gdb-index.
Doug> Is that an error?

I guess it could be.  I don't really care much about the various
pathological cases.

Doug> I hate to add another wrinkle, and thanks for bearing with me.
Doug> I just tried passing a file that doesn't exist.  gdb writes something
Doug> to stderr and then exits with a zero exit code.
Doug> That needs to be flagged as an error (presumably with test -r or some
Doug> such before invoking gdb) , but it could be deferred to another patch.

This is the main.c problem.  The "file" command fails, but that doesn't
affect operation.

Tom

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-09 20:25                 ` Jan Kratochvil
@ 2010-08-09 20:43                   ` Tom Tromey
  0 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2010-08-09 20:43 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

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

Jan> -nx is missing here, breaking index generation for example in ... src/gdb/.

Tom> dir="${file%/*}"

Jan> And if someone runs:
Jan> 	gdb-add-index namewithoutdirectoty
Jan> it also does not run.

Thanks.  I fixed these in my local copy.

Tom

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-09 20:36                   ` Tom Tromey
@ 2010-08-09 21:16                     ` Doug Evans
  2010-08-10 18:46                       ` Tom Tromey
  0 siblings, 1 reply; 34+ messages in thread
From: Doug Evans @ 2010-08-09 21:16 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Mon, Aug 9, 2010 at 1:36 PM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Doug" == Doug Evans <dje@google.com> writes:
>
> Doug> I don't want to unnecessarily delay the patch (given, for example, its
> Doug> size), but not generating an index file when asked to and not flagging
> Doug> an error feels wrong at a gut level.
>
> For our particular use (RPM builds), we'll just ignore errors anyhow,
> because (IMO) it is more important for the build to succeed than for
> this optimization to be applied.

Are you sure you'll just ignore *all* such errors?

I suspect you'd want to at least catch, for example, spelling errors
in file names passed to the script.
Otherwise you'll trip over problems downstream when simple things such
as this could be caught up front.

> There are a few problems here if you want it to work the other way.

Yep.

> First, main.c doesn't play well with errors.  When processing -ex
> arguments we just ignore error returns, and then later call quit_force,
> which exits with status 0.  I think this makes sense to change, but I
> have not thought through all the ramifications, or tried to research the
> history.
>
> Second, save_gdb_index_command prints the error but doesn't propagate
> it.  Since it loops over all objfiles this seemed nicest.  But, we don't
> use it that way from this script; maybe we could add a "-fail" option to
> the command or something like that.

Well, -fail should be the default, and if one wants gdb to be usable
in these kinds of scripting situations, error catching should be a
general facility rather than adhoc additions to particular commands.

For reference sake, some alternatives:
- don't loop, specify the objfile instead?
- don't exit half-completed
   - e.g. if one fails they all fail

> I think I will just revert the gdb-add-index.sh addition, since it has
> too many problems.  I'll revisit it when I can spend some time fixing up
> -batch.  I'll send a reversion patch tomorrow.
>
> Doug> E.g., I wonder what should happen if there isn't enough (or any) info
> Doug> to generate .gdb-index.
> Doug> Is that an error?
>
> I guess it could be.  I don't really care much about the various
> pathological cases.

Well, there are various kinds of pathological cases.
I think we should at least invest time thinking about things the user
is likely to trip over.
[I'd also want to make sure we're on the same page as to what is
pathological, I suspect we are not.]

> Doug> I hate to add another wrinkle, and thanks for bearing with me.
> Doug> I just tried passing a file that doesn't exist.  gdb writes something
> Doug> to stderr and then exits with a zero exit code.
> Doug> That needs to be flagged as an error (presumably with test -r or some
> Doug> such before invoking gdb) , but it could be deferred to another patch.
>
> This is the main.c problem.  The "file" command fails, but that doesn't
> affect operation.

Right, but this is a common thing that can be tripped over, and
trivially dealt with in the script (e.g. with test -r), at least until
gdb supports being scripted better.
[For pedantic completeness sake, there would a window between doing
the test -r and the file command, but *I'm* not suggesting handling
that *pathological* case! :-)]

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-09 21:16                     ` Doug Evans
@ 2010-08-10 18:46                       ` Tom Tromey
  2010-08-10 18:57                         ` Doug Evans
  0 siblings, 1 reply; 34+ messages in thread
From: Tom Tromey @ 2010-08-10 18:46 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> Are you sure you'll just ignore *all* such errors?

Yes.

Doug> I suspect you'd want to at least catch, for example, spelling errors
Doug> in file names passed to the script.

There won't be spelling errors, since in our use gdb-add-index is run
from an RPM build script.

Tom

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

* Re: [0/4] RFC: add DWARF index support
  2010-08-10 18:46                       ` Tom Tromey
@ 2010-08-10 18:57                         ` Doug Evans
  0 siblings, 0 replies; 34+ messages in thread
From: Doug Evans @ 2010-08-10 18:57 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Tue, Aug 10, 2010 at 11:46 AM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Doug" == Doug Evans <dje@google.com> writes:
>
> Doug> Are you sure you'll just ignore *all* such errors?
>
> Yes.
>
> Doug> I suspect you'd want to at least catch, for example, spelling errors
> Doug> in file names passed to the script.
>
> There won't be spelling errors, since in our use gdb-add-index is run
> from an RPM build script.

And RPM build scripts never have bugs, including while they're being developed?

But ok, it's not that important.

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

end of thread, other threads:[~2010-08-10 18:57 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-30 22:33 [0/4] RFC: add DWARF index support Tom Tromey
2010-07-09 17:31 ` Tom Tromey
2010-07-09 17:45   ` Eli Zaretskii
2010-07-09 20:26     ` Tom Tromey
2010-07-10  7:03       ` Eli Zaretskii
2010-07-12 16:52         ` Tom Tromey
2010-07-22 11:31   ` Jan Kratochvil
2010-07-22 15:54     ` Tom Tromey
2010-07-30 20:46   ` Tom Tromey
2010-08-02 18:10     ` Doug Evans
2010-08-05 16:30       ` Tom Tromey
2010-08-05 16:32         ` Doug Evans
2010-08-05 19:55           ` Tom Tromey
2010-08-05 19:57           ` Tom Tromey
2010-08-06 17:15             ` Doug Evans
2010-08-06 17:40               ` Tom Tromey
2010-08-06 20:53                 ` Doug Evans
2010-08-09 20:36                   ` Tom Tromey
2010-08-09 21:16                     ` Doug Evans
2010-08-10 18:46                       ` Tom Tromey
2010-08-10 18:57                         ` Doug Evans
2010-08-09 20:25                 ` Jan Kratochvil
2010-08-09 20:43                   ` Tom Tromey
2010-08-09 20:33                 ` Jan Kratochvil
2010-07-13 20:42 ` Tom Tromey
2010-07-22  4:28   ` Paul Pluzhnikov
2010-07-22 14:14     ` Tom Tromey
2010-07-22 15:54       ` Tom Tromey
2010-07-22 16:20         ` Paul Pluzhnikov
2010-07-22 20:54         ` Tom Tromey
2010-07-23 22:12           ` Tom Tromey
2010-07-26 18:41             ` Ken Werner
2010-07-26 18:50               ` Tom Tromey
2010-07-27  7:58                 ` Ken Werner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).