From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E4FE6385828D for ; Wed, 1 Mar 2023 13:48:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E4FE6385828D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677678523; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Qp6ZMIKY2iI2X7EyHqHR75t1cZo7rOenGa/ezMp4jMk=; b=JNoPH09zhyf8nb0qqAEUHsjkIy54hg13GRlC52iLd6g06IN7jRdQkF2h2vU7VxPOyPrtBw CIW1ya0d0neEt1rtrGQEexweLRo+1cRXOnKVVFnpvKqsoDr8qmvZH8sdLZcWtJCjcbSkZP CcNgSPJyCBfbTTEwLRgB4NexPmBy+wc= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-561-46XldOL2PhqAydUFteavgA-1; Wed, 01 Mar 2023 08:48:42 -0500 X-MC-Unique: 46XldOL2PhqAydUFteavgA-1 Received: by mail-qk1-f197.google.com with SMTP id x14-20020ae9e90e000000b007429af46d5eso6671480qkf.12 for ; Wed, 01 Mar 2023 05:48:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677678522; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Qp6ZMIKY2iI2X7EyHqHR75t1cZo7rOenGa/ezMp4jMk=; b=TY2HCuEAEAZrOO6kKS0ameml8Nt6J8u6Rdhn3M9YnMkXYPpLm8zUL8FJEBVdcfo3mp S/TWBX/QP/OiTl3A62CJ69y0qfx4jyvlDtfnDgue8osAkgq5tj2DOJbQ5mgIH2R8E4+o 2R1aWI6tlEVOC6dXBQwJ9JTs8gKIsnuXU+YS6uo6Np/+TI1BumDBG9Ob+ghOPSG1sHW6 rj8pZXWUWSbMkjtqanmCCv1hoTVsvhjeM1ShfydpjUv5pEgVZp4r692oTXFqLisdApMp YQtGUCHinburH7vbb3GiiKa6Vmg1SUGAV8hT6L2Wuxd6r0z2YYOzvtrO8pUU7GBFRS4k RVcA== X-Gm-Message-State: AO0yUKXmHHJX1IPPqvU69yt8H6u3NjepvHdFiUCmtAsIyekta/JrTNNn 2M5f79DZbPqvcRm7QR97hsaY2PeAUHWiHLg4QqXtMfqMh0NYR2KIFEHD/c1Snf0uEag+TMK2hYO O1FWtQFQ= X-Received: by 2002:ac8:7d51:0:b0:3bf:d196:5e27 with SMTP id h17-20020ac87d51000000b003bfd1965e27mr11367319qtb.20.1677678522015; Wed, 01 Mar 2023 05:48:42 -0800 (PST) X-Google-Smtp-Source: AK7set/jEbbn781u9jGfHn3B6IVKyBFCkljpt9VF+8lRz8DGmsDoLOeupyzK8Ih4j+beoQhoCWHrzw== X-Received: by 2002:ac8:7d51:0:b0:3bf:d196:5e27 with SMTP id h17-20020ac87d51000000b003bfd1965e27mr11367295qtb.20.1677678521709; Wed, 01 Mar 2023 05:48:41 -0800 (PST) Received: from t14s.localdomain (c-73-69-212-193.hsd1.ma.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id e17-20020a05620a015100b00742e61999a3sm2231750qkn.64.2023.03.01.05.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Mar 2023 05:48:41 -0800 (PST) Message-ID: <76eab2fdfdc89c9ca1fcb0ea23ed3540b4bec452.camel@redhat.com> Subject: Re: [GSoC][Static Analyzer] Some questions and request for a small patch to work on From: David Malcolm To: Shengyu Huang Cc: GCC Development Date: Wed, 01 Mar 2023 08:48:40 -0500 In-Reply-To: <5BF6D475-B981-4B7C-A86B-BCCEF629AC19@gmail.com> References: <960EE623-1B17-4321-B77E-FBCD9496BE1F@gmail.com> <40fbb064f56845908f797400e5d9443b6cf97fe4.camel@redhat.com> <594374fad6f19b956b3f0e6e5ce04ad51205186b.camel@redhat.com> <5BF6D475-B981-4B7C-A86B-BCCEF629AC19@gmail.com> User-Agent: Evolution 3.44.4 (3.44.4-1.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 2023-03-01 at 12:16 +0100, Shengyu Huang wrote: > Hi Dave, >=20 > > On 1 Mar 2023, at 00:59, David Malcolm wrote: > >=20 > > Did you get it to output your messages? > >=20 >=20 >=20 > 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: >=20 > FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node) { > =C2=A0 node->get_untransformed_body (); > =C2=A0 warning_at (DECL_SOURCE_LOCATION (node->decl), 0, "hello world, I= =E2=80=99m > compiling %qE", node->decl); // ADDED > } >=20 > Compiling my own test script without optimizations, I got the output > (surprisingly no warning from -Wanalyzer-shift-count-negative > anymore): >=20 > test.c: In function 'main': > test.c:42:9: warning: left shift count is negative [-Wshift-count- > negative] > =C2=A0=C2=A0 42 |=C2=A0=C2=A0 b =3D b << -1; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 ^~ > test.c: At top level: > test.c:36:5: warning: hello world, I'm compiling 'main' > =C2=A0=C2=A0 36 | int main() > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0 ^~~~ > test.c:27:6: warning: hello world, I'm compiling 're' > =C2=A0=C2=A0 27 | void re (int c) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ^~ > test.c:12:6: warning: hello world, I'm compiling 'f' > =C2=A0=C2=A0 12 | void f (unsigned long *p, int r, int i) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ^ > test.c:9:5: warning: hello world, I'm compiling 'fun2' > =C2=A0=C2=A0=C2=A0 9 | int fun2() > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0 ^~~~ > test.c:4:5: warning: hello world, I'm compiling 'fun1' > =C2=A0=C2=A0=C2=A0 4 | int fun1() > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0 ^~~~ Looks great. [...snip...] >=20 >=20 >=20 > >=20 > > 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.=C2=A0 > > See: > > =C2=A0https://gcc-newbies-guide.readthedocs.io/en/latest/debugging.html > > and maybe have a look at the support scripts mentioned on that > > page. > >=20 >=20 > 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=E2=80=99ve never seen before. Some online sources say it happened due t= o > =E2=80=9Ccorrupted stack=E2=80=9D, but I don=E2=80=99t know how that can = happen > either=E2=80=A6However, after pulling changes from the trunk and rebuildi= ng > from the source, =E2=80=9C??()=E2=80=9D disappeared and now I can step th= rough the > execution without any problem (previously `step` and `continue` did > not work as expected=E2=80=A6). Do you have any clues what happened so th= at 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... >=20 > Best, > Shengyu >=20 > > BTW, are you building trunk, or GCC 12?=C2=A0 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