From: "Agovic, Sanimir" <sanimir.agovic@intel.com>
To: "Tom Tromey (tromey@redhat.com)" <tromey@redhat.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH 02/10] type: add c99 variable length array support
Date: Tue, 19 Nov 2013 15:31:00 -0000 [thread overview]
Message-ID: <0377C58828D86C4588AEEC42FC3B85A7176B7861@IRSMSX105.ger.corp.intel.com> (raw)
In-Reply-To: <87eh6sujea.fsf@fleche.redhat.com>
Thanks for your review.
> Sanimir> + switch (ctx->location)
> Sanimir> + {
> Sanimir> + case DWARF_VALUE_REGISTER:
> Sanimir> + *valp = dwarf_expr_read_reg (&baton, dwarf_expr_fetch_address (ctx, 0));
> Sanimir> + break;
> Sanimir> + case DWARF_VALUE_MEMORY:
> Sanimir> + *valp = dwarf_expr_fetch_address (ctx, 0);
> Sanimir> + break;
> Sanimir> + }
>
> It seems that something should be done for other DWARF_VALUE_* results
> here.
>
I will try, please have a closer look at this hunk in the upcoming v2.
> Sanimir> +struct type *
> Sanimir> +resolve_dynamic_type (struct type *type, CORE_ADDR address)
> Sanimir> +{
> [...]
> Sanimir> + if (!TYPE_OBJFILE_OWNED (ty))
> Sanimir> + return type;
>
> This seems like a bit of a wart, though I am not sure whether the
> situation can actually arise.
>
>
> One thing I didn't see in here is error-checking of whether resolution
> makes sense.
>
> E.g., suppose I print the value of a pointer-to-VLA. Then I move to
> some other frame and "print *$".
>
1| void foo (size_t n) {
2| int vla[n];
3| }
(gdb) print &vla
$1 = (int (*)[42]) 0xffffffffffff
(gdb) up
(gdb) print *$
$2 = {0 <repeats 42 times>}
(gdb) down
(gdb) print *$
$3 = {0 <repeats 42 times>}
> In this situation the bounds have not been resolved -- but applying the
> DWARF expression in the currently-selected frame will silently do the
> wrong thing.
>
The bounds will be resolved in this case and therefore it is save to change
the frame+re-evaluate. If you have a different example in mind please tell
me and I see how to deal with it.
> I wonder if this series also needs to handle DW_AT_count.
> Maybe no compiler generates it.
>
I will add a separate patch which implements DW_AT_count, I could not test
it as no compiler emits this attribute so far.
Below you will find the trivial reviews.
-Sanimir
> -----Original Message-----
> From: Tom Tromey [mailto:tromey@redhat.com]
> Sent: Thursday, November 07, 2013 08:00 PM
> To: Agovic, Sanimir
> Cc: gdb-patches@sourceware.org
> Subject: Re: [PATCH 02/10] type: add c99 variable length array support
>
> >>>>> "Sanimir" == Sanimir Agovic <sanimir.agovic@intel.com> writes:
>
> Sanimir> The dwarf standard allow certain attributes to be expressed as
> Sanimir> dwarf expressions rather than constants. For instance
> Sanimir> upper-/lowerbound attributes. In case of a c99 variable length
> Sanimir> array the upperbound is a dynamic attribute.
>
>
> Sanimir> +int
> Sanimir> +dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
> Sanimir> + CORE_ADDR addr, CORE_ADDR *valp)
>
> Need an introductory comment. It can just say "See dwarf2loc.h.", since
> you put the real comment there.
>
Done.
> Sanimir> +static struct dwarf2_locexpr_baton* attr_to_locexprbaton
> Sanimir> +(const struct attribute *, struct dwarf2_cu *);
> Sanimir> +
> Sanimir> +static struct dwarf2_locexpr_baton* attr_to_locexprbaton_1
> Sanimir> +(const struct attribute *, struct dwarf2_cu *, const gdb_byte *additional_data,
> Sanimir> + int extra_size);
> Sanimir> +
> Sanimir> +static int attr_to_dwarf2_prop
> Sanimir> +(struct die_info *, const struct attribute *, struct dwarf2_cu *,
> Sanimir> + struct dwarf2_prop *);
>
> In cases like this we usually indent the subsequent lines a bit, like:
>
> static int attr_to_dwarf2_prop
> (struct die_info *, const struct attribute *, struct dwarf2_cu *,
> struct dwarf2_prop *);
>
> However in this case I think it may be preferable to rearrange the
> functions so that forward declarations are not needed. What do you
> think?
>
Done. Moved functions and dropped forward declaration.
> Sanimir> +static struct dwarf2_locexpr_baton*
> Sanimir> +attr_to_locexprbaton (const struct attribute *attribute, struct dwarf2_cu *cu)
> Sanimir> +{
> Sanimir> + return attr_to_locexprbaton_1 (attribute, cu, NULL, 0);
> Sanimir> +}
>
> If there is just a single caller (there is in this patch, but I haven't
> read all the patches yet), I would remove this function and just update
> the caller.
>
Done. Folded function attr_to_locexprbaton/_1 into attr_to_locexprbaton.
> Sanimir> +static struct dwarf2_locexpr_baton*
> Sanimir> +attr_to_locexprbaton_1 (const struct attribute *attribute, struct dwarf2_cu *cu,
> Sanimir> + const gdb_byte *additional_data, int extra_size)
>
> Needs an introductory comment.
>
Done.
> Sanimir> + /* Copy the data pointer as the blocks lifetime is
>
> Missing apostrophe: "block's".
>
Done.
> Sanimir> + gdb_assert(baton->data != NULL);
>
> Space before open paren.
>
Done.
> Sanimir> +/* Parse dwarf attribute if it's a block, reference or constant and put the
> Sanimir> + resulting value of the attribute into struct dwarf2_prop. */
> Sanimir> +
> Sanimir> +static int
> Sanimir> +attr_to_dwarf2_prop (struct die_info *die, const struct attribute *attr,
> Sanimir> + struct dwarf2_cu *cu,
> Sanimir> + struct dwarf2_prop *prop)
>
> I think it would be good if the introductory comment describe the return
> value.
>
Done.
> Sanimir> + else if (attr_form_is_ref (attr))
> Sanimir> + {
> Sanimir> + struct dwarf2_cu *target_cu = cu;
> Sanimir> + struct die_info *target_die;
> Sanimir> + struct attribute *target_attr;
> Sanimir> + const gdb_byte append_ops[] = { DW_OP_deref };
> Sanimir> +
> Sanimir> + target_die = follow_die_ref (die, attr, &target_cu);
> Sanimir> + target_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
> Sanimir> +
> Sanimir> + prop->data.locexpr =
> Sanimir> + attr_to_locexprbaton_1 (target_attr, cu, append_ops,
> Sanimir> + sizeof (append_ops) / sizeof (append_ops[0]));
> Sanimir> + prop->kind = DWARF_LOCEXPR;
> Sanimir> + gdb_assert (prop->data.locexpr != NULL);
>
> I don't understand this hunk. Could you say why it is needed?
>
DW_AT_upper_bound may reference a die e.g. artificial variable, in this case we
need to read DW_AT_location of the target die. Some compilers emit this form to
implement vla.
> Sanimir> + dwarf2_invalid_attrib_class_complaint(dwarf_form_name (attr->form),
> Sanimir> + dwarf2_name (die, cu));
>
> Missing space before a paren.
>
Done.
> Sanimir> +static int
> Sanimir> +has_static_range (const struct range_bounds *bounds)
> Sanimir> +{
> Sanimir> + return bounds->low.kind == DWARF_CONST
> Sanimir> + && bounds->high.kind == DWARF_CONST;
> Sanimir> +}
>
> THis needs parens around the argument to "return" and then an
> indentation fix on the second line.
>
Done.
> Sanimir> +/* Calculates the size of a type given the upper and lower bound of a dynamic
> Sanimir> + type. */
> Sanimir> +
> Sanimir> +static ULONGEST
> Sanimir> +get_type_length (const struct type *type)
> Sanimir> +{
> Sanimir> + const struct type *range_type, *target_type;
> Sanimir> + ULONGEST len = TYPE_LENGTH (type);
> Sanimir> + LONGEST low_bound, high_bound;
> Sanimir> +
> Sanimir> + if (TYPE_CODE (type) != TYPE_CODE_ARRAY
> Sanimir> + && TYPE_CODE (type) != TYPE_CODE_STRING)
> Sanimir> + return len;
> Sanimir> +
> Sanimir> + range_type = TYPE_INDEX_TYPE (type);
> Sanimir> +
> Sanimir> + if (!has_static_range (TYPE_RANGE_DATA (range_type)))
> Sanimir> + return len;
>
> This seems like it doesn't follow what the introductory comment says it
> does.
>
Fixed document.
> Sanimir> +
> Sanimir> +static void
> Sanimir> +resolve_dynamic_bounds (struct type *type, CORE_ADDR address)
>
> Introductory comment.
>
Done.
> Sanimir> + do {
> Sanimir> + struct type *range_type = TYPE_INDEX_TYPE (ary_dim);
>
> It's hard to know but perhaps a check_typedef is required here.
>
> Sanimir> + ary_dim = TYPE_TARGET_TYPE (ary_dim);
>
> Here too.
>
Done.
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052
next prev parent reply other threads:[~2013-11-19 15:14 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-21 14:40 C99 " Sanimir Agovic
2013-10-21 14:40 ` [PATCH 07/10] test: evaluate pointers to C99 vla correctly Sanimir Agovic
2013-11-07 20:57 ` Tom Tromey
2013-11-08 6:37 ` Tom Tromey
2013-11-07 21:14 ` Tom Tromey
2013-10-21 14:40 ` [PATCH 05/10] vla: allow side effects for sizeof argument Sanimir Agovic
2013-10-24 19:55 ` Tom Tromey
2013-10-25 8:13 ` Agovic, Sanimir
2013-10-28 21:00 ` Tom Tromey
2013-11-18 9:37 ` Agovic, Sanimir
2013-11-18 15:56 ` Tom Tromey
2013-11-20 12:18 ` Agovic, Sanimir
2013-11-19 17:08 ` Pedro Alves
2013-11-20 12:47 ` Agovic, Sanimir
2013-11-20 13:24 ` Pedro Alves
2013-10-21 14:40 ` [PATCH 02/10] type: add c99 variable length array support Sanimir Agovic
2013-11-07 19:02 ` Tom Tromey
2013-11-19 15:31 ` Agovic, Sanimir [this message]
2013-11-22 20:00 ` Tom Tromey
2013-11-27 17:08 ` Agovic, Sanimir
[not found] ` <0377C58828D86C4588AEEC42FC3B85A7176BC3DE@IRSMSX105.ger.corp.intel.com>
2013-11-27 17:15 ` Agovic, Sanimir
2013-11-07 19:10 ` Tom Tromey
2013-10-21 14:40 ` [PATCH 03/10] vla: enable sizeof operator to work with variable length arrays Sanimir Agovic
2013-11-07 19:10 ` Tom Tromey
2013-10-21 14:40 ` [PATCH 09/10] test: basic c99 vla tests Sanimir Agovic
2013-11-07 21:23 ` Tom Tromey
2013-10-21 14:40 ` [PATCH 10/10] test: add mi vla test Sanimir Agovic
2013-11-07 21:31 ` Tom Tromey
2013-10-21 14:40 ` [PATCH 06/10] vla: update type from newly created value Sanimir Agovic
2013-11-07 20:56 ` Tom Tromey
2013-11-20 7:56 ` Agovic, Sanimir
2013-11-20 11:02 ` Pedro Alves
2013-11-20 13:08 ` Agovic, Sanimir
2013-11-21 18:50 ` Pedro Alves
2013-11-23 19:27 ` Doug Evans
2013-10-21 14:40 ` [PATCH 01/10] vla: introduce new bound type abstraction adapt uses Sanimir Agovic
2013-11-07 19:00 ` Tom Tromey
2013-11-18 11:15 ` Agovic, Sanimir
2013-10-21 14:40 ` [PATCH 08/10] test: multi-dimensional c99 vla Sanimir Agovic
2013-11-07 21:19 ` Tom Tromey
2013-10-21 14:40 ` [PATCH 04/10] vla: enable sizeof operator for indirection Sanimir Agovic
2013-11-07 19:57 ` Tom Tromey
2013-11-21 18:52 ` C99 variable length array support Pedro Alves
2013-11-21 19:01 ` Pedro Alves
2013-11-21 19:10 ` Pedro Alves
2013-11-22 10:53 ` Agovic, Sanimir
2013-11-22 12:35 ` Pedro Alves
2013-11-22 17:06 ` Agovic, Sanimir
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=0377C58828D86C4588AEEC42FC3B85A7176B7861@IRSMSX105.ger.corp.intel.com \
--to=sanimir.agovic@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).