| 1 |
/* sysprof-callgraph-categorize.c |
| 2 |
* |
| 3 |
* Copyright 2023 Christian Hergert <[email protected]> |
| 4 |
* |
| 5 |
* This program is free software: you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation, either version 3 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
* |
| 18 |
* SPDX-License-Identifier: GPL-3.0-or-later |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "config.h" |
| 22 |
|
| 23 |
#include "sysprof-callgraph-private.h" |
| 24 |
#include "sysprof-categories-private.h" |
| 25 |
#include "sysprof-symbol-private.h" |
| 26 |
|
| 27 |
SysprofCallgraphCategory |
| 28 |
_sysprof_callgraph_node_categorize (SysprofCallgraphNode *node) |
| 29 |
{ |
| 30 |
SysprofSymbol *symbol; |
| 31 |
SysprofCallgraphCategory category; |
| 32 |
|
| 33 |
g_return_val_if_fail (node, SYSPROF_CALLGRAPH_CATEGORY_UNCATEGORIZED); |
| 34 |
g_return_val_if_fail (node->summary, SYSPROF_CALLGRAPH_CATEGORY_UNCATEGORIZED); |
| 35 |
g_return_val_if_fail (node->summary->symbol, SYSPROF_CALLGRAPH_CATEGORY_UNCATEGORIZED); |
| 36 |
|
| 37 |
symbol = node->summary->symbol; |
| 38 |
|
| 39 |
/* NOTE: We could certainly extend this to allow users to define custom |
| 40 |
* categorization. Additionally, we might want to match more than one node so |
| 41 |
* that you can do valgrind style function matches like: |
| 42 |
*/ |
| 43 |
|
| 44 |
if (symbol->binary_nick == NULL) |
| 45 |
return SYSPROF_CALLGRAPH_CATEGORY_UNCATEGORIZED; |
| 46 |
|
| 47 |
category = sysprof_categories_lookup (NULL, symbol->binary_nick, symbol->name); |
| 48 |
|
| 49 |
if (category == 0) |
| 50 |
return SYSPROF_CALLGRAPH_CATEGORY_UNCATEGORIZED; |
| 51 |
|
| 52 |
return category; |
| 53 |
} |