libsysprof-analyze: add minimal symbolizer API

This exposes the types and hierarchy but won't expose the API details that
we need internally. The idea here is that we can keep that private so we
can adjust how it is used should we need to since the public interface
would be the SysprofDocumentSymbols, not the SysprofSymbolizer which does
decoding directly via address/context state.
This commit is contained in:
Christian Hergert
2023-05-03 14:16:31 -07:00
parent 0e799deee4
commit f7374f3252
7 changed files with 251 additions and 0 deletions

View File

@ -12,7 +12,9 @@ libsysprof_analyze_public_sources = [
'sysprof-document-process-list.c',
'sysprof-document-sample.c',
'sysprof-document-traceable.c',
'sysprof-multi-symbolizer.c',
'sysprof-symbol.c',
'sysprof-symbolizer.c',
]
libsysprof_analyze_public_headers = [
@ -30,7 +32,9 @@ libsysprof_analyze_public_headers = [
'sysprof-document-process-list.h',
'sysprof-document-sample.h',
'sysprof-document-traceable.h',
'sysprof-multi-symbolizer.h',
'sysprof-symbol.h',
'sysprof-symbolizer.h',
]
libsysprof_analyze_deps = [

View File

@ -38,7 +38,9 @@ G_BEGIN_DECLS
# include "sysprof-document-process-list.h"
# include "sysprof-document-sample.h"
# include "sysprof-document-traceable.h"
# include "sysprof-multi-symbolizer.h"
# include "sysprof-symbol.h"
# include "sysprof-symbolizer.h"
#undef SYSPROF_ANALYZE_INSIDE
G_END_DECLS

View File

@ -0,0 +1,77 @@
/* sysprof-multi-symbolizer.c
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "config.h"
#include "sysprof-multi-symbolizer.h"
#include "sysprof-symbolizer-private.h"
struct _SysprofMultiSymbolizer
{
SysprofSymbolizer parent_instance;
GPtrArray *symbolizers;
};
struct _SysprofMultiSymbolizerClass
{
SysprofSymbolizerClass parent_class;
};
G_DEFINE_FINAL_TYPE (SysprofMultiSymbolizer, sysprof_multi_symbolizer, SYSPROF_TYPE_SYMBOLIZER)
static void
sysprof_multi_symbolizer_finalize (GObject *object)
{
SysprofMultiSymbolizer *self = (SysprofMultiSymbolizer *)object;
g_clear_pointer (&self->symbolizers, g_ptr_array_unref);
G_OBJECT_CLASS (sysprof_multi_symbolizer_parent_class)->finalize (object);
}
static void
sysprof_multi_symbolizer_class_init (SysprofMultiSymbolizerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = sysprof_multi_symbolizer_finalize;
}
static void
sysprof_multi_symbolizer_init (SysprofMultiSymbolizer *self)
{
self->symbolizers = g_ptr_array_new_with_free_func (g_object_unref);
}
SysprofMultiSymbolizer *
sysprof_multi_symbolizer_new (void)
{
return g_object_new (SYSPROF_TYPE_MULTI_SYMBOLIZER, NULL);
}
void
sysprof_multi_symbolizer_add (SysprofMultiSymbolizer *self,
SysprofSymbolizer *symbolizer)
{
g_return_if_fail (SYSPROF_IS_MULTI_SYMBOLIZER (self));
g_return_if_fail (SYSPROF_IS_SYMBOLIZER (symbolizer));
g_ptr_array_add (self->symbolizers, g_object_ref (symbolizer));
}

View File

@ -0,0 +1,45 @@
/* sysprof-multi-symbolizer.h
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include "sysprof-symbolizer.h"
G_BEGIN_DECLS
#define SYSPROF_TYPE_MULTI_SYMBOLIZER (sysprof_multi_symbolizer_get_type())
#define SYSPROF_IS_MULTI_SYMBOLIZER(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, SYSPROF_TYPE_MULTI_SYMBOLIZER)
#define SYSPROF_MULTI_SYMBOLIZER(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, SYSPROF_TYPE_MULTI_SYMBOLIZER, SysprofMultiSymbolizer)
#define SYSPROF_MULTI_SYMBOLIZER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, SYSPROF_TYPE_MULTI_SYMBOLIZER, SysprofMultiSymbolizerClass)
typedef struct _SysprofMultiSymbolizer SysprofMultiSymbolizer;
typedef struct _SysprofMultiSymbolizerClass SysprofMultiSymbolizerClass;
SYSPROF_AVAILABLE_IN_ALL
GType sysprof_multi_symbolizer_get_type (void) G_GNUC_CONST;
SYSPROF_AVAILABLE_IN_ALL
SysprofMultiSymbolizer *sysprof_multi_symbolizer_new (void);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_multi_symbolizer_add (SysprofMultiSymbolizer *self,
SysprofSymbolizer *symbolizer);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofMultiSymbolizer, g_object_unref)
G_END_DECLS

View File

@ -0,0 +1,37 @@
/* sysprof-symbolizer-private.h
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include "sysprof-symbolizer.h"
G_BEGIN_DECLS
struct _SysprofSymbolizer
{
GObject parent;
};
struct _SysprofSymbolizerClass
{
GObjectClass parent_class;
};
G_END_DECLS

View File

@ -0,0 +1,44 @@
/* sysprof-symbolizer.c
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "config.h"
#include "sysprof-symbolizer-private.h"
G_DEFINE_ABSTRACT_TYPE (SysprofSymbolizer, sysprof_symbolizer, G_TYPE_OBJECT)
static void
sysprof_symbolizer_finalize (GObject *object)
{
G_OBJECT_CLASS (sysprof_symbolizer_parent_class)->finalize (object);
}
static void
sysprof_symbolizer_class_init (SysprofSymbolizerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = sysprof_symbolizer_finalize;
}
static void
sysprof_symbolizer_init (SysprofSymbolizer *self)
{
}

View File

@ -0,0 +1,42 @@
/* sysprof-symbolizer.h
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* 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 <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <glib-object.h>
#include <sysprof-capture.h>
G_BEGIN_DECLS
#define SYSPROF_TYPE_SYMBOLIZER (sysprof_symbolizer_get_type())
#define SYSPROF_IS_SYMBOLIZER(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, SYSPROF_TYPE_SYMBOLIZER)
#define SYSPROF_SYMBOLIZER(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, SYSPROF_TYPE_SYMBOLIZER, SysprofSymbolizer)
#define SYSPROF_SYMBOLIZER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, SYSPROF_TYPE_SYMBOLIZER, SysprofSymbolizerClass)
typedef struct _SysprofSymbolizer SysprofSymbolizer;
typedef struct _SysprofSymbolizerClass SysprofSymbolizerClass;
SYSPROF_AVAILABLE_IN_ALL
GType sysprof_symbolizer_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofSymbolizer, g_object_unref)
G_END_DECLS