xref: /freebsd/usr.sbin/pmcstat/pmcpl_callgraph.h (revision 1de7b4b805ddbf2429da511c053686ac4591ed89)
10b86b1bbSFabien Thomas /*-
2*1de7b4b8SPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*1de7b4b8SPedro F. Giffuni  *
40b86b1bbSFabien Thomas  * Copyright (c) 2005-2007, Joseph Koshy
50b86b1bbSFabien Thomas  * Copyright (c) 2007 The FreeBSD Foundation
60b86b1bbSFabien Thomas  * All rights reserved.
70b86b1bbSFabien Thomas  *
80b86b1bbSFabien Thomas  * Portions of this software were developed by A. Joseph Koshy under
90b86b1bbSFabien Thomas  * sponsorship from the FreeBSD Foundation and Google, Inc.
100b86b1bbSFabien Thomas  *
110b86b1bbSFabien Thomas  * Redistribution and use in source and binary forms, with or without
120b86b1bbSFabien Thomas  * modification, are permitted provided that the following conditions
130b86b1bbSFabien Thomas  * are met:
140b86b1bbSFabien Thomas  * 1. Redistributions of source code must retain the above copyright
150b86b1bbSFabien Thomas  *    notice, this list of conditions and the following disclaimer.
160b86b1bbSFabien Thomas  * 2. Redistributions in binary form must reproduce the above copyright
170b86b1bbSFabien Thomas  *    notice, this list of conditions and the following disclaimer in the
180b86b1bbSFabien Thomas  *    documentation and/or other materials provided with the distribution.
190b86b1bbSFabien Thomas  *
200b86b1bbSFabien Thomas  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
210b86b1bbSFabien Thomas  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
220b86b1bbSFabien Thomas  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
230b86b1bbSFabien Thomas  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
240b86b1bbSFabien Thomas  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
250b86b1bbSFabien Thomas  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
260b86b1bbSFabien Thomas  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
270b86b1bbSFabien Thomas  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
280b86b1bbSFabien Thomas  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
290b86b1bbSFabien Thomas  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
300b86b1bbSFabien Thomas  * SUCH DAMAGE.
310b86b1bbSFabien Thomas  *
320b86b1bbSFabien Thomas  * $FreeBSD$
330b86b1bbSFabien Thomas  */
340b86b1bbSFabien Thomas 
350b86b1bbSFabien Thomas #ifndef	_PMCSTAT_PL_CALLGRAPH_H_
360b86b1bbSFabien Thomas #define	_PMCSTAT_PL_CALLGRAPH_H_
370b86b1bbSFabien Thomas 
380b86b1bbSFabien Thomas /*
390b86b1bbSFabien Thomas  * Each call graph node is tracked by a pmcstat_cgnode struct.
400b86b1bbSFabien Thomas  */
410b86b1bbSFabien Thomas 
420b86b1bbSFabien Thomas struct pmcstat_cgnode {
430b86b1bbSFabien Thomas 	struct pmcstat_image	*pcg_image;
440b86b1bbSFabien Thomas 	uintfptr_t		pcg_func;
450b86b1bbSFabien Thomas 	uint32_t		pcg_count;
460b86b1bbSFabien Thomas 	uint32_t		pcg_nchildren;
470b86b1bbSFabien Thomas 	LIST_ENTRY(pmcstat_cgnode) pcg_sibling;
480b86b1bbSFabien Thomas 	LIST_HEAD(,pmcstat_cgnode) pcg_children;
490b86b1bbSFabien Thomas };
500b86b1bbSFabien Thomas 
510b86b1bbSFabien Thomas struct pmcstat_cgnode_hash {
520b86b1bbSFabien Thomas 	struct pmcstat_cgnode  *pch_cgnode;
530b86b1bbSFabien Thomas 	pmc_id_t		pch_pmcid;
540b86b1bbSFabien Thomas 	LIST_ENTRY(pmcstat_cgnode_hash) pch_next;
550b86b1bbSFabien Thomas };
560b86b1bbSFabien Thomas extern LIST_HEAD(pmcstat_cgnode_hash_list, pmcstat_cgnode_hash) pmcstat_cgnode_hash[PMCSTAT_NHASH];
570b86b1bbSFabien Thomas extern int pmcstat_cgnode_hash_count;
580b86b1bbSFabien Thomas 
590b86b1bbSFabien Thomas /* Function prototypes */
600b86b1bbSFabien Thomas int pmcpl_cg_init(void);
610b86b1bbSFabien Thomas void pmcpl_cg_shutdown(FILE *mf);
620b86b1bbSFabien Thomas void pmcpl_cg_process(
630b86b1bbSFabien Thomas     struct pmcstat_process *pp, struct pmcstat_pmcrecord *pmcr,
640b86b1bbSFabien Thomas     uint32_t nsamples, uintfptr_t *cc, int usermode, uint32_t cpu);
65d27927f7SRuslan Bukin int pmcpl_cg_topkeypress(int c, void *w);
660b86b1bbSFabien Thomas void pmcpl_cg_topdisplay(void);
670b86b1bbSFabien Thomas void pmcpl_cg_configure(char *opt);
680b86b1bbSFabien Thomas 
690b86b1bbSFabien Thomas #endif	/* _PMCSTAT_PL_CALLGRAPH_H_ */
70