libsysprof-analyze: start on symbols API via document

This commit is contained in:
Christian Hergert
2023-05-03 14:21:17 -07:00
parent f7374f3252
commit 976fb93a83
6 changed files with 165 additions and 5 deletions

View File

@ -11,6 +11,7 @@ libsysprof_analyze_public_sources = [
'sysprof-document-process.c',
'sysprof-document-process-list.c',
'sysprof-document-sample.c',
'sysprof-document-symbols.c',
'sysprof-document-traceable.c',
'sysprof-multi-symbolizer.c',
'sysprof-symbol.c',
@ -31,6 +32,7 @@ libsysprof_analyze_public_headers = [
'sysprof-document-process.h',
'sysprof-document-process-list.h',
'sysprof-document-sample.h',
'sysprof-document-symbols.h',
'sysprof-document-traceable.h',
'sysprof-multi-symbolizer.h',
'sysprof-symbol.h',

View File

@ -37,6 +37,7 @@ G_BEGIN_DECLS
# include "sysprof-document-process.h"
# include "sysprof-document-process-list.h"
# include "sysprof-document-sample.h"
# include "sysprof-document-symbols.h"
# include "sysprof-document-traceable.h"
# include "sysprof-multi-symbolizer.h"
# include "sysprof-symbol.h"

View File

@ -0,0 +1,31 @@
/* sysprof-document-symbols-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-document.h"
#include "sysprof-document-symbols.h"
G_BEGIN_DECLS
SysprofDocumentSymbols *_sysprof_document_symbols_new (SysprofDocument *document,
SysprofSymbolizer *symbolizer);
G_END_DECLS

View File

@ -0,0 +1,70 @@
/* sysprof-document-symbols.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-document-symbols-private.h"
struct _SysprofDocumentSymbols
{
GObject parent_instance;
SysprofSymbolizer *symbolizer;
};
G_DEFINE_FINAL_TYPE (SysprofDocumentSymbols, sysprof_document_symbols, G_TYPE_OBJECT)
static void
sysprof_document_symbols_finalize (GObject *object)
{
SysprofDocumentSymbols *self = (SysprofDocumentSymbols *)object;
g_clear_object (&self->symbolizer);
G_OBJECT_CLASS (sysprof_document_symbols_parent_class)->finalize (object);
}
static void
sysprof_document_symbols_class_init (SysprofDocumentSymbolsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = sysprof_document_symbols_finalize;
}
static void
sysprof_document_symbols_init (SysprofDocumentSymbols *self)
{
}
SysprofDocumentSymbols *
_sysprof_document_symbols_new (SysprofDocument *document,
SysprofSymbolizer *symbolizer)
{
SysprofDocumentSymbols *self;
g_return_val_if_fail (SYSPROF_IS_DOCUMENT (document), NULL);
g_return_val_if_fail (SYSPROF_IS_SYMBOLIZER (symbolizer), NULL);
self = g_object_new (SYSPROF_TYPE_DOCUMENT_SYMBOLS, NULL);
/* TODO: async generation of symbols */
return self;
}

View File

@ -0,0 +1,43 @@
/*
* sysprof-document-symbols.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>
#include "sysprof-symbol.h"
G_BEGIN_DECLS
#define SYSPROF_TYPE_DOCUMENT_SYMBOLS (sysprof_document_symbols_get_type())
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (SysprofDocumentSymbols, sysprof_document_symbols, SYSPROF, DOCUMENT_SYMBOLS, GObject)
SYSPROF_AVAILABLE_IN_ALL
SysprofSymbol *sysprof_document_symbols_lookup (SysprofDocumentSymbols *symbols,
int pid,
SysprofAddressContext context,
SysprofAddress address);
G_END_DECLS

View File

@ -22,7 +22,10 @@
#include <gio/gio.h>
#include "sysprof-version-macros.h"
#include <sysprof-capture.h>
#include "sysprof-document-symbols.h"
#include "sysprof-symbolizer.h"
G_BEGIN_DECLS
@ -32,10 +35,20 @@ SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (SysprofDocument, sysprof_document, SYSPROF, DOCUMENT, GObject)
SYSPROF_AVAILABLE_IN_ALL
SysprofDocument *sysprof_document_new (const char *filename,
GError **error);
SysprofDocument *sysprof_document_new (const char *filename,
GError **error);
SYSPROF_AVAILABLE_IN_ALL
SysprofDocument *sysprof_document_new_from_fd (int capture_fd,
GError **error);
SysprofDocument *sysprof_document_new_from_fd (int capture_fd,
GError **error);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_document_symbolize_async (SysprofDocument *self,
SysprofSymbolizer *symbolizer,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
SYSPROF_AVAILABLE_IN_ALL
SysprofDocumentSymbols *sysprof_document_symbolize_finish (SysprofDocument *self,
GAsyncResult *result,
GError **error);
G_END_DECLS