[2/4] Minor cleanup to addrmap_index_data::previous_valid

Message ID 20210529135443.1446279-3-tom@tromey.com
State New
Headers show
Series
  • Some small debug index writer cleanups
Related show

Commit Message

Tom Tromey May 29, 2021, 1:54 p.m.
This changes addrmap_index_data::previous_valid to a bool, and
initializes it inline.

2021-05-28  Tom Tromey  <tom@tromey.com>

	* dwarf2/index-write.c (struct addrmap_index_data)
	<previous_valid>: Now bool.  Initialize.
	(add_address_entry_worker): Update.
	(write_address_map): Update.
---
 gdb/ChangeLog            |  7 +++++++
 gdb/dwarf2/index-write.c | 12 +++---------
 2 files changed, 10 insertions(+), 9 deletions(-)

-- 
2.26.3

Comments

Tom de Vries via Gdb-patches June 13, 2021, 4:48 p.m. | #1
Hi

On Sat, May 29, 2021 at 07:54:41AM -0600, Tom Tromey wrote:
> This changes addrmap_index_data::previous_valid to a bool, and

> initializes it inline.

> 

> 2021-05-28  Tom Tromey  <tom@tromey.com>

> 

> 	* dwarf2/index-write.c (struct addrmap_index_data)

> 	<previous_valid>: Now bool.  Initialize.

> 	(add_address_entry_worker): Update.

> 	(write_address_map): Update.

> ---

>  gdb/ChangeLog            |  7 +++++++

>  gdb/dwarf2/index-write.c | 12 +++---------

>  2 files changed, 10 insertions(+), 9 deletions(-)

> 

> diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c

> index ffc49e8ba82..656742f2e0a 100644

> --- a/gdb/dwarf2/index-write.c

> +++ b/gdb/dwarf2/index-write.c

> @@ -422,7 +422,7 @@ struct addrmap_index_data

>    /* Non-zero if the previous_* fields are valid.

>       We can't write an entry until we see the next entry (since it is only then

>       that we know the end of the entry).  */


The comment could also change from “Non-zero” to “true” to reflect the
type change, or even “Indicates if the previous_* fields are valid”.

Lancelot.

> -  int previous_valid;

> +  bool previous_valid = false;

>    /* Index of the CU in the table of all CUs in the index file.  */

>    unsigned int previous_cu_index;

>    /* Start address of the CU.  */

> @@ -459,10 +459,10 @@ add_address_entry_worker (void *datap, CORE_ADDR start_addr, void *obj)

>        const auto it = data->cu_index_htab.find (pst);

>        gdb_assert (it != data->cu_index_htab.cend ());

>        data->previous_cu_index = it->second;

> -      data->previous_valid = 1;

> +      data->previous_valid = true;

>      }

>    else

> -    data->previous_valid = 0;

> +    data->previous_valid = false;

>  

>    return 0;

>  }

> @@ -477,12 +477,6 @@ write_address_map (dwarf2_per_bfd *per_bfd, data_buf &addr_vec,

>  {

>    struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab);

>  

> -  /* When writing the address table, we have to cope with the fact that

> -     the addrmap iterator only provides the start of a region; we have to

> -     wait until the next invocation to get the start of the next region.  */

> -

> -  addrmap_index_data.previous_valid = 0;

> -

>    addrmap_foreach (per_bfd->partial_symtabs->psymtabs_addrmap,

>  		   add_address_entry_worker, &addrmap_index_data);

>  

> -- 

> 2.26.3

>
Tom Tromey June 14, 2021, 8:14 p.m. | #2
>>>>> "Lancelot" == Lancelot SIX <lsix@lancelotsix.com> writes:


Lancelot> The comment could also change from “Non-zero” to “true” to reflect the
Lancelot> type change, or even “Indicates if the previous_* fields are valid”.

Thanks, I changed it to use the "true" formulation.

Tom

Patch

diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index ffc49e8ba82..656742f2e0a 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -422,7 +422,7 @@  struct addrmap_index_data
   /* Non-zero if the previous_* fields are valid.
      We can't write an entry until we see the next entry (since it is only then
      that we know the end of the entry).  */
-  int previous_valid;
+  bool previous_valid = false;
   /* Index of the CU in the table of all CUs in the index file.  */
   unsigned int previous_cu_index;
   /* Start address of the CU.  */
@@ -459,10 +459,10 @@  add_address_entry_worker (void *datap, CORE_ADDR start_addr, void *obj)
       const auto it = data->cu_index_htab.find (pst);
       gdb_assert (it != data->cu_index_htab.cend ());
       data->previous_cu_index = it->second;
-      data->previous_valid = 1;
+      data->previous_valid = true;
     }
   else
-    data->previous_valid = 0;
+    data->previous_valid = false;
 
   return 0;
 }
@@ -477,12 +477,6 @@  write_address_map (dwarf2_per_bfd *per_bfd, data_buf &addr_vec,
 {
   struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab);
 
-  /* When writing the address table, we have to cope with the fact that
-     the addrmap iterator only provides the start of a region; we have to
-     wait until the next invocation to get the start of the next region.  */
-
-  addrmap_index_data.previous_valid = 0;
-
   addrmap_foreach (per_bfd->partial_symtabs->psymtabs_addrmap,
 		   add_address_entry_worker, &addrmap_index_data);