[RFA,03/42] Add assert in prepare_for_building

Message ID 20180523045851.11660-4-tom@tromey.com
State New
Headers show
Series
  • Remove globals from buildsym
Related show

Commit Message

Tom Tromey May 23, 2018, 4:58 a.m.
This adds an assertion in prepare_for_building.  This was useful for
verifying whether some subsequent changes were valid.

gdb/ChangeLog
2018-05-22  Tom Tromey  <tom@tromey.com>

	* buildsym.c (prepare_for_building): Add assert.
---
 gdb/ChangeLog  | 4 ++++
 gdb/buildsym.c | 1 +
 2 files changed, 5 insertions(+)

-- 
2.13.6

Comments

Simon Marchi July 7, 2018, 2:06 p.m. | #1
On 2018-05-23 12:58 AM, Tom Tromey wrote:
> This adds an assertion in prepare_for_building.  This was useful for

> verifying whether some subsequent changes were valid.

> 

> gdb/ChangeLog

> 2018-05-22  Tom Tromey  <tom@tromey.com>

> 

> 	* buildsym.c (prepare_for_building): Add assert.

> ---

>  gdb/ChangeLog  | 4 ++++

>  gdb/buildsym.c | 1 +

>  2 files changed, 5 insertions(+)

> 

> diff --git a/gdb/buildsym.c b/gdb/buildsym.c

> index b747a082b5..9e0c39a4a4 100644

> --- a/gdb/buildsym.c

> +++ b/gdb/buildsym.c

> @@ -1025,6 +1025,7 @@ prepare_for_building (const char *name, CORE_ADDR start_addr)

>    gdb_assert (pending_macros == NULL);

>    gdb_assert (pending_addrmap == NULL);

>    gdb_assert (current_subfile == NULL);

> +  gdb_assert (buildsym_compunit == nullptr);

>  }

>  

>  /* Start a new symtab for a new source file in OBJFILE.  Called, for example,

> 


[I failed to reply-all, so I am resending this]

The code paths in buildsym are not very obvious, so it's hard to
verify that this will always be true, but on the surface it makes sense.
Given that it survived your testing, it LGTM.

Simon

Patch

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index b747a082b5..9e0c39a4a4 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1025,6 +1025,7 @@  prepare_for_building (const char *name, CORE_ADDR start_addr)
   gdb_assert (pending_macros == NULL);
   gdb_assert (pending_addrmap == NULL);
   gdb_assert (current_subfile == NULL);
+  gdb_assert (buildsym_compunit == nullptr);
 }
 
 /* Start a new symtab for a new source file in OBJFILE.  Called, for example,