Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Fawzi Mohamed <fawzi.mohamed@nokia.com>
Cc: gdb-patches@sourceware.org,
	ext Tristan Gingold <gingold@adacore.com>,
	Andr? P?nitz <andre.poenitz@nokia.com>
Subject: Re: [PATCH,gdb]: ensures that cie ptr of an fda is a cie
Date: Mon, 04 Jul 2011 18:52:00 -0000	[thread overview]
Message-ID: <20110704184111.GP2407@adacore.com> (raw)
In-Reply-To: <F1900C4A-1C06-4F4B-9048-16C9A3F03765@nokia.com>

> This increases the robustness of gdb, so I think it is worthwhile to add.

Indeed.

> 2011-07-04 Fawzi Mohamed <fawzi.mohamed@nokia.com>
> 
> 	* dwarf2-frame.c (decode_frame_entry, decode_frame_entry_1): ensure
> 	that cie pointer really points to a cie 

I'm not a specialist of this area of the code, so I can't approve.
However, I'm noticing some style issues (style is project-specific).
Also, please make sure to use the '-p' switch when creating the diff,
so that we can get a little more context for each hunk (see man diff).

> +enum eh_frame_type {
> +    eh_cie_type_id = 1,
> +    eh_fde_type_id = 2,
> +    eh_cie_or_fde_type_id = 3
> +};

The open curly brace should be on the next line, and our indentation
level is 2 characters, thus:

    enum eh_frame_type
    {
      eh_cie_type_id = 1,
      eh_fde_type_id = 2,
      eh_cie_or_fde_type_id = 3
    };

Also, we try to document every type and every function that we add
in GDB. And for types like this, it is often advantageous to also
document each element (not sure in this case). You can have a look
at struct frame_id in frame.h for an example of how we document
our types.

>  static gdb_byte *decode_frame_entry (struct comp_unit *unit, gdb_byte *start,
>  				     int eh_frame_p,
>                                       struct dwarf2_cie_table *cie_table,
> -                                     struct dwarf2_fde_table *fde_table);
> +                                     struct dwarf2_fde_table *fde_table,
> +                                     enum eh_frame_type entry_type);

The documentation of these function need to be augmented in order
to describe what this extra parameter does.  Same for all the other
functions that you have modified.

> +      gdb_assert ((entry_type & eh_cie_type_id)!=0);

Style: spaces around the != operator.  Also, please provide a comment
explaining why entry_type & eh_cie_type_id can never be zero.  It might
be obvious if already specified in the function documention, but might
not be so obvious. In fact, what is the purpose of this assertion?
It looks like you're validating the value of entry_type to make sure
that it is either a eh_cie_type_id or a eh_cie_or_fde_type_id.
This leads me to believe that the values inside eh_frame_type
are meant to be bit flags. This would be much clearer with documentation
and by using the following syntax:

    enum eh_frame_type
    {
      eh_cie_type_id = 1 << 0,
      eh_fde_type_id = 1 << 1,
      eh_cie_or_fde_type_id = eh_cie_type_id + eh_fde_type_id
    };

(I might also add an `unknown' value that's equal to zero, just
to name that value).

> +      gdb_assert ((entry_type & eh_fde_type_id)!=0);
> +

Same comment.

-- 
Joel


  reply	other threads:[~2011-07-04 18:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-04 18:19 Fawzi Mohamed
2011-07-04 18:52 ` Joel Brobecker [this message]
2011-07-05 10:44   ` [PATCH,gdb, Update1]: " Fawzi Mohamed
2011-07-05 15:17     ` Joel Brobecker
2011-07-05 16:57       ` [PATCH,gdb, Update2]: " Fawzi Mohamed
2011-07-05 16:26 ` [PATCH,gdb]: " Tom Tromey
2011-07-06 14:45   ` [PATCH,gdb,Update3]: " Fawzi Mohamed
2011-07-06 18:16     ` Jan Kratochvil
2011-07-07 17:17       ` [PATCH,gdb,Update4]: " Fawzi Mohamed
2011-07-07 23:37         ` Tom Tromey
2011-07-11 17:19           ` [PATCH,gdb,Update6]: " Fawzi Mohamed
2011-07-11 21:52             ` Tom Tromey
2011-07-12 11:15               ` [PATCH,gdb,Update7]: " Fawzi Mohamed
2011-07-12 20:01                 ` Tom Tromey
2011-07-15 15:34                   ` FYI " Fawzi Mohamed
2011-07-07 18:48       ` [PATCH,gdb,Update5]: " Fawzi Mohamed
2011-07-07 19:38         ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110704184111.GP2407@adacore.com \
    --to=brobecker@adacore.com \
    --cc=andre.poenitz@nokia.com \
    --cc=fawzi.mohamed@nokia.com \
    --cc=gdb-patches@sourceware.org \
    --cc=gingold@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox