This is the mail archive of the 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: RFA: Adding a location_t (or pointer) to tree_exp for 3.4 only.

Ok, I moved the wrapping to build_cxx_call.
That didn't help much though: the WFL is still passed
to functions that expect (or *might* expect) a CALL_EXPR.

The diff below reflects the state of my current test.

It contains a *functional* WFL wrapping (assembly output is
ok with my test case); however - I also added some test
code that does the following:

I changed the macro TREE_CODE(NODE) to core dump every
time that it is being called for the WFL that wraps
a CALL_EXPR and when the global 'nocheck' variable is not

I set the 'nocheck' to 1 when it is normal that TREE_CODE()
would be called for the WFL; but still, it turns out that
the WFL ends up being passed unwrapped to certain functions
for which it is not logical that it isn't unwrapped in
advance and which potentially could cause a problem.

With my test case, and with the diff below, the core is
triggered here:

0x08192696 in arg_assoc (k=0xbfffea60, n=0x40266380)
    at ../../../gcc/gcc-mainline/gcc/cp/decl2.c:3699
3699      if (TYPE_P (n))

Where 'n' is a expr_with_file_location wrapping a call_expr:

(gdb) call debug_tree(n)
 <expr_with_file_location 0x40266380
    type <integer_type 0x4026a57c int SI
        size <integer_cst 0x40268258 constant 32>
        unit size <integer_cst 0x402682e4 constant 4>
        align 32 symtab 0 alias set -1 precision 32 min <integer_cst 0x402682bc -2147483648> max <integer_cst 0x402682d0 2147483647>
        pointer_to_this <pointer_type 0x4027506c>>
    side-effects public
    arg 0 <call_expr 0x4026f390 type <integer_type 0x4026a57c int>
        arg 0 <addr_expr 0x402edb90 type <pointer_type 0x402f4c3c>
            constant arg 0 <function_decl 0x402f45e8 h13>>>
    arg 1 <identifier_node 0x402f9580 troep.ccbindings <(nil)>local bindings <(nil)>>>

While this particuar place might not be a problem because
it doesn't test explicitly for CALL_EXPR, so that that
now CALL_EXPR is 'replaced' with 'EXPR_WITH_FILE_LOCATION',
nothing changes, it still makes clear things COULD have
gone wrong.

arg_assoc contains a lot of direct tests of TREE_CODE:

static bool
arg_assoc (struct arg_lookup *k, tree n)
  if (n == error_mark_node)
    return false;

  if (TYPE_P (n))
    return arg_assoc_type (k, n);

  if (! type_unknown_p (n))
    return arg_assoc_type (k, TREE_TYPE (n));

  if (TREE_CODE (n) == ADDR_EXPR)
    n = TREE_OPERAND (n, 0);
    n = TREE_OPERAND (n, 1);
  if (TREE_CODE (n) == OFFSET_REF)
    n = TREE_OPERAND (n, 1);
  while (TREE_CODE (n) == TREE_LIST)
    n = TREE_VALUE (n);
  if (TREE_CODE (n) == BASELINK)

(gdb) bt
#0  0x08192696 in arg_assoc (k=0xbfffea60, n=0x40266380)
    at ../../../gcc/gcc-mainline/gcc/cp/decl2.c:3699
#1  0x08192628 in arg_assoc_args (k=0xbfffea60, args=0x402edba4)
    at ../../../gcc/gcc-mainline/gcc/cp/decl2.c:3686
#2  0x081937b0 in lookup_arg_dependent (name=0x402f9340, fns=0x402f4870, args=0x402edb7c)
    at ../../../gcc/gcc-mainline/gcc/cp/decl2.c:3790
#3  0x0823fd19 in perform_koenig_lookup (fn=0x402f4870, args=0x402edb7c)
    at ../../../gcc/gcc-mainline/gcc/cp/semantics.c:1567
#4  0x081b572b in cp_parser_postfix_expression (parser=0x402f9140, address_p=false)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:3543
#5  0x081b685a in cp_parser_unary_expression (parser=0x402f9140, address_p=false)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4122
#6  0x081b6fa4 in cp_parser_cast_expression (parser=0x402f9140, address_p=false)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4546
#7  0x081c71df in cp_parser_simple_cast_expression (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:13791
#8  0x081c6259 in cp_parser_binary_expression (parser=0x402f9140,
    token_tree_map=0x873a280, fn=0x81c71cc <cp_parser_simple_cast_expression>)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:13290
