public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: Shengyu Huang <kumom.huang@gmail.com>
Cc: GCC Development <gcc@gcc.gnu.org>
Subject: Re: [GSoC][Static Analyzer] Some questions and request for a small patch to work on
Date: Wed, 01 Mar 2023 08:48:40 -0500	[thread overview]
Message-ID: <76eab2fdfdc89c9ca1fcb0ea23ed3540b4bec452.camel@redhat.com> (raw)
In-Reply-To: <5BF6D475-B981-4B7C-A86B-BCCEF629AC19@gmail.com>

On Wed, 2023-03-01 at 12:16 +0100, Shengyu Huang wrote:
> Hi Dave,
> 
> > On 1 Mar 2023, at 00:59, David Malcolm <dmalcolm@redhat.com> wrote:
> > 
> > Did you get it to output your messages?
> > 
> 
> 
> Yes, I chose to emit the warning before the supergraph or exploded
> graph is created (I guess this is enough, right?). I checked out from
> the trunk a week ago, and I checked out from the latest trunk just
> now and built from modified source again, by adding a line in the
> following code in analyzer/engine.cc:
> 
> FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node) {
>   node->get_untransformed_body ();
>   warning_at (DECL_SOURCE_LOCATION (node->decl), 0, "hello world, I’m
> compiling %qE", node->decl); // ADDED
> }
> 
> Compiling my own test script without optimizations, I got the output
> (surprisingly no warning from -Wanalyzer-shift-count-negative
> anymore):
> 
> test.c: In function 'main':
> test.c:42:9: warning: left shift count is negative [-Wshift-count-
> negative]
>    42 |   b = b << -1;
>       |         ^~
> test.c: At top level:
> test.c:36:5: warning: hello world, I'm compiling 'main'
>    36 | int main()
>       |     ^~~~
> test.c:27:6: warning: hello world, I'm compiling 're'
>    27 | void re (int c)
>       |      ^~
> test.c:12:6: warning: hello world, I'm compiling 'f'
>    12 | void f (unsigned long *p, int r, int i)
>       |      ^
> test.c:9:5: warning: hello world, I'm compiling 'fun2'
>     9 | int fun2()
>       |     ^~~~
> test.c:4:5: warning: hello world, I'm compiling 'fun1'
>     4 | int fun1()
>       |     ^~~~

Looks great.

[...snip...]

> 
> 
> 
> > 
> > The next thing to do might be to try stepping through the code in
> > the
> > debugger; that's often a good way to learn about a new codebase. 
> > See:
> >  https://gcc-newbies-guide.readthedocs.io/en/latest/debugging.html
> > and maybe have a look at the support scripts mentioned on that
> > page.
> > 
> 
> I did try to use gdb more to inspect the internals, but one thing I
> noticed when using it is that I got `??()` in the backtrace, which
> I’ve never seen before. Some online sources say it happened due to
> “corrupted stack”, but I don’t know how that can happen
> either…However, after pulling changes from the trunk and rebuilding
> from the source, “??()” disappeared and now I can step through the
> execution without any problem (previously `step` and `continue` did
> not work as expected…). Do you have any clues what happened so that I
> can fix it myself later if that happens again?

I've noticed that if I invoke "make" in the top-level build directory,
when it recurses into the "gcc" subdirectory it builds with -O2,
whereas if I invoke "make" directly in the build tree's gcc
subdirectory it builds without optimization, and I get a much better
debugging experience.  Maybe that's what happened?  Because of this, I
sometimes find I have to do "rm analyzer/*.o" in the "gcc" subdirectory
of the build, and rerun "make" in there.  Though even with -O2 my gdb
still gives me function names in the backtrace, albeit on x86_64, and
probably a different version of gdb...

> 
> Best,
> Shengyu
> 
> > BTW, are you building trunk, or GCC 12?  I've made a *lot* of
> > changes
> > to the analyzer in trunk, so it would be good for you to be working
> > with something that's reasonably up-to-date.

Sounds like you're pulling from trunk; good.

Thanks
Dave


  reply	other threads:[~2023-03-01 13:48 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21 21:26 Shengyu Huang
2023-02-21 22:55 ` David Malcolm
2023-02-22 14:03   ` Jonathan Wakely
2023-02-23 11:17     ` James K. Lowden
2023-02-23 16:30       ` Jonathan Wakely
2023-02-22 14:11   ` Shengyu Huang
2023-02-22 14:53     ` Iain Sandoe
2023-02-22 15:13       ` Iain Sandoe
2023-02-27 13:35       ` Shengyu Huang
2023-02-27 13:45         ` Iain Sandoe
2023-02-27 13:51           ` Shengyu Huang
2023-02-27 13:49         ` Iain Sandoe
2023-02-27 14:01           ` Floyd, Paul
2023-02-22 15:43     ` David Malcolm
2023-02-28  9:18       ` Shengyu Huang
2023-02-28 23:59         ` David Malcolm
2023-03-01 11:16           ` Shengyu Huang
2023-03-01 13:48             ` David Malcolm [this message]
2023-02-28 14:46     ` [GSoC][Static Analyzer] Ideas for proposal Shengyu Huang
2023-03-01  0:22       ` David Malcolm
2023-03-12 22:20         ` Shengyu Huang
2023-03-13 15:51           ` David Malcolm
2023-03-20 17:28             ` [GSoC][Static Analyzer] First proposal draft and a few more questions/requests Shengyu Huang
2023-03-20 22:50               ` David Malcolm
2023-03-26 16:03                 ` Shengyu Huang
2023-03-26 17:14                   ` David Malcolm
2023-03-26 21:46                     ` Shengyu Huang
2023-04-01 14:19                       ` Shengyu Huang
2023-04-02 22:53                         ` David Malcolm
2023-04-03  0:02                           ` Shengyu Huang

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=76eab2fdfdc89c9ca1fcb0ea23ed3540b4bec452.camel@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=kumom.huang@gmail.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).