mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-analyze: add API for bundled symbolizer
This, once completed, will use __symbols__ embedded within a capture file to decode symbols rather than querying ELF files directly.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
libsysprof_analyze_public_sources = [
|
||||
'sysprof-bundled-symbolizer.c',
|
||||
'sysprof-document.c',
|
||||
'sysprof-document-allocation.c',
|
||||
'sysprof-document-exit.c',
|
||||
@ -20,6 +21,7 @@ libsysprof_analyze_public_sources = [
|
||||
|
||||
libsysprof_analyze_public_headers = [
|
||||
'sysprof-analyze.h',
|
||||
'sysprof-bundled-symbolizer.h',
|
||||
'sysprof-document.h',
|
||||
'sysprof-document-allocation.h',
|
||||
'sysprof-document-exit.h',
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_ANALYZE_INSIDE
|
||||
# include "sysprof-bundled-symbolizer.h"
|
||||
# include "sysprof-document.h"
|
||||
# include "sysprof-document-allocation.h"
|
||||
# include "sysprof-document-exit.h"
|
||||
|
||||
134
src/libsysprof-analyze/sysprof-bundled-symbolizer.c
Normal file
134
src/libsysprof-analyze/sysprof-bundled-symbolizer.c
Normal file
@ -0,0 +1,134 @@
|
||||
/* sysprof-bundled-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-bundled-symbolizer.h"
|
||||
#include "sysprof-document-private.h"
|
||||
#include "sysprof-symbolizer-private.h"
|
||||
|
||||
struct _SysprofBundledSymbolizer
|
||||
{
|
||||
SysprofSymbolizer parent_instance;
|
||||
};
|
||||
|
||||
struct _SysprofBundledSymbolizerClass
|
||||
{
|
||||
SysprofSymbolizerClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_FINAL_TYPE (SysprofBundledSymbolizer, sysprof_bundled_symbolizer, SYSPROF_TYPE_SYMBOLIZER)
|
||||
|
||||
static void
|
||||
sysprof_bundled_symbolizer_decode (SysprofBundledSymbolizer *self,
|
||||
GBytes *bytes,
|
||||
gboolean is_native)
|
||||
{
|
||||
g_assert (SYSPROF_IS_BUNDLED_SYMBOLIZER (self));
|
||||
g_assert (bytes != NULL);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_bundled_symbolizer_prepare_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
SysprofDocument *document = (SysprofDocument *)object;
|
||||
g_autoptr(GTask) task = user_data;
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autoptr(GBytes) bytes = NULL;
|
||||
|
||||
g_assert (SYSPROF_IS_DOCUMENT (document));
|
||||
g_assert (G_IS_ASYNC_RESULT (result));
|
||||
g_assert (G_IS_TASK (task));
|
||||
|
||||
if ((bytes = sysprof_document_lookup_file_finish (document, result, &error)))
|
||||
sysprof_bundled_symbolizer_decode (g_task_get_source_object (task),
|
||||
bytes,
|
||||
_sysprof_document_is_native (document));
|
||||
|
||||
g_task_return_boolean (task, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_bundled_symbolizer_prepare_async (SysprofSymbolizer *symbolizer,
|
||||
SysprofDocument *document,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_autoptr(GTask) task = NULL;
|
||||
|
||||
g_assert (SYSPROF_IS_BUNDLED_SYMBOLIZER (symbolizer));
|
||||
g_assert (SYSPROF_IS_DOCUMENT (document));
|
||||
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
|
||||
|
||||
task = g_task_new (symbolizer, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, sysprof_bundled_symbolizer_prepare_async);
|
||||
|
||||
sysprof_document_lookup_file_async (document,
|
||||
"__symbols__",
|
||||
cancellable,
|
||||
sysprof_bundled_symbolizer_prepare_cb,
|
||||
g_steal_pointer (&task));
|
||||
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sysprof_bundled_symbolizer_prepare_finish (SysprofSymbolizer *symbolizer,
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_assert (SYSPROF_IS_BUNDLED_SYMBOLIZER (symbolizer));
|
||||
g_assert (G_IS_TASK (result));
|
||||
g_assert (g_task_is_valid (result, symbolizer));
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (result), error);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_bundled_symbolizer_finalize (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (sysprof_bundled_symbolizer_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_bundled_symbolizer_class_init (SysprofBundledSymbolizerClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
SysprofSymbolizerClass *symbolizer_class = SYSPROF_SYMBOLIZER_CLASS (klass);
|
||||
|
||||
object_class->finalize = sysprof_bundled_symbolizer_finalize;
|
||||
|
||||
symbolizer_class->prepare_async = sysprof_bundled_symbolizer_prepare_async;
|
||||
symbolizer_class->prepare_finish = sysprof_bundled_symbolizer_prepare_finish;
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_bundled_symbolizer_init (SysprofBundledSymbolizer *self)
|
||||
{
|
||||
}
|
||||
|
||||
SysprofSymbolizer *
|
||||
sysprof_bundled_symbolizer_new (void)
|
||||
{
|
||||
return g_object_new (SYSPROF_TYPE_BUNDLED_SYMBOLIZER, NULL);
|
||||
}
|
||||
42
src/libsysprof-analyze/sysprof-bundled-symbolizer.h
Normal file
42
src/libsysprof-analyze/sysprof-bundled-symbolizer.h
Normal file
@ -0,0 +1,42 @@
|
||||
/* sysprof-bundled-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_BUNDLED_SYMBOLIZER (sysprof_bundled_symbolizer_get_type())
|
||||
#define SYSPROF_IS_BUNDLED_SYMBOLIZER(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, SYSPROF_TYPE_BUNDLED_SYMBOLIZER)
|
||||
#define SYSPROF_BUNDLED_SYMBOLIZER(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, SYSPROF_TYPE_BUNDLED_SYMBOLIZER, SysprofBundledSymbolizer)
|
||||
#define SYSPROF_BUNDLED_SYMBOLIZER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, SYSPROF_TYPE_BUNDLED_SYMBOLIZER, SysprofBundledSymbolizerClass)
|
||||
|
||||
typedef struct _SysprofBundledSymbolizer SysprofBundledSymbolizer;
|
||||
typedef struct _SysprofBundledSymbolizerClass SysprofBundledSymbolizerClass;
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GType sysprof_bundled_symbolizer_get_type (void) G_GNUC_CONST;
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofSymbolizer *sysprof_bundled_symbolizer_new (void);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofBundledSymbolizer, g_object_unref)
|
||||
|
||||
G_END_DECLS
|
||||
Reference in New Issue
Block a user