Re: [RFA 03/42] Add assert in prepare_for_building

Simon Marchi
2018-07-07T14:06:16Z

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