#9  0x081b6fca in cp_parser_pm_expression (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4567
#10 0x081c6259 in cp_parser_binary_expression (parser=0x402f9140,
    token_tree_map=0x873a28c, fn=0x81b6faf <cp_parser_pm_expression>)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:13290
#11 0x081b6fea in cp_parser_multiplicative_expression (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4591
#12 0x081c6259 in cp_parser_binary_expression (parser=0x402f9140,
    token_tree_map=0x873a29c, fn=0x81b6fcf <cp_parser_multiplicative_expression>)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:13290
#13 0x081b700a in cp_parser_additive_expression (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4614
#14 0x081c6259 in cp_parser_binary_expression (parser=0x402f9140,
    token_tree_map=0x873a2a8, fn=0x81b6fef <cp_parser_additive_expression>)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:13290
#15 0x081b702a in cp_parser_shift_expression (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4637
#16 0x081c6259 in cp_parser_binary_expression (parser=0x402f9140,
    token_tree_map=0x873a2b4, fn=0x81b700f <cp_parser_shift_expression>)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:13290
#17 0x081b704a in cp_parser_relational_expression (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4672
#18 0x081c6259 in cp_parser_binary_expression (parser=0x402f9140,
    token_tree_map=0x873a2d0, fn=0x81b702f <cp_parser_relational_expression>)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:13290
#19 0x081b706a in cp_parser_equality_expression (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4695
#20 0x081c6259 in cp_parser_binary_expression (parser=0x402f9140,
    token_tree_map=0x873a2dc, fn=0x81b704f <cp_parser_equality_expression>)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:13290
#21 0x081b708a in cp_parser_and_expression (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4716
#22 0x081c6259 in cp_parser_binary_expression (parser=0x402f9140,
    token_tree_map=0x873a2e4, fn=0x81b706f <cp_parser_and_expression>)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:13290
#23 0x081b70aa in cp_parser_exclusive_or_expression (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4737
#24 0x081c6259 in cp_parser_binary_expression (parser=0x402f9140,
    token_tree_map=0x873a2ec, fn=0x81b708f <cp_parser_exclusive_or_expression>)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:13290
#25 0x081b70ca in cp_parser_inclusive_or_expression (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4759
#26 0x081c6259 in cp_parser_binary_expression (parser=0x402f9140,
    token_tree_map=0x873a2f4, fn=0x81b70af <cp_parser_inclusive_or_expression>)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:13290
#27 0x081b70ea in cp_parser_logical_and_expression (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4780
#28 0x081c6259 in cp_parser_binary_expression (parser=0x402f9140,
    token_tree_map=0x873a2fc, fn=0x81b70cf <cp_parser_logical_and_expression>)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:13290
#29 0x081b710a in cp_parser_logical_or_expression (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4801
#30 0x081b71e0 in cp_parser_assignment_expression (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:4869
#31 0x081bfa60 in cp_parser_parameter_declaration (parser=0x402f9140,
    template_parm_p=false) at ../../../gcc/gcc-mainline/gcc/cp/parser.c:10632
#32 0x081bf5d6 in cp_parser_parameter_declaration_list (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:10386
#33 0x081bf517 in cp_parser_parameter_declaration_clause (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:10332
#34 0x081bd3f4 in cp_parser_direct_declarator (parser=0x402f9140,
    dcl_kind=CP_PARSER_DECLARATOR_NAMED, ctor_dtor_or_conv_p=0xbffff0e0)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:9750
#35 0x081bd318 in cp_parser_declarator (parser=0x402f9140,
    dcl_kind=CP_PARSER_DECLARATOR_NAMED, ctor_dtor_or_conv_p=0xbffff0e0)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:9625
#36 0x081bcced in cp_parser_init_declarator (parser=0x402f9140,
    decl_specifiers=0x402edaa0, prefix_attributes=0x0,
    function_definition_allowed_p=true, member_p=false, declares_class_or_enum=0,
    function_definition_p=0xbffff13f) at ../../../gcc/gcc-mainline/gcc/cp/parser.c:9299
