From: 杨已彪 <2019010291@hust.edu.cn>
To: "Luis Machado" <luis.machado@linaro.org>
Cc: gdb@sourceware.org
Subject: Re: Re: Wrong debug info for argc at -O2
Date: Tue, 30 Jun 2020 23:30:45 +0800 (GMT+08:00) [thread overview]
Message-ID: <46654a76.1da00.17305da15ec.Coremail.2019010291@hust.edu.cn> (raw)
In-Reply-To: <c3044feb-d401-5120-17d7-999f1bd86477@linaro.org>
I am very sorry that I forgot to reply this.
I am using Ubuntu 20.04 with x86_64.
$ uname -a
Linux Lab 5.4.0-26-generic #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
"Luis Machado" <luis.machado@linaro.org>wrote:
> On 5/29/20 12:58 PM, 杨已彪 wrote:
> >
> >
> > Consider test-case:
> > ...
> > $ cat small.c
> > #include <stdio.h>
> >
> > int main(int argc, char **argv) {
> > char buf[6];
> > char c[] = "abc";
> > sprintf(buf, (char *)c, 1);
> >
> > return 0;
> > }
> > ...
> >
> >
> > Stepping with step and print the values of arguments:
> > ...
> > $ gcc -O2 -g small.c; gdb -q a.out
> > Reading symbols from a.out...
> > (gdb) b main
> > Breakpoint 1 at 0x401040: file small.c, line 5.
> > (gdb) r
> > Starting program: /home/yibiao/Debugger/a.out
> >
> > Breakpoint 1, main (argc=1, argv=0x7fffffffdff8) at small.c:5
> > 5 char c[] = "abc";
> > (gdb) info args argc
> > argc = 1
> > (gdb) step
> > 6 sprintf(buf, (char *)c, 1);
> > (gdb) info args argc
> > argc = -8454
> > (gdb)
>
> What architecture is this?
>
> If you want precise debug information, you should use -O0 instead. With
> O2 you are likely to run into situations where the debug info has been
> lost or is just incorrect.
>
> With that said, GCC has improved over the past few years in terms of
> debug info generation for O2+.
prev parent reply other threads:[~2020-06-30 15:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-29 15:58 杨已彪
2020-06-22 18:14 ` Simon Marchi
2020-06-22 18:53 ` Luis Machado
2020-06-30 15:30 ` 杨已彪 [this message]
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=46654a76.1da00.17305da15ec.Coremail.2019010291@hust.edu.cn \
--to=2019010291@hust.edu.cn \
--cc=gdb@sourceware.org \
--cc=luis.machado@linaro.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).