From d07a59a5ca830bf74705471f6bea6db1a47da2b5 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 7 Mar 2025 06:42:18 +0800 Subject: gprof: Copy a simple test from glibc Copy a simple gprof test from glibc to test the basic gprof functionality. 1. Tested natively on Linux/x86-64 and Linux/i686. 2. Tested for the x86_64-solaris cross target without cross-compiler. 3. Tested for the aarch64-linux-gnu cross target with cross-compiler. PR gprof/32764 * Makefile.am (SUBDIRS): Add testsuite * configure.ac (AC_CONFIG_FILES): Removed. (AC_OUTPUT): Add Makefile testsuite/Makefile po/Makefile.in:po/Make-in. (AM_CONDITIONAL): Add NATIVE. * Makefile.in: Regenerated. * configure: Likewise. * testsuite/Makefile.am: New file. * testsuite/tst-gmon-gprof.sh: Likewise. * testsuite/tst-gmon.c: Likewise. * testsuite/Makefile.in: Generated. Signed-off-by: H.J. Lu --- gprof/testsuite/tst-gmon.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 gprof/testsuite/tst-gmon.c (limited to 'gprof/testsuite/tst-gmon.c') diff --git a/gprof/testsuite/tst-gmon.c b/gprof/testsuite/tst-gmon.c new file mode 100644 index 0000000..add2d92 --- /dev/null +++ b/gprof/testsuite/tst-gmon.c @@ -0,0 +1,55 @@ +/* Test program for profiling information collection (_mcount/gprof). + Copyright (C) 2017-2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +/* This program does not use the test harness because we want tight + control over the call graph. */ + +__attribute__ ((weak)) +void +f1 (void) +{ +} + +__attribute__ ((weak)) +void +f2 (void) +{ + f1 (); + /* Prevent tail call. */ + asm volatile (""); +} + +__attribute__ ((weak)) +void +f3 (int count) +{ + for (int i = 0; i < count; ++i) + { + f1 (); + f2 (); + } +} + +int +main (void) +{ + f3 (1000); + return 0; +} -- cgit v1.1