public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Carlo Wood <carlo@alinoe.com>
To: Richard Henderson <rth@redhat.com>,
	gcc@gcc.gnu.org, wilson@specifixinc.com, jason@redhat.com
Subject: Re: RFA: Adding a location_t (or pointer) to tree_exp for 3.4 only.
Date: Tue, 07 Oct 2003 02:40:00 -0000	[thread overview]
Message-ID: <20031007024048.GA16520@alinoe.com> (raw)
In-Reply-To: <20031007004647.GA5397@redhat.com>

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
set.

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>
        side-effects
        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)>>
    troep.cc:13:0>

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);
  if (TREE_CODE (n) == COMPONENT_REF)
    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)
[...etc...]


(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/libc.so.6
(gdb)

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 */
 \f
 /* 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)
+#else
+/* TEST CODE - REMOVE */
+#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)
+#endif
+
 #define TREE_SET_CODE(NODE, VALUE) \
 ((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);
+  EXPR_WFL_EMIT_LINE_NOTE (fn) = 1;
+  nocheck=0;
+
+  return fn;
 }
 
 static GTY(()) tree java_iface_lookup_fn;

-- 
Carlo Wood <carlo@alinoe.com>

  reply	other threads:[~2003-10-07  2:40 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-22  2:31 RFC: debug line info & inlining; patch proposal and request for comments Carlo Wood
2003-09-23  5:33 ` Jim Wilson
2003-09-27 16:38 ` RFA: Adding a location_t (or pointer) to tree_exp for 3.4 only Carlo Wood
2003-10-06 12:58   ` Hans-Peter Nilsson
2003-10-06 17:41   ` Richard Henderson
2003-10-06 17:51     ` Daniel Jacobowitz
2003-10-06 18:03       ` Daniel Berlin
2003-10-06 19:20         ` Carlo Wood
2003-10-06 19:08     ` Carlo Wood
2003-10-06 20:11       ` Richard Henderson
2003-10-06 20:14         ` Daniel Jacobowitz
2003-10-06 20:20           ` Richard Henderson
2003-10-06 20:24             ` Daniel Jacobowitz
2003-10-06 21:54               ` Richard Henderson
2003-10-06 21:53             ` Carlo Wood
2003-10-06 21:55               ` Richard Henderson
2003-10-06 22:30                 ` Carlo Wood
2003-10-06 23:17                   ` Richard Henderson
2003-10-06 23:49                     ` Carlo Wood
2003-10-07  0:07                       ` Richard Henderson
2003-10-07  0:43                         ` Carlo Wood
2003-10-07  0:46                           ` Richard Henderson
2003-10-07  2:40                             ` Carlo Wood [this message]
2003-10-07 18:32                             ` Carlo Wood
2003-10-07 19:08                               ` Carlo Wood
2003-10-07 19:46                               ` Richard Henderson
2003-10-07 21:12                                 ` Carlo Wood
2003-10-07 23:43                                   ` Carlo Wood
2003-10-07 19:41                 ` Carlo Wood
2003-10-12  4:32             ` law
2003-10-12 12:02               ` Daniel Berlin

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=20031007024048.GA16520@alinoe.com \
    --to=carlo@alinoe.com \
    --cc=gcc@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=rth@redhat.com \
    --cc=wilson@specifixinc.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).