public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix the unitialized bit in a struct field corresponding to enumb
@ 2017-02-11 15:24 Maxim Akhmedov
  2017-02-15 14:07 ` Luis Machado
  0 siblings, 1 reply; 2+ messages in thread
From: Maxim Akhmedov @ 2017-02-11 15:24 UTC (permalink / raw)
  To: gdb-patches

Without setting this bit, even for a small enumeration types their member fields contain random 0/1's as the values of "artificial". When comparing two instances of exactly the same
enum type, the result depends on whether their members contain the same garbage as the value of artificial.

gdb/ChangeLog:
2017-02-11  Maxim Akhmedov  <max42@yandex-team.ru>

	* dwarf2read.c: fix uninitialized bit in a struct field corresponding
	to enumeration member.

---
 gdb/dwarf2read.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 774ed73075..676da14c58 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -13652,6 +13652,7 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
                  FIELD_TYPE (fields[num_fields]) = NULL;
                  SET_FIELD_ENUMVAL (fields[num_fields], SYMBOL_VALUE (sym));
                  FIELD_BITSIZE (fields[num_fields]) = 0;
+                 FIELD_ARTIFICIAL (fields[num_fields]) = 0;
 
                  num_fields++;
                }
-- 
2.11.0

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

* Re: [PATCH 1/2] Fix the unitialized bit in a struct field corresponding to enumb
  2017-02-11 15:24 [PATCH 1/2] Fix the unitialized bit in a struct field corresponding to enumb Maxim Akhmedov
@ 2017-02-15 14:07 ` Luis Machado
  0 siblings, 0 replies; 2+ messages in thread
From: Luis Machado @ 2017-02-15 14:07 UTC (permalink / raw)
  To: Maxim Akhmedov, gdb-patches

On 02/11/2017 09:23 AM, Maxim Akhmedov wrote:
> Without setting this bit, even for a small enumeration types their member fields contain random 0/1's as the values of "artificial". When comparing two instances of exactly the same
> enum type, the result depends on whether their members contain the same garbage as the value of artificial.
>
> gdb/ChangeLog:
> 2017-02-11  Maxim Akhmedov  <max42@yandex-team.ru>
>
> 	* dwarf2read.c: fix uninitialized bit in a struct field corresponding
> 	to enumeration member.
>
> ---
>  gdb/dwarf2read.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
> index 774ed73075..676da14c58 100644
> --- a/gdb/dwarf2read.c
> +++ b/gdb/dwarf2read.c
> @@ -13652,6 +13652,7 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
>                   FIELD_TYPE (fields[num_fields]) = NULL;
>                   SET_FIELD_ENUMVAL (fields[num_fields], SYMBOL_VALUE (sym));
>                   FIELD_BITSIZE (fields[num_fields]) = 0;
> +                 FIELD_ARTIFICIAL (fields[num_fields]) = 0;
>
>                   num_fields++;
>                 }

This looks OK to me, though it would've been nice to zero out the entire 
field struct and not just individual bits of it.

There are basically two ways we're doing this:

- XNEW and then memset to 0.
- XCNEW, which already handles zeroing things out.

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

end of thread, other threads:[~2017-02-15 14:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-11 15:24 [PATCH 1/2] Fix the unitialized bit in a struct field corresponding to enumb Maxim Akhmedov
2017-02-15 14:07 ` Luis Machado

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).