From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id 90AB03858D28 for ; Sun, 23 Jan 2022 20:11:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 90AB03858D28 Received: by mail-ed1-x530.google.com with SMTP id z22so52576122edd.12 for ; Sun, 23 Jan 2022 12:11:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Nc3DGNIpvS9YqjlHz0TSdOmAF9L0tzR8tEWgb7UBJ2k=; b=6NDjtic32gydsakHZI9UYqTxrvL6JEbPEwIkCejdpKTC74PfQb6z0rQq/bsdBbmkEK owmdTbgQxVZNEnMVmrVShtsTyB/CxQeluovTHXhmItpZbn9Z5Nb+RJi7fQivhCi+AM5m j375CKbQFm78RTafMIANv5GxzR2L/8A8cQq+zZJIdJZBo82Bw0SW7c3St8MYwIaelOV3 O36434ZqUcBmgCmIfo91RvypgwspeA8O31NKEEGpTbijJdYaD2EYF0mbGve4n6xPycSt T0mIr/ImxaO/wZNHTIP7BeCuRTvUpTPFLQfPmlxz7KisLt7H4zxOTtabfwgjKE4LJJq8 th1A== X-Gm-Message-State: AOAM530ONkTjfT3/9NrgyKNWJL0+Q96RuiHEea5D5QKuFZxpe5IhYBCR o3xnu3iVdnsmOqyomHI78pPgYO4Ra0KhaV9eMeQ= X-Google-Smtp-Source: ABdhPJylz7f7whnFlbLk3G8ISbPXQNf1aDAOcXh48v/Jx6Sz74DqpvCptQpULPALHvs14Xl/WGcGV06Rg8P7CHv2XPk= X-Received: by 2002:a05:6402:1395:: with SMTP id b21mr12894294edv.299.1642968705571; Sun, 23 Jan 2022 12:11:45 -0800 (PST) MIME-Version: 1.0 References: <4eec5fa69b9daedcec5361c2cc18df7f1ef397af.camel@redhat.com> In-Reply-To: From: Mir Immad Date: Mon, 24 Jan 2022 01:41:33 +0530 Message-ID: Subject: Re: GSoC: Working on the static analyzer To: David Malcolm Cc: gcc@gcc.gnu.org X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, HTML_MESSAGE, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Jan 2022 20:11:48 -0000 Hi, sir. I've been trying to understand the static analyzer's code. I spent most of my time learning the state machine's API. I learned how state machine's on_stmt is supposed to "recognize" specific functions and how on_transition takes a specific tree from one state to another, and how the captured states are used by pending_diagnostics to report the errors. Furthermore, I was able to create a dummy checker that mimicked the behaviour of sm-file's double_fclose and compile GCC with these changes. Is this the right way of learning? As you've mentioned on the projects page that you would like to add more support for some POSIX APIs. Can you please write (or refer me to a) a simple C program that uses such an API (and also what the analyzer should have done) so that I can attempt to add such a checker to the analyzer. Also, I didn't realize the complexity of adding SARIF when I mentioned it. I'd rather work on adding more checkers. Regards. Mir Immad On Sun, Jan 23, 2022, 11:04 PM Mir Immad wrote: > Hi Sir, > > I've been trying to understand the static analyzer's code. I spent most of > my time learning the state machine's API. I learned how state machine's > on_stmt is supposed to "recognize" specific functions and takes a specific > tree from one state to another, and how the captured states are used by > pending_diagnostics to report the errors. Furthermore, I was able to create > a dummy checker that mimicked the behaviour of sm-file's double_fclose and > compile GCC with these changes. Is this the right way of learning? > > As you've mentioned on the projects page that you would like to add more > support for some POSIX APIs. Can you please write (or refer me to a) a > simple C program that uses such an API (and also what the analyzer should > have done) so that I can attempt to add such a checker to the analyzer. > > Also, I didn't realize the complexity of adding SARIF when I mentioned it. > I'd rather work on adding more checkers. > > Regards. > Mir Immad > > On Mon, Jan 17, 2022 at 5:41 AM David Malcolm wrote: > >> On Fri, 2022-01-14 at 22:15 +0530, Mir Immad wrote: >> > HI David, >> > I've been tinkering with the static analyzer for the last few days. I >> > find >> > the project of adding SARIF output to the analyzer intresting. I'm >> > writing >> > this to let you know that I'm trying to learn the codebase. >> > Thank you. >> >> Excellent. >> >> BTW, I think adding SARIF output would involve working more with GCC's >> diagnostics subsystem than with the static analyzer, since (in theory) >> all of the static analyzer's output is passing through the diagnostics >> subsystem - though the static analyzer is probably the only GCC >> component generating diagnostic paths. >> >> I'm happy to mentor such a project as I maintain both subsystems and >> SARIF output would benefit both - but it would be rather tangential to >> the analyzer - so if you had specifically wanted to be working on the >> guts of the analyzer itself, you may want to pick a different >> subproject. >> >> The SARIF standard is rather long and complicated, and we would want to >> be compatible with clang's implementation. >> >> It would be very cool if gcc could also accept SARIF files as an >> *input* format, and emit them as diagnostics; that might help with >> debugging SARIF output. (I have a old patch for adding JSON parsing >> support to GCC that could be used as a starting point for this). >> >> Hope the above makes sense >> Dave >> >> > >> > On Tue, Jan 11, 2022, 7:09 PM David Malcolm >> > wrote: >> > >> > > On Tue, 2022-01-11 at 11:03 +0530, Mir Immad via Gcc wrote: >> > > > Hi everyone, >> > > >> > > Hi, and welcome. >> > > >> > > > I intend to work on the static analyzer. Are these documents >> > > > enough to >> > > > get >> > > > started: https://gcc.gnu.org/onlinedocs/gccint and >> > > > >> > > >> https://gcc.gnu.org/onlinedocs/gccint/Analyzer-Internals.html#Analyzer-Internals >> > > >> > > Yes. >> > > >> > > There are also some high-level notes here: >> > > https://gcc.gnu.org/wiki/DavidMalcolm/StaticAnalyzer >> > > >> > > Also, given that the analyzer is part of GCC, the more general >> > > introductions to hacking on GCC will be useful. >> > > >> > > I recommend creating a trivial C source file with a bug in it (e.g. >> > > a >> > > 3-line function with a use-after-free), and stepping through the >> > > analyzer to get a sense of how it works. >> > > >> > > Hope this is helpful; don't hesitate to ask questions. >> > > Dave >> > > >> > > >> >> >>