[RFA,06/42] Move have_line_numbers to buildsym_compunit

Message ID 20180523045851.11660-7-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 moves the global have_line_numbers into buildsym_compunit.

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

	* buildsym.c (struct buildsym_compunit) <m_have_line_numbers>: New
	member.
	(have_line_numbers): Remove.
	(record_line, prepare_for_building, end_symtab_get_static_block)
	(augment_type_symtab): Update.
---
 gdb/ChangeLog  |  8 ++++++++
 gdb/buildsym.c | 16 +++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)

-- 
2.13.6

Comments

Keith Seitz July 5, 2018, 7:01 p.m. | #1
Hi,

I have just one trivial request:

On 05/22/2018 09:58 PM, Tom Tromey wrote:
> diff --git a/gdb/buildsym.c b/gdb/buildsym.c

> index c3961254da..d0dfa4cd02 100644

> --- a/gdb/buildsym.c

> +++ b/gdb/buildsym.c

> @@ -1288,7 +1286,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)

>        && pending_blocks == NULL

>        && file_symbols == NULL

>        && global_symbols == NULL

> -      && have_line_numbers == 0

> +      && buildsym_compunit->m_have_line_numbers == 0

>        && buildsym_compunit->m_pending_macros == NULL

>        && global_using_directives == NULL)

>      {


Since m_have_line_numbers was declared bool, I prefer (and I think most do?) that the comparison use `false' instead.

Keith
Simon Marchi July 8, 2018, 4:05 p.m. | #2
On 2018-07-05 03:01 PM, Keith Seitz wrote:
> Hi,

> 

> I have just one trivial request:

> 

> On 05/22/2018 09:58 PM, Tom Tromey wrote:

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

>> index c3961254da..d0dfa4cd02 100644

>> --- a/gdb/buildsym.c

>> +++ b/gdb/buildsym.c

>> @@ -1288,7 +1286,7 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)

>>        && pending_blocks == NULL

>>        && file_symbols == NULL

>>        && global_symbols == NULL

>> -      && have_line_numbers == 0

>> +      && buildsym_compunit->m_have_line_numbers == 0

>>        && buildsym_compunit->m_pending_macros == NULL

>>        && global_using_directives == NULL)

>>      {

> 

> Since m_have_line_numbers was declared bool, I prefer (and I think most do?) that the comparison use `false' instead.

> 

> Keith


Right, or even !buildsym_compunit->m_have_line_numbers.  LGTM either way.

Simon
Tom Tromey July 8, 2018, 4:26 p.m. | #3
>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:


>> -      && have_line_numbers == 0

>> +      && buildsym_compunit->m_have_line_numbers == 0


Keith> Since m_have_line_numbers was declared bool, I prefer (and I
Keith> think most do?) that the comparison use `false' instead.

I changed it to just !have_line_numbers.

Tom

Patch

diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index c3961254da..d0dfa4cd02 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -192,6 +192,10 @@  struct buildsym_compunit
   /* The macro table for the compilation unit whose symbols we're
      currently reading.  */
   struct macro_table *m_pending_macros = nullptr;
+
+  /* True if symtab has line number info.  This prevents an otherwise
+     empty symtab from being tossed.  */
+  bool m_have_line_numbers = false;
 };
 
 /* The work-in-progress of the compunit we are building.
@@ -203,11 +207,6 @@  static struct buildsym_compunit *buildsym_compunit;
 
 static struct pending *free_pendings;
 
-/* Non-zero if symtab has line number info.  This prevents an
-   otherwise empty symtab from being tossed.  */
-
-static int have_line_numbers;
-
 /* The mutable address map for the compilation unit whose symbols
    we're currently reading.  The symtabs' shared blockvector will
    point to a fixed copy of this.  */
@@ -934,7 +933,7 @@  record_line (struct subfile *subfile, int line, CORE_ADDR pc)
 	xmalloc (sizeof (struct linetable)
 	   + subfile->line_vector_length * sizeof (struct linetable_entry));
       subfile->line_vector->nitems = 0;
-      have_line_numbers = 1;
+      buildsym_compunit->m_have_line_numbers = true;
     }
 
   if (subfile->line_vector->nitems + 1 >= subfile->line_vector_length)
@@ -1030,7 +1029,6 @@  prepare_for_building (CORE_ADDR start_addr)
   local_symbols = NULL;
   local_using_directives = NULL;
   within_function = 0;
-  have_line_numbers = 0;
 
   context_stack_depth = 0;
 
@@ -1288,7 +1286,7 @@  end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
       && pending_blocks == NULL
       && file_symbols == NULL
       && global_symbols == NULL
-      && have_line_numbers == 0
+      && buildsym_compunit->m_have_line_numbers == 0
       && buildsym_compunit->m_pending_macros == NULL
       && global_using_directives == NULL)
     {
@@ -1595,7 +1593,7 @@  augment_type_symtab (void)
     complaint (&symfile_complaints, _("Blocks in a type symtab"));
   if (buildsym_compunit->m_pending_macros != NULL)
     complaint (&symfile_complaints, _("Macro in a type symtab"));
-  if (have_line_numbers)
+  if (buildsym_compunit->m_have_line_numbers)
     complaint (&symfile_complaints,
 	       _("Line numbers recorded in a type symtab"));