Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: 慕冬亮 <mudongliangabcd@gmail.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb@sourceware.org
Subject: Re: why does assert(0) corrupt the stack trace?
Date: Sun, 05 Nov 2017 20:05:00 -0000	[thread overview]
Message-ID: <CAD-N9QX17JssrU=Eo5whDFzLLQVUUb1RidHWwqzUC3ZFY6LGJw@mail.gmail.com> (raw)
In-Reply-To: <20171105195410.GA29185@host1.jankratochvil.net>

--
My best regards to you.

     No System Is Safe!
     Dongliang Mu


2017-11-05 14:54 GMT-05:00 Jan Kratochvil <jan.kratochvil@redhat.com>:
> On Sun, 05 Nov 2017 20:13:20 +0100, 慕冬亮 wrote:
>> I have a question about debugging assert in gdb. When one program
>> crash at one assert statement, the stack trace shown in the gdb is
>> corrupted. Is it normal?
>
> It was happening in the past as when assert() detects a failure it calls
> abort() which does never return - using GCC attribute noreturn.  Then GCC
> optimizer does not save enough registers to make the backtrace possible
> because the code will just abort anyway, the code does not need to know where
> to return.
>
If I compile the program with "-O0", this problem may be solved. Yes?
> It was some intermediate development phase where such optimization was created
> and before an exception has been made to make the backtracing by debuggers
> possible.
>
> Sorry for not looking up the Bugs/commits.
>
> As usual you should update your compiler + debugger to latest versions.
>
>
> Jan


  reply	other threads:[~2017-11-05 20:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-05 19:13 慕冬亮
2017-11-05 19:46 ` Paul Smith
2017-11-05 19:54 ` Jan Kratochvil
2017-11-05 20:05   ` 慕冬亮 [this message]
2017-11-05 20:10     ` Jan Kratochvil
2017-11-05 22:01     ` Duane Ellis

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='CAD-N9QX17JssrU=Eo5whDFzLLQVUUb1RidHWwqzUC3ZFY6LGJw@mail.gmail.com' \
    --to=mudongliangabcd@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=jan.kratochvil@redhat.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