#37 0x081b8652 in cp_parser_simple_declaration (parser=0x402f9140,
    function_definition_allowed_p=true) at ../../../gcc/gcc-mainline/gcc/cp/parser.c:6156
#38 0x081b858c in cp_parser_block_declaration (parser=0x402f9140, statement_p=false)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:6072
#39 0x081b8448 in cp_parser_declaration (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:5992
#40 0x081b827e in cp_parser_declaration_seq_opt (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:5901
#41 0x081b34a5 in cp_parser_translation_unit (parser=0x402f9140)
    at ../../../gcc/gcc-mainline/gcc/cp/parser.c:2163
#42 0x081c8cdb in c_parse_file () at ../../../gcc/gcc-mainline/gcc/cp/parser.c:14523
#43 0x082d79c8 in c_common_parse_file (set_yydebug=0)
    at ../../../gcc/gcc-mainline/gcc/c-opts.c:1226
#44 0x0860c923 in compile_file () at ../../../gcc/gcc-mainline/gcc/toplev.c:1792
#45 0x08611d36 in do_compile () at ../../../gcc/gcc-mainline/gcc/toplev.c:4482
#46 0x08611dcb in toplev_main (argc=29, argv=0xbffff2f4)
    at ../../../gcc/gcc-mainline/gcc/toplev.c:4522
#47 0x082db882 in main (argc=29, argv=0xbffff2f4)
    at ../../../gcc/gcc-mainline/gcc/main.c:35
#48 0x420156a4 in __libc_start_main () from /lib/tls/

I go to bed now - tomorrow I'll find more places where this happens.

Index: rtl.c
RCS file: /cvs/gcc/gcc/gcc/rtl.c,v
retrieving revision 1.126
diff -u -d -p -r1.126 rtl.c
--- rtl.c	30 Jul 2003 19:23:31 -0000	1.126
+++ rtl.c	7 Oct 2003 02:22:14 -0000
@@ -28,6 +28,7 @@ Software Foundation, 59 Temple Place - S
 #include "ggc.h"
 #include "errors.h"
+int nocheck = 0;	/* just temporal test var */
 /* Indexed by rtx code, gives number of operands for an rtx with that code.
    Does NOT include rtx header data (code and links).  */
Index: tree.h
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.447
diff -u -d -p -r1.447 tree.h
--- tree.h	28 Sep 2003 19:09:49 -0000	1.447
+++ tree.h	7 Oct 2003 02:22:19 -0000
@@ -267,7 +267,20 @@ struct tree_common GTY(())
 /* The tree-code says what kind of node it is.
    Codes are defined in tree.def.  */
+extern int nocheck;
+#if 0
 #define TREE_CODE(NODE) ((enum tree_code) (NODE)->common.code)
+#define TREE_CODE(NODE) __extension__					\
+({  enum tree_code code = ((enum tree_code) (NODE)->common.code);	\
+    if (!nocheck && code == EXPR_WITH_FILE_LOCATION &&			\
+        (TREE_CODE_NOCHECK(((NODE)->exp.operands[0])) == CALL_EXPR))	\
+      *(int*)0=1;							\
+    code; })
+#define TREE_CODE_NOCHECK(NODE) ((enum tree_code) (NODE)->common.code)
 ((NODE)->common.code = (ENUM_BITFIELD (tree_code)) (VALUE))
Index: cp/call.c
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.437
diff -u -d -p -r1.437 call.c
--- cp/call.c	27 Sep 2003 16:44:04 -0000	1.437
+++ cp/call.c	7 Oct 2003 02:22:22 -0000
@@ -4642,7 +4642,18 @@ build_cxx_call(tree fn, tree args, tree 
   if (IS_AGGR_TYPE (TREE_TYPE (fn)))
     fn = build_cplus_new (TREE_TYPE (fn), fn);
-  return convert_from_reference (fn);
+  fn = convert_from_reference (fn);
+  /* Wrap every call in a wfl in order to garantee that the correct
+     locus debug information is emitted.  This exception is made for
+     calls because they turn up in debugger back traces.  */
+  nocheck=1;
+  fn = build_expr_wfl (fn, input_location.file, input_location.line, 0);
+  nocheck=0;
+  return fn;
 static GTY(()) tree java_iface_lookup_fn;

Carlo Wood <>

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