Debian Codegraph @

src/libsysprof/sysprof-malloc-tracing.c

raw
1 /* sysprof-malloc-tracing.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-malloc-tracing.h"
24 #include "sysprof-instrument-private.h"
25 #include "sysprof-recording-private.h"
26 #include "sysprof-spawnable.h"
27
28 struct _SysprofMallocTracing
29 {
30 SysprofInstrument parent_instance;
31 };
32
33 struct _SysprofMallocTracingClass
34 {
35 SysprofInstrumentClass parent_class;
36 };
37
38 G_DEFINE_FINAL_TYPE (SysprofMallocTracing, sysprof_malloc_tracing, SYSPROF_TYPE_INSTRUMENT)
39
40 static DexFuture *
41 sysprof_malloc_tracing_prepare (SysprofInstrument *instrument,
42 SysprofRecording *recording)
43 {
44 SysprofSpawnable *spawnable;
45
46 g_assert (SYSPROF_IS_MALLOC_TRACING (instrument));
47 g_assert (SYSPROF_IS_RECORDING (recording));
48
49 if ((spawnable = _sysprof_recording_get_spawnable (recording)))
50 sysprof_spawnable_add_ld_preload (spawnable,
51 PACKAGE_LIBDIR"/libsysprof-memory-" API_VERSION_S ".so");
52
53 return dex_future_new_for_boolean (TRUE);
54 }
55
56 static void
57 sysprof_malloc_tracing_class_init (SysprofMallocTracingClass *klass)
58 {
59 SysprofInstrumentClass *instrument_class = SYSPROF_INSTRUMENT_CLASS (klass);
60
61 instrument_class->prepare = sysprof_malloc_tracing_prepare;
62 }
63
64 static void
65 sysprof_malloc_tracing_init (SysprofMallocTracing *self)
66 {
67 }
68
69 SysprofInstrument *
70 sysprof_malloc_tracing_new (void)
71 {
72 return g_object_new (SYSPROF_TYPE_MALLOC_TRACING, NULL);
73 }