From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8605 invoked by alias); 12 Aug 2011 14:55:23 -0000 Received: (qmail 8593 invoked by uid 22791); 12 Aug 2011 14:55:22 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from 8.mo5.mail-out.ovh.net (HELO mo5.mail-out.ovh.net) (178.32.116.78) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Aug 2011 14:55:05 +0000 Received: from mail98.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo5.mail-out.ovh.net (Postfix) with SMTP id CE2B9FF8AC1 for ; Fri, 12 Aug 2011 16:55:15 +0200 (CEST) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 12 Aug 2011 16:55:04 +0200 Received: from aannecy-651-1-65-169.w86-209.abo.wanadoo.fr (HELO ?192.168.1.6?) (piervit@pvittet.com@86.209.208.169) by ns0.ovh.net with SMTP; 12 Aug 2011 16:55:02 +0200 Message-ID: <4E453EC2.1030600@pvittet.com> Date: Fri, 12 Aug 2011 14:55:00 -0000 From: Pierre Vittet User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110705 Thunderbird/3.1.11 MIME-Version: 1.0 To: gcc@gcc.gnu.org, Basile Starynkevitch , Alexandre Lissy , patrick.martineau@univ-tours.fr X-Ovh-Mailout: 178.32.228.5 (mo5.mail-out.ovh.net) Subject: [GSOC] Customizable warnings with a GCC plugin Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Ovh-Tracer-Id: 4523302875983839305 X-Ovh-Remote: 86.209.208.169 (aannecy-651-1-65-169.w86-209.abo.wanadoo.fr) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -217 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfedvjedruddtucetggdotefuucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhlucfvnfffucdludefmdenthhhvgcuphhrohgslhgvmhculddqfedtmdenvhhoihgupdhinhhtucdlqddutddtmd X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg00251.txt.bz2 Hello, As the GSOC ending is approching, I tried on a real project (GNU Grub) the plugin that I am developping. This plugin allows the user to add warnings when compiling, depending of rules that he has previously written. Here is an exemple of possible rules : (testNull "grub_malloc") This means that when there is a call to function "grub_malloc", we will check that it is immediately followed by a condition, testing that what was returned by grub_malloc was (not) null. (testNull "grub_malloc") We also have operator testZero and test testNeg, allowing to work on functions that return int. We could also use such rule (event if it is quite unusual): (testNull "function_that_modify_first_arg" 1) It means that instead of testing that there is a condition on the result of the function, we test that there is a test on the first argument of the function. Using this feature has more sense with the following type of test: (testFollowedBy "grub_bufio_open" 0 "grub_bufio_close" 1) This means that in a function body, if you have a call to the function "grub_bufio_open", we will check that the returned variable (0) is later tested to be first argument (1) of a call to grub_bufio_close. There is also a testNotFollowedBy working the same way which emit a warning if the first function is followed by the second one. The last kind of test is "testImmediatlyFollowedBy" testing that a call to a function is immediatly followed by a call to another one, for exemple we might want to use : (testImmediatlyFollowedBy "chroot" 1 "chdir" 1) The plugin seems to return quite interesting warnings without to much false positives. False positives comes from several particular situations, for exemple for testFollowedBy, if you have someting like that: int myFunction(void) { void * myPtr = first_function_to_be_tested(); if(something does not works) { return ERROR; } second_function(myPtr); return 0; } It will return a warning as you can exit the function without running second_function. The problem is that it is more a design problem than a problem from the plugin. If you want to see the detail of my result when running a few tests on Grub, you can have a look on the grub mailing list : https://lists.gnu.org/archive/html/grub-devel/2011-08/msg00009.html . I would be glad to have your opinion on my plugin. Do you thing in can be really useful in real project ? Would you use it ? Have you idea of tests that we could run over GCC or another project ? I guess this can be a pretty good tools, but it needs to have clear coding standard in order to know what should be tested. For the moment, the plugin has only be tested on C code, this might works with only few changes for C++. It needed the following patchs http://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg13086.html which had been commited yesterday + some changes in MELT (the plugin is developped in MELT). Moreover as the plugin uses some newly added functionalities of MELT, it might be quite hard to use until the release of MELT 0.9 (which might be ready for the end of August). I have named the plugin Talpo, it means mole in esperanto, the idea is that we dig blindly into GCC finding the information we want, the project is available here : https://gitorious.org/talpo. I will focus on documentation and help next week. Thanks for your interest! Pierre Vittet