mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-analyze: add SysprofSymbol
The goal here is to get an object to represent a symbol so that we can more easily extend things in the future. We'll still use those pointers as unique in the stackstash in the future.
This commit is contained in:
@ -12,6 +12,7 @@ libsysprof_analyze_public_sources = [
|
||||
'sysprof-document-process-list.c',
|
||||
'sysprof-document-sample.c',
|
||||
'sysprof-document-traceable.c',
|
||||
'sysprof-symbol.c',
|
||||
]
|
||||
|
||||
libsysprof_analyze_public_headers = [
|
||||
@ -29,6 +30,7 @@ libsysprof_analyze_public_headers = [
|
||||
'sysprof-document-process-list.h',
|
||||
'sysprof-document-sample.h',
|
||||
'sysprof-document-traceable.h',
|
||||
'sysprof-symbol.h',
|
||||
]
|
||||
|
||||
libsysprof_analyze_deps = [
|
||||
|
||||
@ -38,6 +38,7 @@ G_BEGIN_DECLS
|
||||
# include "sysprof-document-process-list.h"
|
||||
# include "sysprof-document-sample.h"
|
||||
# include "sysprof-document-traceable.h"
|
||||
# include "sysprof-symbol.h"
|
||||
#undef SYSPROF_ANALYZE_INSIDE
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
32
src/libsysprof-analyze/sysprof-symbol-private.h
Normal file
32
src/libsysprof-analyze/sysprof-symbol-private.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* sysprof-symbol-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-symbol.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
SysprofSymbol *_sysprof_symbol_new (char *name,
|
||||
char *binary_nick,
|
||||
char *binary_path);
|
||||
|
||||
G_END_DECLS
|
||||
155
src/libsysprof-analyze/sysprof-symbol.c
Normal file
155
src/libsysprof-analyze/sysprof-symbol.c
Normal file
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* sysprof-symbol.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-symbol.h"
|
||||
|
||||
struct _SysprofSymbol
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
/* All are GRefString */
|
||||
char *name;
|
||||
char *binary_path;
|
||||
char *binary_nick;
|
||||
};
|
||||
|
||||
G_DEFINE_FINAL_TYPE (SysprofSymbol, sysprof_symbol, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_NAME,
|
||||
PROP_BINARY_NICK,
|
||||
PROP_BINARY_PATH,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
sysprof_symbol_finalize (GObject *object)
|
||||
{
|
||||
SysprofSymbol *self = (SysprofSymbol *)object;
|
||||
|
||||
g_clear_pointer (&self->name, g_ref_string_release);
|
||||
g_clear_pointer (&self->binary_path, g_ref_string_release);
|
||||
g_clear_pointer (&self->binary_nick, g_ref_string_release);
|
||||
|
||||
G_OBJECT_CLASS (sysprof_symbol_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_symbol_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofSymbol *self = SYSPROF_SYMBOL (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, sysprof_symbol_get_name (self));
|
||||
break;
|
||||
|
||||
case PROP_BINARY_NICK:
|
||||
g_value_set_string (value, sysprof_symbol_get_binary_nick (self));
|
||||
break;
|
||||
|
||||
case PROP_BINARY_PATH:
|
||||
g_value_set_string (value, sysprof_symbol_get_binary_path (self));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_symbol_class_init (SysprofSymbolClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = sysprof_symbol_finalize;
|
||||
object_class->get_property = sysprof_symbol_get_property;
|
||||
|
||||
properties [PROP_NAME] =
|
||||
g_param_spec_string ("name", NULL, NULL,
|
||||
NULL,
|
||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
properties [PROP_BINARY_NICK] =
|
||||
g_param_spec_string ("binary-nick", NULL, NULL,
|
||||
NULL,
|
||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
properties [PROP_BINARY_PATH] =
|
||||
g_param_spec_string ("binary-path", NULL, NULL,
|
||||
NULL,
|
||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_symbol_init (SysprofSymbol *self)
|
||||
{
|
||||
}
|
||||
|
||||
const char *
|
||||
sysprof_symbol_get_name (SysprofSymbol *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_SYMBOL (self), NULL);
|
||||
|
||||
return self->name;
|
||||
}
|
||||
|
||||
const char *
|
||||
sysprof_symbol_get_binary_nick (SysprofSymbol *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_SYMBOL (self), NULL);
|
||||
|
||||
return self->binary_nick;
|
||||
}
|
||||
|
||||
const char *
|
||||
sysprof_symbol_get_binary_path (SysprofSymbol *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_SYMBOL (self), NULL);
|
||||
|
||||
return self->binary_path;
|
||||
}
|
||||
|
||||
SysprofSymbol *
|
||||
_sysprof_symbol_new (char *name,
|
||||
char *binary_path,
|
||||
char *binary_nick)
|
||||
{
|
||||
SysprofSymbol *self;
|
||||
|
||||
self = g_object_new (SYSPROF_TYPE_SYMBOL, NULL);
|
||||
self->name = name ? g_ref_string_acquire (name) : NULL;
|
||||
self->binary_path = binary_path ? g_ref_string_acquire (binary_path) : NULL;
|
||||
self->binary_nick = binary_nick ? g_ref_string_acquire (binary_nick) : NULL;
|
||||
|
||||
return self;
|
||||
}
|
||||
45
src/libsysprof-analyze/sysprof-symbol.h
Normal file
45
src/libsysprof-analyze/sysprof-symbol.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* sysprof-symbol.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_SYMBOL (sysprof_symbol_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SysprofSymbol, sysprof_symbol, SYSPROF, SYMBOL, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const char *sysprof_symbol_get_name (SysprofSymbol *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const char *sysprof_symbol_get_binary_nick (SysprofSymbol *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const char *sysprof_symbol_get_binary_path (SysprofSymbol *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
gboolean sysprof_symbol_equal (const SysprofSymbol *a,
|
||||
const SysprofSymbol *b);
|
||||
|
||||
G_END_DECLS
|
||||
Reference in New Issue
Block a user