This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 2/6] Introduce `pre_expanded sals'
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Sergio Durigan Junior <sergiodj at redhat dot com>
- Cc: gdb-patches at sourceware dot org, Tom Tromey <tromey at redhat dot com>
- Date: Mon, 11 Apr 2011 23:07:58 +0200
- Subject: Re: [PATCH 2/6] Introduce `pre_expanded sals'
- References: <m3mxk6pvbs.fsf@redhat.com>
On Mon, 04 Apr 2011 05:08:23 +0200, Sergio Durigan Junior wrote:
> static struct symtabs_and_lines
> -addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
> +addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found,
> + int *pre_expanded)
> {
> char *s;
> int marker_spec, not_found;
> struct symtabs_and_lines sals = {0};
> struct gdb_exception e;
> + int my_pre_expanded = 0;
Such as proposal:
if (pre_expanded == NULL)
pre_expanded = &my_pre_expanded;
and use only `pre_expanded' in the code so that one does not forget to update
both. (+Probably some *pre_expanded preinitialization.)
[...]
> + my_pre_expanded = canonical.pre_expanded;
> + if (pre_expanded)
> + *pre_expanded = my_pre_expanded;
> + }
> }
> if (e.reason < 0)
> {
> @@ -11010,7 +11041,7 @@ addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
>
> if (!not_found)
> {
> - gdb_assert (sals.nelts == 1);
> + gdb_assert (my_pre_expanded || sals.nelts == 1);
>
> resolve_sal_pc (&sals.sals[0]);
> if (b->condition_not_parsed && s && s[0])
> @@ -11049,22 +11080,27 @@ re_set_breakpoint (struct breakpoint *b)
> struct symtabs_and_lines expanded = {0};
> struct symtabs_and_lines expanded_end = {0};
> struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
> + int pre_expanded = 0;
>
> input_radix = b->input_radix;
> save_current_space_and_thread ();
> switch_to_program_space_and_thread (b->pspace);
> set_language (b->language);
>
> - sals = addr_string_to_sals (b, b->addr_string, &found);
> + sals = addr_string_to_sals (b, b->addr_string, &found, &pre_expanded);
> if (found)
> {
> make_cleanup (xfree, sals.sals);
> - expanded = expand_line_sal_maybe (sals.sals[0]);
> + if (pre_expanded)
> + expanded = sals;
> + else
> + expanded = expand_line_sal_maybe (sals.sals[0]);
> }
>
> if (b->addr_string_range_end)
> {
> - sals_end = addr_string_to_sals (b, b->addr_string_range_end, &found);
> + sals_end = addr_string_to_sals (b, b->addr_string_range_end, &found,
> + NULL);
> if (found)
> {
> make_cleanup (xfree, sals_end.sals);
> diff --git a/gdb/linespec.h b/gdb/linespec.h
> index d8d2ec9..458235c 100644
> --- a/gdb/linespec.h
> +++ b/gdb/linespec.h
> @@ -30,6 +30,10 @@ struct linespec_result
> display mechanism would do the wrong thing. */
> int special_display;
>
> + /* If non-zero, the linespec result should be considered to be a
> + "pre-expanded" multi-location linespec. */
> + int pre_expanded;
Here could be the comment by Tom from the follow-up mail as this comment does
not explain much.
> +
> /* If non-NULL, an array of canonical names for returned
> symtab_and_line objects. The array has as many elements as the
> `nelts' field in the symtabs_and_line returned by decode_line_1.
Thanks,
Jan