| 1 |
/* sysprof-symbolizer.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-symbolizer-private.h" |
| 24 |
|
| 25 |
G_DEFINE_ABSTRACT_TYPE (SysprofSymbolizer, sysprof_symbolizer, G_TYPE_OBJECT) |
| 26 |
|
| 27 |
static void |
| 28 |
sysprof_symbolizer_real_prepare_async (SysprofSymbolizer *self, |
| 29 |
SysprofDocument *document, |
| 30 |
GCancellable *cancellable, |
| 31 |
GAsyncReadyCallback callback, |
| 32 |
gpointer user_data) |
| 33 |
{ |
| 34 |
g_autoptr(GTask) task = g_task_new (self, cancellable, callback, user_data); |
| 35 |
g_task_return_boolean (task, TRUE); |
| 36 |
} |
| 37 |
|
| 38 |
static gboolean |
| 39 |
sysprof_symbolizer_real_prepare_finish (SysprofSymbolizer *self, |
| 40 |
GAsyncResult *result, |
| 41 |
GError **error) |
| 42 |
{ |
| 43 |
return g_task_propagate_boolean (G_TASK (result), error); |
| 44 |
} |
| 45 |
|
| 46 |
static void |
| 47 |
sysprof_symbolizer_finalize (GObject *object) |
| 48 |
{ |
| 49 |
G_OBJECT_CLASS (sysprof_symbolizer_parent_class)->finalize (object); |
| 50 |
} |
| 51 |
|
| 52 |
static void |
| 53 |
sysprof_symbolizer_class_init (SysprofSymbolizerClass *klass) |
| 54 |
{ |
| 55 |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
| 56 |
|
| 57 |
object_class->finalize = sysprof_symbolizer_finalize; |
| 58 |
|
| 59 |
klass->prepare_async = sysprof_symbolizer_real_prepare_async; |
| 60 |
klass->prepare_finish = sysprof_symbolizer_real_prepare_finish; |
| 61 |
} |
| 62 |
|
| 63 |
static void |
| 64 |
sysprof_symbolizer_init (SysprofSymbolizer *self) |
| 65 |
{ |
| 66 |
} |
| 67 |
|
| 68 |
void |
| 69 |
_sysprof_symbolizer_prepare_async (SysprofSymbolizer *self, |
| 70 |
SysprofDocument *document, |
| 71 |
GCancellable *cancellable, |
| 72 |
GAsyncReadyCallback callback, |
| 73 |
gpointer user_data) |
| 74 |
{ |
| 75 |
g_return_if_fail (SYSPROF_IS_SYMBOLIZER (self)); |
| 76 |
g_return_if_fail (SYSPROF_IS_DOCUMENT (document)); |
| 77 |
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); |
| 78 |
|
| 79 |
SYSPROF_SYMBOLIZER_GET_CLASS (self)->prepare_async (self, document, cancellable, callback, user_data); |
| 80 |
} |
| 81 |
|
| 82 |
gboolean |
| 83 |
_sysprof_symbolizer_prepare_finish (SysprofSymbolizer *self, |
| 84 |
GAsyncResult *result, |
| 85 |
GError **error) |
| 86 |
{ |
| 87 |
g_return_val_if_fail (SYSPROF_IS_SYMBOLIZER (self), FALSE); |
| 88 |
g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE); |
| 89 |
|
| 90 |
return SYSPROF_SYMBOLIZER_GET_CLASS (self)->prepare_finish (self, result, error); |
| 91 |
} |
| 92 |
|
| 93 |
SysprofSymbol * |
| 94 |
_sysprof_symbolizer_symbolize (SysprofSymbolizer *self, |
| 95 |
SysprofStrings *strings, |
| 96 |
const SysprofProcessInfo *process_info, |
| 97 |
SysprofAddressContext context, |
| 98 |
SysprofAddress address) |
| 99 |
{ |
| 100 |
return SYSPROF_SYMBOLIZER_GET_CLASS (self)->symbolize (self, strings, process_info, context, address); |
| 101 |
} |
| 102 |
|
| 103 |
void |
| 104 |
_sysprof_symbolizer_setup (SysprofSymbolizer *self, |
| 105 |
SysprofDocumentLoader *loader) |
| 106 |
{ |
| 107 |
g_return_if_fail (SYSPROF_IS_SYMBOLIZER (self)); |
| 108 |
g_return_if_fail (SYSPROF_IS_DOCUMENT_LOADER (loader)); |
| 109 |
|
| 110 |
if (SYSPROF_SYMBOLIZER_GET_CLASS (self)->setup) |
| 111 |
SYSPROF_SYMBOLIZER_GET_CLASS (self)->setup (self, loader); |
| 112 |
} |