public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: Andreas Schwab <schwab@linux-m68k.org>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix wrong assertions
Date: Fri, 29 May 2015 14:10:00 -0000	[thread overview]
Message-ID: <20150529141027.GA8159@host1.jankratochvil.net> (raw)
In-Reply-To: <86382fpki0.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2521 bytes --]

On Fri, 29 May 2015 15:43:19 +0200, Yao Qi wrote:
> Jan Kratochvil <jan.kratochvil@redhat.com> writes:
> > The terminology seems bogus there.
> >
> > "partially ambiguous" was meant the chain:
> > 	main -> a -> <???> -> d
> > An intersection of all possible chains.
> 
> Sounds like "partially ambiguous" is equivalent to "ambiguous".

Yes, probably, I am not sure how to call it all myself.


> If that is right, the assert below is too strict, isn't?

Yes, it is too strict, this is why I agree with the fix by Andreas.


>   /* See call_site_find_chain_1 why there is no way to reach the bottom callee
>      PC again.  In such case there must be two different code paths to reach
>      it, therefore some of the former determined intermediate PCs must differ
>      and the unambiguous chain gets shortened.  */
>   gdb_assert (result->callers + result->callees < result->length);
> 
> > but that doe snot matter).  Consequently its elements from the middle are
> > being removed and there remains only some few unambiguous top and
> > bottom ones.
> 
> If there is no call sites removed from the chain during the intersection,
> CALLERS + CALLEES == LENGTH, right?

Just I expected there always has to be some site removed from the chain.
I do not find obvious it does not have to.  But maybe someone else finds it
obvious.


> in function chain_candidate,
> result->length is set by the length of a chain.  If this chain is the
> shortest one, CALLERS + CALLEES == LENGTH otherwise,
> CALLERS + CALLEES < LENGTH.  Is it right?

It is right now.  But when one does not think about self-tail-calls then even
the shortest one will get one frame removed.


> If so, we need to relax the
> condition in the assert and update the comments.

Yes, attached with updated comment.


> > I did not realize that there can be self-tail-call:
> > 	main(0x100) -> a(0x200) -> d(0x400)
> > 	main(0x100) -> a(0x280) -> a(0x200) -> d(0x400)
> > which intersects to:
> > 	main(0x100) -> <???>? -> a(0x200) -> d(0x400)
> > And so if the first chain was chosen the
> > 	main(0x100) -> a(0x200) -> d(0x400)
> > then the final intersection has callers+callees==length.
> 
> What are the definitions of CALLERS, CALLEES, top and bottom? given this example?

top=CALLERS=main(0x100), therefore 1
bottom=CALLEES=d(0x400), therefore 1

top = topmost, where you can go by GDB "up" commands, also called "prev" in
struct frame_info.

bottom = bottommost, where you can go by GDB "down" commands, also called
"next" in struct frame_info.


Jan

[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 1517 bytes --]

2015-05-29  Andreas Schwab  <schwab@linux-m68k.org>
	    Jan Kratochvil  <jan.kratochvil@redhat.com>

	PR symtab/18392
	* dwarf2-frame-tailcall.c (pretended_chain_levels): Correct
	assertion.
	* dwarf2loc.c (chain_candidate): Likewise.

diff --git a/gdb/dwarf2-frame-tailcall.c b/gdb/dwarf2-frame-tailcall.c
index b412a5b..f964ab2 100644
--- a/gdb/dwarf2-frame-tailcall.c
+++ b/gdb/dwarf2-frame-tailcall.c
@@ -197,7 +197,7 @@ pretended_chain_levels (struct call_site_chain *chain)
     return chain->length;
 
   chain_levels = chain->callers + chain->callees;
-  gdb_assert (chain_levels < chain->length);
+  gdb_assert (chain_levels <= chain->length);
 
   return chain_levels;
 }
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 3aa8ddd..68d6cb4 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -825,9 +825,9 @@ chain_candidate (struct gdbarch *gdbarch, struct call_site_chain **resultp,
 
   /* See call_site_find_chain_1 why there is no way to reach the bottom callee
      PC again.  In such case there must be two different code paths to reach
-     it, therefore some of the former determined intermediate PCs must differ
-     and the unambiguous chain gets shortened.  */
-  gdb_assert (result->callers + result->callees < result->length);
+     it.  Still it may CALLERS+CALLEES==LENGTH in the case of optional
+     tail-call calling itself.  */
+  gdb_assert (result->callers + result->callees <= result->length);
 }
 
 /* Create and return call_site_chain for CALLER_PC and CALLEE_PC.  All the

  reply	other threads:[~2015-05-29 14:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-09 18:57 Andreas Schwab
2015-05-13 14:01 ` Jan Kratochvil
2015-05-13 14:35   ` Andreas Schwab
2015-05-29  9:31   ` Yao Qi
2015-05-29 11:31     ` Jan Kratochvil
2015-05-29 13:43       ` Yao Qi
2015-05-29 14:10         ` Jan Kratochvil [this message]
2015-05-29 16:33           ` Yao Qi
2015-05-30  7:44             ` Jan Kratochvil
2015-06-01 11:35           ` Yao Qi
2015-06-01 12:05             ` [commit] " Jan Kratochvil
2015-05-19 20:47 ` [patch] testcase: tailcall assertion [Re: [PATCH] Fix wrong assertions] Jan Kratochvil

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=20150529141027.GA8159@host1.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=qiyaoltc@gmail.com \
    --cc=schwab@linux-m68k.org \
    /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).