public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch+80] DWARF-5: Fix -fdebug-types-section
@ 2017-06-29  9:26 Jan Kratochvil
  2017-08-23 23:18 ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kratochvil @ 2017-06-29  9:26 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 146 bytes --]

Hi,

GDB was now accessing as signatured_type memory allocated only by size of
dwarf2_per_cu_data.

This is unrelated to the DWARF-5 index.


Jan

[-- Attachment #2: dwarf51.patch --]
[-- Type: text/plain, Size: 4889 bytes --]

2017-06-29  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2read.c (build_type_psymtabs_reader): New prototype.
	(process_psymtab_comp_unit): Accept IS_DEBUG_TYPES.
	(read_comp_units_from_section): New parameter abbrev_section, use
	read_and_check_comp_unit_head, allocate signatured_type if needed.
	(create_all_comp_units): Update read_comp_units_from_section caller.

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 2369d4b..c6414a7 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1513,6 +1513,11 @@ static void dwarf2_find_base_address (struct die_info *die,
 static struct partial_symtab *create_partial_symtab
   (struct dwarf2_per_cu_data *per_cu, const char *name);
 
+static void build_type_psymtabs_reader (const struct die_reader_specs *reader,
+					const gdb_byte *info_ptr,
+					struct die_info *type_unit_die,
+					int has_children, void *data);
+
 static void dwarf2_build_psymtabs_hard (struct objfile *);
 
 static void scan_partial_symbols (struct partial_die_info *,
@@ -6250,8 +6255,6 @@ process_psymtab_comp_unit (struct dwarf2_per_cu_data *this_cu,
 			   int want_partial_unit,
 			   enum language pretend_language)
 {
-  struct process_psymtab_comp_unit_data info;
-
   /* If this compilation unit was already read in, free the
      cached copy in order to read it in again.	This is
      necessary because we skipped some symbols when we first
@@ -6260,12 +6263,17 @@ process_psymtab_comp_unit (struct dwarf2_per_cu_data *this_cu,
   if (this_cu->cu != NULL)
     free_one_cached_comp_unit (this_cu);
 
-  gdb_assert (! this_cu->is_debug_types);
-  info.want_partial_unit = want_partial_unit;
-  info.pretend_language = pretend_language;
-  init_cutu_and_read_dies (this_cu, NULL, 0, 0,
-			   process_psymtab_comp_unit_reader,
-			   &info);
+  if (this_cu->is_debug_types)
+    init_cutu_and_read_dies (this_cu, NULL, 0, 0, build_type_psymtabs_reader,
+			     NULL);
+  else
+    {
+      process_psymtab_comp_unit_data info;
+      info.want_partial_unit = want_partial_unit;
+      info.pretend_language = pretend_language;
+      init_cutu_and_read_dies (this_cu, NULL, 0, 0,
+			       process_psymtab_comp_unit_reader, &info);
+    }
 
   /* Age out any secondary CUs.  */
   age_cached_comp_units ();
@@ -6720,6 +6728,7 @@ load_partial_comp_unit (struct dwarf2_per_cu_data *this_cu)
 static void
 read_comp_units_from_section (struct objfile *objfile,
 			      struct dwarf2_section_info *section,
+			      struct dwarf2_section_info *abbrev_section,
 			      unsigned int is_dwz,
 			      int *n_allocated,
 			      int *n_comp_units,
@@ -6739,20 +6748,33 @@ read_comp_units_from_section (struct objfile *objfile,
 
   while (info_ptr < section->buffer + section->size)
     {
-      unsigned int length, initial_length_size;
       struct dwarf2_per_cu_data *this_cu;
 
       sect_offset sect_off = (sect_offset) (info_ptr - section->buffer);
 
-      /* Read just enough information to find out where the next
-	 compilation unit is.  */
-      length = read_initial_length (abfd, info_ptr, &initial_length_size);
+      comp_unit_head cu_header;
+      read_and_check_comp_unit_head (&cu_header, section, abbrev_section,
+				     info_ptr, rcuh_kind::COMPILE);
 
       /* Save the compilation unit for later lookup.  */
-      this_cu = XOBNEW (&objfile->objfile_obstack, struct dwarf2_per_cu_data);
-      memset (this_cu, 0, sizeof (*this_cu));
+      if (cu_header.unit_type != DW_UT_type)
+	{
+	  this_cu = XOBNEW (&objfile->objfile_obstack,
+			    struct dwarf2_per_cu_data);
+	  memset (this_cu, 0, sizeof (*this_cu));
+	}
+      else
+	{
+	  auto sig_type = XOBNEW (&objfile->objfile_obstack,
+				  struct signatured_type);
+	  memset (sig_type, 0, sizeof (*sig_type));
+	  sig_type->signature = cu_header.signature;
+	  sig_type->type_offset_in_tu = cu_header.type_cu_offset_in_tu;
+	  this_cu = &sig_type->per_cu;
+	}
+      this_cu->is_debug_types = (cu_header.unit_type == DW_UT_type);
       this_cu->sect_off = sect_off;
-      this_cu->length = length + initial_length_size;
+      this_cu->length = cu_header.length + cu_header.initial_length_size;
       this_cu->is_dwz = is_dwz;
       this_cu->objfile = objfile;
       this_cu->section = section;
@@ -6785,12 +6807,13 @@ create_all_comp_units (struct objfile *objfile)
   n_allocated = 10;
   all_comp_units = XNEWVEC (struct dwarf2_per_cu_data *, n_allocated);
 
-  read_comp_units_from_section (objfile, &dwarf2_per_objfile->info, 0,
+  read_comp_units_from_section (objfile, &dwarf2_per_objfile->info,
+				&dwarf2_per_objfile->abbrev, 0,
 				&n_allocated, &n_comp_units, &all_comp_units);
 
   dwz = dwarf2_get_dwz_file ();
   if (dwz != NULL)
-    read_comp_units_from_section (objfile, &dwz->info, 1,
+    read_comp_units_from_section (objfile, &dwz->info, &dwz->abbrev, 1,
 				  &n_allocated, &n_comp_units,
 				  &all_comp_units);
 

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

* Re: [patch+80] DWARF-5: Fix -fdebug-types-section
  2017-06-29  9:26 [patch+80] DWARF-5: Fix -fdebug-types-section Jan Kratochvil
@ 2017-08-23 23:18 ` Pedro Alves
  2017-08-24  8:32   ` [commit+8.0] " Jan Kratochvil
  0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2017-08-23 23:18 UTC (permalink / raw)
  To: Jan Kratochvil, gdb-patches

On 06/29/2017 10:26 AM, Jan Kratochvil wrote:
> Hi,
> 
> GDB was now accessing as signatured_type memory allocated only by size of
> dwarf2_per_cu_data.
> 
> This is unrelated to the DWARF-5 index.

OK.

Thanks,
Pedro Alves

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

* [commit+8.0] DWARF-5: Fix -fdebug-types-section
  2017-08-23 23:18 ` Pedro Alves
@ 2017-08-24  8:32   ` Jan Kratochvil
  2017-08-24 12:12     ` Joel Brobecker
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kratochvil @ 2017-08-24  8:32 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Thu, 24 Aug 2017 01:18:07 +0200, Pedro Alves wrote:
> On 06/29/2017 10:26 AM, Jan Kratochvil wrote:
> > GDB was now accessing as signatured_type memory allocated only by size of
> > dwarf2_per_cu_data.
> > 
> > This is unrelated to the DWARF-5 index.
> 
> OK.

Checked in:
	f1902523c9b7941775a2c64af89de0f111b8924c master
	06f84c95a2d88d03c1c231bfd436ac9d225d6615 gdb-8.0-branch


Jan

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

* Re: [commit+8.0] DWARF-5: Fix -fdebug-types-section
  2017-08-24  8:32   ` [commit+8.0] " Jan Kratochvil
@ 2017-08-24 12:12     ` Joel Brobecker
  2017-08-24 14:31       ` Jan Kratochvil
  0 siblings, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2017-08-24 12:12 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Pedro Alves, gdb-patches

> On Thu, 24 Aug 2017 01:18:07 +0200, Pedro Alves wrote:
> > On 06/29/2017 10:26 AM, Jan Kratochvil wrote:
> > > GDB was now accessing as signatured_type memory allocated only by size of
> > > dwarf2_per_cu_data.
> > > 
> > > This is unrelated to the DWARF-5 index.
> > 
> > OK.
> 
> Checked in:
> 	f1902523c9b7941775a2c64af89de0f111b8924c master
> 	06f84c95a2d88d03c1c231bfd436ac9d225d6615 gdb-8.0-branch

Hi Jan,

Was there a GDB PR number for this fix? (just making sure this fix
will be documented in the 8.0.1 release)

Thanks,
-- 
Joel

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

* Re: [commit+8.0] DWARF-5: Fix -fdebug-types-section
  2017-08-24 12:12     ` Joel Brobecker
@ 2017-08-24 14:31       ` Jan Kratochvil
  2017-08-24 14:37         ` Joel Brobecker
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kratochvil @ 2017-08-24 14:31 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: Pedro Alves, gdb-patches

On Thu, 24 Aug 2017 14:12:33 +0200, Joel Brobecker wrote:
> Was there a GDB PR number for this fix? (just making sure this fix
> will be documented in the 8.0.1 release)

Sorry about that, filed one now:
	Assertion on debuggee built with -gdwarf-5 -fdebug-types-section
	https://sourceware.org/bugzilla/show_bug.cgi?id=22002


Jan

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

* Re: [commit+8.0] DWARF-5: Fix -fdebug-types-section
  2017-08-24 14:31       ` Jan Kratochvil
@ 2017-08-24 14:37         ` Joel Brobecker
  0 siblings, 0 replies; 6+ messages in thread
From: Joel Brobecker @ 2017-08-24 14:37 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: Pedro Alves, gdb-patches

> Sorry about that, filed one now:
> 	Assertion on debuggee built with -gdwarf-5 -fdebug-types-section
> 	https://sourceware.org/bugzilla/show_bug.cgi?id=22002

Perfect, thanks!

-- 
Joel

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

end of thread, other threads:[~2017-08-24 14:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29  9:26 [patch+80] DWARF-5: Fix -fdebug-types-section Jan Kratochvil
2017-08-23 23:18 ` Pedro Alves
2017-08-24  8:32   ` [commit+8.0] " Jan Kratochvil
2017-08-24 12:12     ` Joel Brobecker
2017-08-24 14:31       ` Jan Kratochvil
2017-08-24 14:37         ` Joel Brobecker

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).