Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFC: really free pending_blocks, v2
@ 2012-11-29 15:25 Tom Tromey
  2012-11-29 16:09 ` Pedro Alves
  2012-12-10 17:06 ` Tom Tromey
  0 siblings, 2 replies; 4+ messages in thread
From: Tom Tromey @ 2012-11-29 15:25 UTC (permalink / raw)
  To: gdb-patches

This is a refresh of the patch I erroneously sent to the main gdb list.

This one uses a local obstack as suggested by John Gilmore.

Built and regtested on x86-64 Fedora 16.

Tom

2012-11-28  Tom Tromey  <tromey@redhat.com>

	* buildsym.c (struct pending_block): Move from buildsym.h.
	(pending_blocks): Likewise; now static.
	(pending_block_obstack): New global.
	(free_pending_blocks): Free blocks.
	(record_pending_block): Use pending_block_obstack.
	* buildsym.h (struct pending_block): Move definition to
	buildsym.c.
	(pending_blocks): Don't declare.

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 8f2e732..c3e8516 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -83,6 +83,25 @@ static struct obstack pending_addrmap_obstack;
    the end, then we just toss the addrmap.  */
 static int pending_addrmap_interesting;
 
+/* An obstack used for allocating pending blocks.  */
+
+static struct obstack pending_block_obstack;
+
+/* List of blocks already made (lexical contexts already closed).
+   This is used at the end to make the blockvector.  */
+
+struct pending_block
+  {
+    struct pending_block *next;
+    struct block *block;
+  };
+
+/* Pointer to the head of a linked list of symbol blocks which have
+   already been finalized (lexical contexts already closed) and which
+   are just waiting to be built into a blockvector when finalizing the
+   associated symtab.  */
+
+static struct pending_block *pending_blocks;
 \f
 static int compare_line_numbers (const void *ln1p, const void *ln2p);
 
@@ -205,9 +224,11 @@ really_free_pendings (void *dummy)
 void
 free_pending_blocks (void)
 {
-  /* The links are made in the objfile_obstack, so we only need to
-     reset PENDING_BLOCKS.  */
-  pending_blocks = NULL;
+  if (pending_blocks != NULL)
+    {
+      obstack_free (&pending_block_obstack, NULL);
+      pending_blocks = NULL;
+    }
 }
 
 /* Take one of the lists of symbols and make a block from it.  Keep
@@ -418,8 +439,11 @@ record_pending_block (struct objfile *objfile, struct block *block,
 {
   struct pending_block *pblock;
 
+  if (pending_blocks == NULL)
+    obstack_init (&pending_block_obstack);
+
   pblock = (struct pending_block *)
-    obstack_alloc (&objfile->objfile_obstack, sizeof (struct pending_block));
+    obstack_alloc (&pending_block_obstack, sizeof (struct pending_block));
   pblock->block = block;
   if (opblock)
     {
diff --git a/gdb/buildsym.h b/gdb/buildsym.h
index 0db96bf..b7d4a76 100644
--- a/gdb/buildsym.h
+++ b/gdb/buildsym.h
@@ -37,6 +37,7 @@ struct addrmap;
    this technique.  */
 
 struct block;
+struct pending_block;
 
 #ifndef EXTERN
 #define	EXTERN extern
@@ -177,21 +178,6 @@ EXTERN int context_stack_size;
 
 EXTERN int within_function;
 
-/* List of blocks already made (lexical contexts already closed).
-   This is used at the end to make the blockvector.  */
-
-struct pending_block
-  {
-    struct pending_block *next;
-    struct block *block;
-  };
-
-/* Pointer to the head of a linked list of symbol blocks which have
-   already been finalized (lexical contexts already closed) and which
-   are just waiting to be built into a blockvector when finalizing the
-   associated symtab.  */
-
-EXTERN struct pending_block *pending_blocks;
 \f
 
 struct subfile_stack


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

* Re: RFC: really free pending_blocks, v2
  2012-11-29 15:25 RFC: really free pending_blocks, v2 Tom Tromey
@ 2012-11-29 16:09 ` Pedro Alves
  2012-11-29 16:18   ` Tom Tromey
  2012-12-10 17:06 ` Tom Tromey
  1 sibling, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2012-11-29 16:09 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 11/29/2012 03:25 PM, Tom Tromey wrote:
>  
> +/* An obstack used for allocating pending blocks.  */
> +
> +static struct obstack pending_block_obstack;
> +
> +/* List of blocks already made (lexical contexts already closed).
> +   This is used at the end to make the blockvector.  */
> +
> +struct pending_block
> +  {
> +    struct pending_block *next;
> +    struct block *block;
> +  };
> +
> +/* Pointer to the head of a linked list of symbol blocks which have
> +   already been finalized (lexical contexts already closed) and which
> +   are just waiting to be built into a blockvector when finalizing the
> +   associated symtab.  */
> +
> +static struct pending_block *pending_blocks;

Do we take care of always clearing this before starting a new symtab?

What I'm worried about is throwing an error during debug info
reading leading to a stale pending_blocks list that gets later added
to by mistake, the next time we start another read.

-- 
Pedro Alves


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

* Re: RFC: really free pending_blocks, v2
  2012-11-29 16:09 ` Pedro Alves
@ 2012-11-29 16:18   ` Tom Tromey
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2012-11-29 16:18 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

>> +static struct pending_block *pending_blocks;

Pedro> Do we take care of always clearing this before starting a new symtab?

If we don't, then I think it is an existing bug, not affected by this
patch.

But, we do take care.  The various symbol readers install
really_free_pendings as a cleanup.

buildsym in general is a mess, mostly because it works using a lot of
globals.  It's never been actively bad enough to fix, though -- it came
close with the dwz work, but still managed to dodge a big cleanup.

Tom


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

* Re: RFC: really free pending_blocks, v2
  2012-11-29 15:25 RFC: really free pending_blocks, v2 Tom Tromey
  2012-11-29 16:09 ` Pedro Alves
@ 2012-12-10 17:06 ` Tom Tromey
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2012-12-10 17:06 UTC (permalink / raw)
  To: gdb-patches

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

Tom> This is a refresh of the patch I erroneously sent to the main gdb list.

I'm checking this in now.

Tom


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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-29 15:25 RFC: really free pending_blocks, v2 Tom Tromey
2012-11-29 16:09 ` Pedro Alves
2012-11-29 16:18   ` Tom Tromey
2012-12-10 17:06 ` Tom Tromey

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