This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Emit accurate debug info for short-circuit operators


On Mon, Apr 20, 2009 at 11:29 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> currently for:
>
> _Bool F8 (_Bool B1, _Bool B2, _Bool B3, _Bool B4, _Bool B5, _Bool B6,
> ? ? ? ? ?_Bool B7, _Bool B8)
> {
> ?_Bool R;
>
> ?if ((B1
> ? ? ? || B2)
> ? ? ?&& B3
> ? ? ?&& !(B4
> ? ? ? ? ? || B5)
> ? ? ?&& (B6
> ? ? ? ? ?|| (B7
> ? ? ? ? ? ? ?&& B8)))
> ? ?R = True;
> ?else
> ? ?R = False;
> ?return R;
> }
>
> the debug session at -O0 looks like:
>
> Breakpoint 1, F8 (B1=false, B2=true, B3=true, B4=false, B5=false, B6=false,
> ? ?B7=true, B8=true) at t.c:62
> 62 ? ? ? ?if ((B1
> (gdb) next
> 70 ? ? ? ? ?R = True;
> (gdb) next
> 62 ? ? ? ?if ((B1
> (gdb) next
> 73 ? ? ? ?return R;
>
> The goal of this change is to make it look like:
>
> Breakpoint 1, F8 (B1=false, B2=true, B3=true, B4=false, B5=false, B6=false,
> ? ?B7=true, B8=true) at t.c:62
> 62 ? ? ? ?if ((B1
> (gdb) next
> 63 ? ? ? ? ? ? || B2)
> (gdb)
> 64 ? ? ? ? ? ? && B3
> (gdb)
> 65 ? ? ? ? ? ? && !(B4
> (gdb)
> 66 ? ? ? ? ? ? ? ? ?|| B5)
> (gdb)
> 67 ? ? ? ? ? ? && (B6
> (gdb)
> 68 ? ? ? ? ? ? ? ? || (B7
> (gdb)
> 69 ? ? ? ? ? ? ? ? ? ? && B8)))
> (gdb)
> 70 ? ? ? ? ?R = True;
> (gdb)
> 73 ? ? ? ?return R;
>
>
> It is made up of 3 parts:
> ?1. Front-end support for accurate locations on short-circuit operators;
> nothing to do for the Ada front-end, patch for the C front-end attached,
> ?2. Small front-end tweak for the NOT operator, Ada and C patches attached,
> ?3. Gimplifier support.
>
> Tested (GCC, GDB) on i586-suse-linux, OK for mainline?

Nice.

The middle-end changes are ok.

Thanks,
Richard.

>
> 2009-04-20 ?Eric Botcazou ?<ebotcazou@adacore.com>
>
> ? ? ? ?* c-common.c (c_common_truthvalue_conversion): Use LOCATION to build
> ? ? ? ?NE_EXPR operations as well.
> ? ? ? ?* c-parser.c (c_parser_condition): Do not set location information on
> ? ? ? ?the condition.
> ? ? ? ?(c_parser_conditional_expression): Likewise.
> ? ? ? ?(c_parser_binary_expression): Set location information on operators.
> ? ? ? ?* c-typeck.c (build_unary_op) <TRUTH_NOT_EXPR>: Reset the location if
> ? ? ? ?TRUTH_NOT_EXPR has been folded.
> ? ? ? ?* fold-const.c (fold_truth_not_expr): Copy location information from
> ? ? ? ?the incoming expression to the outgoing one.
> ? ? ? ?* gimplify.c (shortcut_cond_r): Add locus parameter. ?Pass it to
> ? ? ? ?recursive calls on the LHS of the operator but pass that of the
> ? ? ? ?operator to recursive calls on the RHS of the operator. ?Set it
> ? ? ? ?on the COND_EXPR.
> ? ? ? ?(shortcut_cond_expr): Set the locus of the operator on the second
> ? ? ? ?COND_EXPR and that of the expression on the first in degenerate cases.
> ? ? ? ?Pass the locus of the expression to calls to shortcut_cond_r.
> ? ? ? ?Set the locus of the 'then' block on the associated jump, if any.
> ? ? ? ?(gimplify_boolean_expr): Add locus parameter. ?Set it on the COND_EXPR.
> ? ? ? ?(gimplify_expr) <TRUTH_ANDIF_EXPR>: Pass the locus of the outer
> ? ? ? ?expression to call to gimplify_boolean_expr.
> ada/
> ? ? ? ?* gcc-interface/trans.c (gnat_to_gnu): Do not overwrite location info.
>
>
> 2009-04-20 ?Eric Botcazou ?<ebotcazou@adacore.com>
>
> ? ? ? ?* gcc.dg/debug/dwarf2/short-circuit.c: New test.
>
>
> --
> Eric Botcazou
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]