From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from fencepost.gnu.org (fencepost.gnu.org [IPv6:2001:470:142:3::e]) by sourceware.org (Postfix) with ESMTPS id 38A313858D35 for ; Thu, 5 Jan 2023 15:05:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38A313858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=Subject:From:To:MIME-Version:Date:in-reply-to: references; bh=fKg8qX6w+U0iNr+XNLZOYzDZvRIhJ2kxJYUj/J73yVI=; b=AIUqRlEOIkXYL3 qvdHkz1jSQLOLfnZ2KtRm5maVxtwRn3D46PF82CfoFCbcn8d8Dxh3PYpv/hLsMj/zBpi/qm4myJ9u fbjoZ/0KcgiRkqqtc4DddCVpsGWfpsejJykeIt8+On7a+kDQf4abbPn62r95Wqmj6rpBjBFABnEj5 Knsj4Chp3rgD3f1JnL8LjoFVvjT3h6rDg5DgHFkeHTSOGFPVzmdwtY/6qBSAvRTEHwRfTcxdAYjwG g3Yu3JvdSHKOZI0GBuHu+K9/EfI4JgHdnn80FAwTBXnsdNxzmfz/vFU+RKhXL5bv3CljGYMTsoBky G78ZzorIXqkIAltcRaiA==; Received: from ip5f5a8893.dynamic.kabel-deutschland.de ([95.90.136.147] helo=[192.168.111.41]) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDRoE-0005q0-A6 for gcc-help@gcc.gnu.org; Thu, 05 Jan 2023 10:05:34 -0500 Message-ID: Date: Thu, 5 Jan 2023 16:05:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 To: gcc-help@gcc.gnu.org Content-Language: en-US From: Simon Sobisch Subject: Is it possible to insert own "function points" via define in code (similar to #line), especially for --coverage? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,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: We can do something like gcc --coverage some.c and then get the function information after running it with gcov. This works fine with "plain C", but when executing generated code you're out of luck. Most easy example: bison it generates relevant #line directives to "switch" between parser.y and parser.c. Inspecting parser.c shows many functions "commonly not interesting" (like bison generated state functions), so these generated files are often ignored / excluded. Inspecting parser.y shows all the functions that are defined "directly" in the parser.y file (within the %{} block), but it doesn't show any of the most interesting terminals. The idea is to insert something like { #function push #function my-important-terminal code here #function pop } and then have gcov consider this part "as if it has been a function". For a similar case, related to profiling, I've only found the option to make the C code non-portable by inserting nested functions here (I haven't checked yet, but guess gcov and lcov would handle those similar to gdb/perf/...); but maybe there is something "general" that can be used instead. Any insights / ideas? Thanks a lot, Simon