From 90c165aa08cdbddc4da0fa2546a528ae1ea0ce84 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Mon, 27 May 2019 20:57:07 -0700 Subject: [PATCH] libsysprof: stub out source for appending symbols --- src/libsysprof/meson.build | 2 + src/libsysprof/sysprof-symbols-source.c | 92 +++++++++++++++++++++++++ src/libsysprof/sysprof-symbols-source.h | 35 ++++++++++ src/libsysprof/sysprof.h | 1 + 4 files changed, 130 insertions(+) create mode 100644 src/libsysprof/sysprof-symbols-source.c create mode 100644 src/libsysprof/sysprof-symbols-source.h diff --git a/src/libsysprof/meson.build b/src/libsysprof/meson.build index d225d0cc..de960445 100644 --- a/src/libsysprof/meson.build +++ b/src/libsysprof/meson.build @@ -19,6 +19,7 @@ libsysprof_public_sources = [ 'sysprof-source.c', 'sysprof-symbol-dirs.c', 'sysprof-symbol-resolver.c', + 'sysprof-symbols-source.c', 'sysprof-tracefd-source.c', ] @@ -41,6 +42,7 @@ libsysprof_public_headers = [ 'sysprof-source.h', 'sysprof-symbol-dirs.h', 'sysprof-symbol-resolver.h', + 'sysprof-symbols-source.h', 'sysprof-tracefd-source.h', 'sysprof.h', ] diff --git a/src/libsysprof/sysprof-symbols-source.c b/src/libsysprof/sysprof-symbols-source.c new file mode 100644 index 00000000..8e464ef9 --- /dev/null +++ b/src/libsysprof/sysprof-symbols-source.c @@ -0,0 +1,92 @@ +/* sysprof-symbols-source.c + * + * Copyright 2019 Christian Hergert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#define G_LOG_DOMAIN "sysprof-symbols-source" + +#include "config.h" + +#include "sysprof-symbols-source.h" + +struct _SysprofSymbolsSource +{ + GObject parent_instance; + SysprofCaptureWriter *writer; +}; + +static void source_iface_init (SysprofSourceInterface *iface); + +G_DEFINE_TYPE_WITH_CODE (SysprofSymbolsSource, sysprof_symbols_source, G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_SOURCE, source_iface_init)) + +static void +sysprof_symbols_source_finalize (GObject *object) +{ + SysprofSymbolsSource *self = (SysprofSymbolsSource *)object; + + g_clear_pointer (&self->writer, sysprof_capture_writer_unref); + + G_OBJECT_CLASS (sysprof_symbols_source_parent_class)->finalize (object); +} + +static void +sysprof_symbols_source_class_init (SysprofSymbolsSourceClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = sysprof_symbols_source_finalize; +} + +static void +sysprof_symbols_source_init (SysprofSymbolsSource *self) +{ +} + +static void +sysprof_symbols_source_set_writer (SysprofSource *source, + SysprofCaptureWriter *writer) +{ + SysprofSymbolsSource *self = (SysprofSymbolsSource *)source; + + g_assert (SYSPROF_IS_SYMBOLS_SOURCE (self)); + g_assert (writer != NULL); + + g_clear_pointer (&self->writer, sysprof_capture_writer_unref); + self->writer = sysprof_capture_writer_ref (writer); +} + +static void +sysprof_symbols_source_supplement (SysprofSource *source, + SysprofCaptureReader *reader) +{ + SysprofSymbolsSource *self = (SysprofSymbolsSource *)source; + + g_assert (SYSPROF_IS_SYMBOLS_SOURCE (self)); + g_assert (reader != NULL); + g_assert (self->writer != NULL); + + +} + +static void +source_iface_init (SysprofSourceInterface *iface) +{ + iface->set_writer = sysprof_symbols_source_set_writer; + iface->supplement = sysprof_symbols_source_supplement; +} diff --git a/src/libsysprof/sysprof-symbols-source.h b/src/libsysprof/sysprof-symbols-source.h new file mode 100644 index 00000000..22359f94 --- /dev/null +++ b/src/libsysprof/sysprof-symbols-source.h @@ -0,0 +1,35 @@ +/* sysprof-symbols-source.h + * + * Copyright 2019 Christian Hergert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "sysprof-source.h" + +G_BEGIN_DECLS + +#define SYSPROF_TYPE_SYMBOLS_SOURCE (sysprof_symbols_source_get_type()) + +SYSPROF_AVAILABLE_IN_ALL +G_DECLARE_FINAL_TYPE (SysprofSymbolsSource, sysprof_symbols_source, SYSPROF, SYMBOLS_SOURCE, GObject) + +SYSPROF_AVAILABLE_IN_ALL +SysprofSource *sysprof_symbols_source_new (void); + +G_END_DECLS diff --git a/src/libsysprof/sysprof.h b/src/libsysprof/sysprof.h index 2a73501f..c748c28b 100644 --- a/src/libsysprof/sysprof.h +++ b/src/libsysprof/sysprof.h @@ -42,6 +42,7 @@ G_BEGIN_DECLS # include "sysprof-symbol-resolver.h" # include "sysprof-map-lookaside.h" # include "sysprof-selection.h" +# include "sysprof-symbols-source.h" # include "sysprof-tracefd-source.h" #ifdef __linux__