From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id 938903858C50 for ; Fri, 17 Mar 2023 23:34:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 938903858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32HM0XnV016391 for ; Fri, 17 Mar 2023 23:34:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=5g2HPxf1o8HbCN30xrn88tL7txwC6FqPycC4WUA2BqY=; b=WUvhBhY46i3g1t68OYwwtpOL7W6q+T375/8jP84Weub3Ge0s9vsXcFSiwgcJUKPjfZ6P vhLpUvJQdp6Ge8T4aIjAUASI8iYf5KqroA6G4ydz6t8Y6N3M4Tj1nfP5PmHeOepiXwRQ ETG6ad7RLe7Pym7sTUuq0PqtiN+0/9wkuQQTijEIee3g8/cw2Y75E7ZX+pRnmoUDm8XY fGCkunZg9lu0ubMypakk9/CD1cfFiRM5u0wc/PDiteSdybKECJ2T142uO0j+0dBeZtvD UnAqD9txAPCqggJ/SGbiwZ9REW9MOy8F10jw0jnJgKePnP63VARDzz4FL8lfBQfaySdI bQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pcthk11kq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 17 Mar 2023 23:34:58 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 32HLrIxo002449 for ; Fri, 17 Mar 2023 23:34:58 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2108.outbound.protection.outlook.com [104.47.55.108]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3pbq48ds4v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 17 Mar 2023 23:34:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ph+rSA4JEQzIE3+qQTV3htejixLXokpON4KS/xO0dkBTrlfAzl48y1PnPCpGdnHJUgHu0dh910AheYvKNh/cxZ4095p6QYquTEUowTr5rLJuS7Swm+KOp9GKWhEpM7lkjaFtxAbbZkF6F6pLslRMzy6LNEeyDl24UbBSGF2Xabc4IfV+J4q6CrdhS/klZbw37LBDfC3JUoje87668WhGSs/TS1Cc9RJsiUZYrf0H7ySPu6fNNLWsfBi3Se50Qmzr8kMXSlTK1qtYZ1BnEtU9bcGJuwmNeBxD8Bn5VO5776gbdIkLQYep7ikkRoXNINCjUfCA5e4QIMqk4fpPKeMK8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5g2HPxf1o8HbCN30xrn88tL7txwC6FqPycC4WUA2BqY=; b=Zou9ckd+ygmslD1jprUhRy1A0ZNlpqy7mZEufAN4IU8WjXdv8EhfSVYkvg+cW5p+GNYEd1TehqRM4AnvonoptuPM2YgmLkvkjxyAmbrX+HdAQtuPCThgqGjS50xMCs6JCSLT+cUlTcy+RPJH0ilAp+yX7J3jT2xhOpFIvixGc8VAvnMpMlR9Wi9NMpR95g7Rqc4Y2hMxk/7pJhXWFXfSdJBCKUS97wqWZJB1LnNWeWX17VtV24njo1UYKn0ChIMC5ZdCWQYPr+M4c8eNTialWjPNkafL31ydSusQBUpWEJ8y6Q0/8NHGWFMgTAFLVd1NqX1ytIWiCk40uYQTlt4cQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5g2HPxf1o8HbCN30xrn88tL7txwC6FqPycC4WUA2BqY=; b=XnkXhyJsaDX4XYMj7KTul/AMamtvJSEJc12+xoXpa8iM+h9BZj2CSLRTpCJyuOpq13trr0pa22UqyCAGPgBES8PGIosuKiVO/WPMyFbRlhYtte0aNv4GcGoyHBbbF3mQ7SdAqnwCf8bVBQdRxwt3Blf3CIoD5wygqnbcH3N42N4= Received: from SA2PR10MB4636.namprd10.prod.outlook.com (2603:10b6:806:11e::10) by SJ0PR10MB4608.namprd10.prod.outlook.com (2603:10b6:a03:2d4::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.33; Fri, 17 Mar 2023 23:34:55 +0000 Received: from SA2PR10MB4636.namprd10.prod.outlook.com ([fe80::534c:a39:4701:8319]) by SA2PR10MB4636.namprd10.prod.outlook.com ([fe80::534c:a39:4701:8319%5]) with mapi id 15.20.6178.035; Fri, 17 Mar 2023 23:34:55 +0000 From: vladimir.mezentsev@oracle.com To: binutils@sourceware.org Cc: Vladimir Mezentsev Subject: [Review is neded] gprofng: Use prototype to call libc functions Date: Fri, 17 Mar 2023 16:34:48 -0700 Message-Id: <20230317233448.1832535-1-vladimir.mezentsev@oracle.com> X-Mailer: git-send-email 2.31.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0P220CA0004.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::9) To SA2PR10MB4636.namprd10.prod.outlook.com (2603:10b6:806:11e::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PR10MB4636:EE_|SJ0PR10MB4608:EE_ X-MS-Office365-Filtering-Correlation-Id: 750e0eec-8911-494b-d9c9-08db274036a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: doUVL0rJYlhhPEq4LtR246qm4UZgZEk6lf5YcLmlbk6Km5fWKOMg5LJg9xQ2xgw+k1HKljltmtY71K6r2rWXns3VjAca2hVhggEWAETIJ3nXTRtkatm1n3mL28/SUIOC5HlWBRZbUg00Wc1c3nh/wub4J0e0r2uBMklz4oijIDV1CHJGYBzonXpD0YAEFFdxoT3e4Tw7dc7PciDVnH14ncSkJRkJ/wCXYo9Xi7gU3QkMuBTv8sQ+5RddIFJkYo1T8mOWAKci9ZoR2lxz7XppUnWpR2hEWOSeZwBdCZZoN/ylu489GgxziRxpVUgQ+5VkFmtVl8lfrv/r8U6kFAvTJCkH6gESqME4dre801hX/5+eJDJHTyjX6GHjTFod6gdDYGTng6Yr8aOaHBXMzFaP3HJ6v0i++WgKcL9WlNAipDlEtxXlemUPcayxQavCHiYFBd+Wh18H1UJw080QJCXFg9FqJqxwJKdW9/V1pFyrg170izpPYns5Bq5erTx7ZZK/ubhLkfXVRYKXhYaU7CETEwJia9L3DcRWCSgRpWme2aBPYVfvvjQ9XVrsHUZG2GJp0u96J6L8d1V2ViJGsSCxzdQ5D5Ls3CBKwZQYAvsGCAr9Xob5x0kJI4M4PVqiZv37byl7PeZbQfzszTauO1y5IA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA2PR10MB4636.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199018)(38100700002)(66946007)(66556008)(6916009)(8676002)(66476007)(4326008)(41300700001)(316002)(8936002)(83380400001)(478600001)(2616005)(5660300002)(30864003)(6512007)(26005)(1076003)(9686003)(6506007)(36756003)(6666004)(107886003)(186003)(86362001)(6486002)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?NiWvM7cnm+YEwb1D24AUgkW08L3cL9aeq8Xmykuj4DRC7xd19C8kqpyTK+2a?= =?us-ascii?Q?PQ3xzzJziGQDvoGloIrgTCaopaXD7e4fFFz5vDiSFwC15yAFsSkAXkJweidP?= =?us-ascii?Q?xMOn/MiY60VLVxxrM6HfDyFmEOy/ClpflWieHbHXhXDdSZtj1LqpKnIkag1t?= =?us-ascii?Q?OWeZS/S49oD7qFKNZxXvmFCQ8aTdS8kP17jWeRQHJtF/QxXUqLGEqK2JE0Ku?= =?us-ascii?Q?SFH+HcOtMDkRVZl2srQaYtSEMsYRpAXfAYWjhWqeWNvq2TIqBl8qJcYdzSe8?= =?us-ascii?Q?9j4e+Xiiz+pZET7GfjRf+uBI0rLjV7N7X6Ke7XHk1YhHKC71zlm6iddWnUgb?= =?us-ascii?Q?9MlGBZ0Lq1SKDQHwRcNlnGQKKKQxrb0HtpPDGFZ/vBgEIMLaU/XpdiTe5v/d?= =?us-ascii?Q?TcOAk1MZK+hxbrPjiRKZ3H3vTQm9qvqjgs/SicXH/a+gTdtVrGmTpVrdKmIn?= =?us-ascii?Q?lUGtD3z48mCM+dmg7UA/Qe7jCCRdxgka/4zcCu0WHdE6RJkciY9fEd7L2DCD?= =?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00JjAPXv6HkpJYsZnYaMdDFysNDpgwmgZYWbRPzI0ej7Z/XKFN1u7ChTywJJCkhhWGP118Ugwg717OPHF1Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 750e0eec-8911-494b-d9c9-08db274036a1 X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4636.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2023 23:34:55.3054 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Lw4Js7/XVYKcygGdG9SfpZUQqVJaoX7zo95Nw15Nb0pMLw9ZD92LZyLzGZq5H3AfwVzkq0PMTEFCk+ym8pPe3LuVPZuN9zCVeC78/oETBHY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4608 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-17_17,2023-03-16_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 phishscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303170169 X-Proofpoint-ORIG-GUID: pt0b2_urbYAU3wF_6tfaT8fDjSiDf3aC X-Proofpoint-GUID: pt0b2_urbYAU3wF_6tfaT8fDjSiDf3aC X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,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: From: Vladimir Mezentsev libcollector may not link against libC. We use dlsym() to get a function from libc. In some files, pointers to these functions do not have prototypes. I also moved the shared definitions to libcollector/collect.h. gprofng/ChangeLog 2023-03-15 Vladimir Mezentsev libcollector/collector.c: Add prototypes. libcollector/dispatcher.c: Likewise. libcollector/heaptrace.c: Likewise. libcollector/iotrace.c: Likewise. libcollector/linetrace.c: Likewise. libcollector/mmaptrace.c: Likewise. libcollector/synctrace.c: Likewise. libcollector/collector.h: Add CALL_REAL(), NULL_PTR(), and DBG_LT. --- gprofng/libcollector/collector.c | 13 +--- gprofng/libcollector/collector.h | 13 ++++ gprofng/libcollector/dispatcher.c | 67 ++++++++-------- gprofng/libcollector/heaptrace.c | 19 +---- gprofng/libcollector/iotrace.c | 17 ---- gprofng/libcollector/linetrace.c | 125 +++++++++++++++++------------- gprofng/libcollector/mmaptrace.c | 10 --- gprofng/libcollector/synctrace.c | 60 +++++++------- 8 files changed, 150 insertions(+), 174 deletions(-) diff --git a/gprofng/libcollector/collector.c b/gprofng/libcollector/collector.c index 55c52548b4e..df493658df9 100644 --- a/gprofng/libcollector/collector.c +++ b/gprofng/libcollector/collector.c @@ -37,12 +37,6 @@ #include "cc_libcollector.h" #include "tsd.h" -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 - typedef unsigned long ulong_t; extern char **environ; @@ -2455,11 +2449,8 @@ __collector_dlog (int tflag, int level, char *format, ...) */ /*------------------------------------------------------------- _exit */ -#define CALL_REAL(x) (*(int(*)())__real_##x) -#define NULL_PTR(x) ( __real_##x == NULL ) - -static void *__real__exit = NULL; /* libc only: _exit */ -static void *__real__Exit = NULL; /* libc only: _Exit */ +static void (*__real__exit) (int status) = NULL; /* libc only: _exit */ +static void (*__real__Exit) (int status) = NULL; /* libc only: _Exit */ void _exit () __attribute__ ((weak, alias ("__collector_exit"))); void _Exit () __attribute__ ((weak, alias ("__collector_Exit"))); diff --git a/gprofng/libcollector/collector.h b/gprofng/libcollector/collector.h index d771cf1d07a..77957ec537d 100644 --- a/gprofng/libcollector/collector.h +++ b/gprofng/libcollector/collector.h @@ -29,6 +29,8 @@ #include "collector_module.h" #define GETRELTIME() (__collector_gethrtime() - __collector_start_time) +#define CALL_REAL(x) (__real_##x) +#define NULL_PTR(x) (__real_##x == NULL) #if defined(__MUSL_LIBC) #define dlvsym(f, nm, v) dlsym (f, nm) @@ -171,6 +173,17 @@ enum SP_DUMP_STACK = 32, }; +/* TprintfT(,...) definitions. Adjust per module as needed */ +enum +{ + DBG_LT0 = 0, // for high-level configuration, unexpected errors/warnings + DBG_LTT = 0, // for interposition on GLIBC functions + DBG_LT1 = 1, // for configuration details, warnings + DBG_LT2 = 2, + DBG_LT3 = 3, + DBG_LT4 = 4 +}; + #ifndef DEBUG #define DprintfT(flag, ...) #define tprintf(...) diff --git a/gprofng/libcollector/dispatcher.c b/gprofng/libcollector/dispatcher.c index 0075f232cc8..5c5a06ec1b4 100644 --- a/gprofng/libcollector/dispatcher.c +++ b/gprofng/libcollector/dispatcher.c @@ -41,18 +41,10 @@ #include "collector_module.h" #include "tsd.h" #include "hwcdrv.h" - - -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LTT 0 // for interposition on GLIBC functions -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 +#include "memmgr.h" static void collector_sigprof_dispatcher (int, siginfo_t*, void*); static int init_interposition_intf (); -#include "memmgr.h" static int collector_timer_create (timer_t * ptimerid); static int collector_timer_settime (int period, timer_t timerid); static int collector_timer_gettime (timer_t timerid); @@ -61,20 +53,28 @@ static timer_t collector_master_thread_timerid = NULL; static collector_mutex_t collector_clone_libc_lock = COLLECTOR_MUTEX_INITIALIZER; static unsigned dispatcher_key = COLLECTOR_TSD_INVALID_KEY; -static void *__real_clone = NULL; -static void *__real_timer_create = NULL; -static void *__real_timer_settime = NULL; -static void *__real_timer_delete = NULL; -static void *__real_timer_gettime = NULL; +static int (*__real_clone) (int (*fn)(void *), void *child_stack, int flags, + void *arg, ...) = NULL; +static int (*__real_timer_create) (clockid_t clockid, + struct sigevent *sevp, timer_t *timerid) = NULL; +static int (*__real_timer_settime) (timer_t timerid, int flags, + const struct itimerspec *new_value, + struct itimerspec *old_value) = NULL; +static int (*__real_timer_delete) (timer_t timerid) = NULL; +static int (*__real_timer_gettime) (timer_t timerid, + struct itimerspec *curr_value) = NULL; #if ARCH(Intel) && WSIZE(32) -static void *__real_pthread_create_2_1 = NULL; -static void *__real_pthread_create_2_0 = NULL; +static int (*__real_pthread_create_2_1) (pthread_t *thread, + const pthread_attr_t *attr, + void *(*start_routine) (void *), void *arg) = NULL; +static int (*__real_pthread_create_2_0) (pthread_t *thread, + const pthread_attr_t *attr, + void *(*start_routine) (void *), void *arg) = NULL; #elif ARCH(Intel) && WSIZE(64) -static void *__real_timer_create_2_3_3 = NULL; -static void *__real_timer_create_2_2_5 = NULL; -#elif ARCH(SPARC) && WSIZE(64) -static void *__real_timer_create_2_3_3 = NULL; -static void *__real_timer_create_2_2 = NULL; +static int (*__real_timer_create_2_3_3) (clockid_t clockid, + struct sigevent *sevp, timer_t *timerid) = NULL; +static int (*__real_timer_create_2_2_5) (clockid_t clockid, + struct sigevent *sevp, timer_t *timerid) = NULL; #endif /* Original SIGPROF handler which will be replaced with the dispatcher. Used @@ -93,16 +93,21 @@ static int dispatch_mode = DISPATCH_NYI; /* controls SIGPROF dispatching */ static int itimer_period_requested = 0; /* dispatcher itimer period */ static int itimer_period_actual = 0; /* actual dispatcher itimer period */ -#define CALL_REAL(x) (*(int(*)())__real_##x) -#define NULL_PTR(x) ( __real_##x == NULL ) - -static void *__real_sigaction = NULL; -static void *__real_setitimer = NULL; -static void *__real_libc_setitimer = NULL; -static void *__real_sigprocmask = NULL; -static void *__real_thr_sigsetmask = NULL; -static void *__real_pthread_sigmask = NULL; -static void *__real_pthread_create = NULL; +static int (*__real_sigaction) (int signum, const struct sigaction *act, + struct sigaction *oldact) = NULL; +static int (*__real_setitimer) (int which, const struct itimerval *new_value, + struct itimerval *old_value) = NULL; +static int (*__real_libc_setitimer) (int which, + const struct itimerval *new_value, struct itimerval *old_value) = NULL; +static int (*__real_sigprocmask) (int how, const sigset_t *set, + sigset_t *oldset) = NULL; +static int (*__real_thr_sigsetmask) (int how, const sigset_t *iset, + sigset_t *oset) = NULL; +static int (*__real_pthread_sigmask) (int how, const sigset_t *set, + sigset_t *oldset) = NULL; +static int (*__real_pthread_create) (pthread_t *thread, + const pthread_attr_t *attr, + void *(*start_routine) (void *), void *arg) = NULL; /* * void collector_sigprof_dispatcher() diff --git a/gprofng/libcollector/heaptrace.c b/gprofng/libcollector/heaptrace.c index 387d2a13c00..b51ab330ba6 100644 --- a/gprofng/libcollector/heaptrace.c +++ b/gprofng/libcollector/heaptrace.c @@ -26,18 +26,11 @@ #include #include "gp-defs.h" -#include "collector_module.h" +#include "collector.h" #include "gp-experiment.h" #include "data_pckts.h" #include "tsd.h" -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 -#define DBG_LT4 4 - /* define the packets to be written out */ typedef struct Heap_packet { /* Malloc/free tracing packet */ @@ -73,18 +66,8 @@ static unsigned heap_key = COLLECTOR_TSD_INVALID_KEY; #define CHCK_REENTRANCE(x) ( !heap_mode || ((x) = collector_interface->getKey( heap_key )) == NULL || (*(x) != 0) ) #define PUSH_REENTRANCE(x) ((*(x))++) #define POP_REENTRANCE(x) ((*(x))--) -#define CALL_REAL(x) (__real_##x) -#define NULL_PTR(x) (__real_##x == NULL) #define gethrtime collector_interface->getHiResTime -#ifdef DEBUG -#define Tprintf(...) if (collector_interface) collector_interface->writeDebugInfo( 0, __VA_ARGS__ ) -#define TprintfT(...) if (collector_interface) collector_interface->writeDebugInfo( 1, __VA_ARGS__ ) -#else -#define Tprintf(...) -#define TprintfT(...) -#endif - static void *(*__real_malloc)(size_t) = NULL; static void (*__real_free)(void *); static void *(*__real_realloc)(void *, size_t); diff --git a/gprofng/libcollector/iotrace.c b/gprofng/libcollector/iotrace.c index d8439b02b3a..303e755df6e 100644 --- a/gprofng/libcollector/iotrace.c +++ b/gprofng/libcollector/iotrace.c @@ -39,12 +39,6 @@ #include "data_pckts.h" #include "tsd.h" -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LTT 0 // for interposition on GLIBC functions -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 /* define the packet that will be written out */ typedef struct IOTrace_packet @@ -88,19 +82,8 @@ static unsigned io_key = COLLECTOR_TSD_INVALID_KEY; #define RECHCK_REENTRANCE(x) (!io_mode || ((x) = collector_interface->getKey( io_key )) == NULL || (*(x) == 0)) #define PUSH_REENTRANCE(x) ((*(x))++) #define POP_REENTRANCE(x) ((*(x))--) - -#define CALL_REAL(x) (__real_##x) -#define NULL_PTR(x) (__real_##x == NULL) - #define gethrtime collector_interface->getHiResTime -#ifdef DEBUG -#define Tprintf(...) if (collector_interface) collector_interface->writeDebugInfo( 0, __VA_ARGS__ ) -#define TprintfT(...) if (collector_interface) collector_interface->writeDebugInfo( 1, __VA_ARGS__ ) -#else -#define Tprintf(...) -#define TprintfT(...) -#endif /* interposition function handles */ static int (*__real_open)(const char *path, int oflag, ...) = NULL; diff --git a/gprofng/libcollector/linetrace.c b/gprofng/libcollector/linetrace.c index 66241ac1f53..fd8e54a7973 100644 --- a/gprofng/libcollector/linetrace.c +++ b/gprofng/libcollector/linetrace.c @@ -30,17 +30,10 @@ #include #include #include - +#include #include "descendants.h" -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LTT 0 // for interposition on GLIBC functions -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 - #define LT_MAXNAMELEN 1024 #define LT_MAXPATHLEN 1024 @@ -63,51 +56,77 @@ static int line_initted = 0; static collector_mutex_t fork_lineage_lock = COLLECTOR_MUTEX_INITIALIZER; static collector_mutex_t clone_lineage_lock = COLLECTOR_MUTEX_INITIALIZER; -/* interposition */ -#define CALL_REAL(x) (*(int(*)())__real_##x) -#define CALL_REALC(x) (*(char*(*)())__real_##x) -#define CALL_REALF(x) (*(FILE*(*)())__real_##x) -#define NULL_PTR(x) ( __real_##x == NULL ) - // For a given Linux, which lib functions have more than one GLIBC version? Do this: // objdump -T `find /lib /lib64 -name "*.so*"` | grep GLIBC | grep text | grep \( -static void *__real_fork = NULL; -static void *__real_vfork = NULL; -static void *__real_execve = NULL; -static void *__real_execvp = NULL; -static void *__real_execv = NULL; -static void *__real_execle = NULL; -static void *__real_execlp = NULL; -static void *__real_execl = NULL; -static void *__real_clone = NULL; -static void *__real_grantpt = NULL; -static void *__real_ptsname = NULL; -static void *__real_popen = NULL; +static pid_t (*__real_fork) (void) = NULL; +static pid_t (*__real_vfork) (void) = NULL; +static int (*__real_execve) (const char *file, char *const argv[], + char *const envp[]) = NULL; +static int (*__real_execvp) (const char *file, char *const argv[]) = NULL; +static int (*__real_execv) (const char *file, char *const argv[]) = NULL; +static int (*__real_execle) (const char *path, const char *arg, ...) = NULL; +static int (*__real_execlp) (const char *file, const char *arg, ...) = NULL; +static int (*__real_execl) (const char *file, const char *arg, ...) = NULL; +static int (*__real_clone) (int (*fn) (void *), void *child_stack, + int flags, void *arg, ...) = NULL; +static int (*__real_grantpt) (int fd) = NULL; +static char *(*__real_ptsname) (int fd) = NULL; +static FILE *(*__real_popen) (const char *command, const char *type) = NULL; static int clone_linenum = 0; #if ARCH(Intel) #if WSIZE(32) -static void *__real_popen_2_1 = NULL; -static void *__real_popen_2_0 = NULL; -static void *__real_posix_spawn_2_15 = NULL; -static void *__real_posix_spawnp_2_15 = NULL; -static void *__real_posix_spawn_2_2 = NULL; -static void *__real_posix_spawnp_2_2 = NULL; +static FILE *(*__real_popen_2_1) (const char *command, const char *type) = NULL; +static FILE *(*__real_popen_2_0) (const char *command, const char *type) = NULL; +static int (*__real_posix_spawn_2_15) (pid_t *pid, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawn_2_2) (pid_t *pid, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawnp_2_15) (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawnp_2_2) (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; #elif WSIZE(64) -static void *__real_posix_spawn_2_15 = NULL; -static void *__real_posix_spawnp_2_15 = NULL; -static void *__real_posix_spawn_2_2_5 = NULL; -static void *__real_posix_spawnp_2_2_5 = NULL; +static int (*__real_posix_spawn_2_15) (pid_t *pid, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawn_2_2_5) (pid_t *pid, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawnp_2_15) (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawnp_2_2_5) (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; #endif /* WSIZE() */ #endif /* ARCH(Intel) */ -static void *__real_system = NULL; -static void *__real_posix_spawn = NULL; -static void *__real_posix_spawnp = NULL; -static void *__real_setuid = NULL; -static void *__real_seteuid = NULL; -static void *__real_setreuid = NULL; -static void *__real_setgid = NULL; -static void *__real_setegid = NULL; -static void *__real_setregid = NULL; +static int (*__real_system) (const char *command) = NULL; +static int (*__real_posix_spawn) (pid_t *pid, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawnp) (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_setuid) (uid_t uid) = NULL; +static int (*__real_seteuid) (uid_t euid) = NULL; +static int (*__real_setreuid) (uid_t ruid, uid_t euid) = NULL; +static int (*__real_setgid) (gid_t gid) = NULL; +static int (*__real_setegid) (gid_t egid) = NULL; +static int (*__real_setregid) (gid_t rgid, gid_t egid)= NULL; static void linetrace_dormant (); static int check_follow_fork (); static int check_follow_exec (const char *execfile); @@ -1604,7 +1623,7 @@ __collector_popen_2_1 (const char *cmd, const char *mode) if (NULL_PTR (popen)) init_lineage_intf (); TprintfT (DBG_LTT, "linetrace: GLIBC: __collector_popen_2_1@%p\n", CALL_REAL (popen_2_1)); - return __collector_popen_symver (CALL_REALF (popen_2_1), cmd, mode); + return __collector_popen_symver (CALL_REAL (popen_2_1), cmd, mode); } SYMVER_ATTRIBUTE (__collector_popen_2_0, popen@GLIBC_2.0) @@ -1614,7 +1633,7 @@ __collector_popen_2_0 (const char *cmd, const char *mode) if (NULL_PTR (popen)) init_lineage_intf (); TprintfT (DBG_LTT, "linetrace: GLIBC: __collector_popen_2_0@%p\n", CALL_REAL (popen_2_0)); - return __collector_popen_symver (CALL_REALF (popen_2_0), cmd, mode); + return __collector_popen_symver (CALL_REAL (popen_2_0), cmd, mode); } SYMVER_ATTRIBUTE (__collector__popen_2_1, _popen@GLIBC_2.1) @@ -1624,7 +1643,7 @@ __collector__popen_2_1 (const char *cmd, const char *mode) if (NULL_PTR (popen)) init_lineage_intf (); TprintfT (DBG_LTT, "linetrace: GLIBC: __collector__popen_2_1@%p\n", CALL_REAL (popen_2_1)); - return __collector_popen_symver (CALL_REALF (popen_2_1), cmd, mode); + return __collector_popen_symver (CALL_REAL (popen_2_1), cmd, mode); } SYMVER_ATTRIBUTE (__collector__popen_2_0, _popen@GLIBC_2.0) @@ -1633,7 +1652,7 @@ __collector__popen_2_0 (const char *cmd, const char *mode) { if (NULL_PTR (popen)) init_lineage_intf (); - return __collector_popen_symver (CALL_REALF (popen_2_0), cmd, mode); + return __collector_popen_symver (CALL_REAL (popen_2_0), cmd, mode); } #else // WSIZE(64) FILE * popen () __attribute__ ((weak, alias ("__collector_popen"))); @@ -1662,7 +1681,7 @@ __collector_popen (const char *cmd, const char *mode) #if ARCH(Intel) && WSIZE(32) return (real_popen) (cmd, mode); #else - return CALL_REALF (popen)(cmd, mode); + return CALL_REAL (popen)(cmd, mode); #endif } int following_combo = 0; @@ -1671,7 +1690,7 @@ __collector_popen (const char *cmd, const char *mode) #if ARCH(Intel) && WSIZE(32) ret = (real_popen) (cmd, mode); #else - ret = CALL_REALF (popen)(cmd, mode); + ret = CALL_REAL (popen)(cmd, mode); #endif POP_REENTRANCE (guard); linetrace_ext_combo_epilogue ("popen", (ret == NULL) ? (-1) : 0, &following_combo); @@ -1718,11 +1737,11 @@ __collector_ptsname (const int fildes) if (line_mode == LM_TRACK_LINEAGE) INIT_REENTRANCE (guard); if (guard == NULL) - return CALL_REALC (ptsname)(fildes); + return CALL_REAL (ptsname)(fildes); int following_combo = 0; linetrace_ext_combo_prologue ("ptsname", "/usr/lib/pt_chmod", &following_combo); PUSH_REENTRANCE (guard); - char *ret = CALL_REALC (ptsname)(fildes); + char *ret = CALL_REAL (ptsname)(fildes); POP_REENTRANCE (guard); linetrace_ext_combo_epilogue ("ptsname", (ret == NULL) ? (-1) : 1, &following_combo); return ret; diff --git a/gprofng/libcollector/mmaptrace.c b/gprofng/libcollector/mmaptrace.c index 221b4e2d176..c46dac4e0aa 100644 --- a/gprofng/libcollector/mmaptrace.c +++ b/gprofng/libcollector/mmaptrace.c @@ -61,13 +61,6 @@ typedef struct prmap_t int pr_pagesize; /* pagesize (bytes) for this mapping */ } prmap_t; -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 -#define DBG_LT4 4 - #define SYS_MMAP_NAME "mmap" #define SYS_MMAP64_NAME "mmap64" #define SYS_MUNMAP_NAME "munmap" @@ -113,9 +106,6 @@ static int reentrance = 0; #define PUSH_REENTRANCE reentrance++ #define POP_REENTRANCE reentrance-- -#define CALL_REAL(x) (__real_##x) -#define NULL_PTR(x) (__real_##x == NULL) - /* interposition function handles */ static void *(*__real_mmap)(void* start, size_t length, int prot, int flags, int fd, off_t offset) = NULL; diff --git a/gprofng/libcollector/synctrace.c b/gprofng/libcollector/synctrace.c index cbe4e46533d..c50151bbd52 100644 --- a/gprofng/libcollector/synctrace.c +++ b/gprofng/libcollector/synctrace.c @@ -38,13 +38,6 @@ #include "tsd.h" #include "cc_libcollector.h" -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LTT 0 // for interposition on GLIBC functions -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 - /* define the packet that will be written out */ typedef struct Sync_packet { /* Synchronization delay tracing packet */ @@ -88,19 +81,8 @@ static int init_thread_intf_finished = 0; #define RECHCK_JREENTRANCE(x) (!sync_java || !sync_mode || ((x) = collector_interface->getKey( sync_key )) == NULL || (*(x) == 0)) #define PUSH_REENTRANCE(x) ((*(x))++) #define POP_REENTRANCE(x) ((*(x))--) - -#define CALL_REAL(x) (*(int(*)())__real_##x) -#define NULL_PTR(x) ( __real_##x == NULL ) #define gethrtime collector_interface->getHiResTime -#ifdef DEBUG -#define Tprintf(...) if (collector_interface) collector_interface->writeDebugInfo( 0, __VA_ARGS__ ) -#define TprintfT(...) if (collector_interface) collector_interface->writeDebugInfo( 1, __VA_ARGS__ ) -#else -#define Tprintf(...) -#define TprintfT(...) -#endif - /* * In most cases, the functions which require interposition are implemented as * weak symbols corresponding to an associated internal function named with a @@ -109,26 +91,36 @@ static int init_thread_intf_finished = 0; * is distinct from the internal version (used by system libraries), i.e., * cond_wait() is an alias for _cond_wait_cancel() rather than _cond_wait(). */ -static void *__real_strtol = NULL; -static void *__real_fprintf = NULL; -static void *__real___collector_jprofile_enable_synctrace = NULL; -static void *__real_pthread_mutex_lock = NULL; -static void *__real_pthread_mutex_unlock = NULL; /* not interposed, used in calibrate */ -static void *__real_pthread_cond_wait = NULL; -static void *__real_pthread_cond_timedwait = NULL; -static void *__real_pthread_join = NULL; -static void *__real_sem_wait = NULL; -static void *__real_pthread_cond_wait_2_3_2 = NULL; -static void *__real_pthread_cond_timedwait_2_3_2 = NULL; +static long int (*__real_strtol)(const char *nptr, char **endptr, int base) = NULL; +static int (*__real_fprintf) (FILE *stream, const char *format, ...) = NULL; +static void (*__real___collector_jprofile_enable_synctrace) (void) = NULL; +static int (*__real_pthread_mutex_lock) (pthread_mutex_t *mutex) = NULL; +static int (*__real_pthread_mutex_unlock) (pthread_mutex_t *mutex) = NULL; +static int (*__real_pthread_cond_wait) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex) = NULL; +static int (*__real_pthread_cond_timedwait) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime) = NULL; +static int (*__real_pthread_join) (pthread_t thread, void **retval) = NULL; +static int (*__real_sem_wait) (sem_t *sem) = NULL; +static int (*__real_pthread_cond_wait_2_3_2) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex) = NULL; +static int (*__real_pthread_cond_timedwait_2_3_2) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime) = NULL; #if WSIZE(32) -static void *__real_sem_wait_2_1 = NULL; -static void *__real_sem_wait_2_0 = NULL; -static void *__real_pthread_cond_wait_2_0 = NULL; -static void *__real_pthread_cond_timedwait_2_0 = NULL; +static int (*__real_sem_wait_2_1) (sem_t *sem) = NULL; +static int (*__real_sem_wait_2_0) (sem_t *sem) = NULL; +static int (*__real_pthread_cond_wait_2_0) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex) = NULL; +static int (*__real_pthread_cond_timedwait_2_0) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime) = NULL; #elif WSIZE(64) #if ARCH(Intel) -static void *__real_pthread_cond_wait_2_2_5 = NULL; +static int (*__real_pthread_cond_wait_2_2_5) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex) = NULL; static void *__real_pthread_cond_timedwait_2_2_5 = NULL; #elif ARCH(SPARC) static void *__real_pthread_cond_wait_2_2 = NULL; -- 2.31.1