mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
libsysprof-analyze: add document type for metadata
This commit is contained in:
@ -4,6 +4,7 @@ libsysprof_analyze_public_sources = [
|
|||||||
'sysprof-document-frame.c',
|
'sysprof-document-frame.c',
|
||||||
'sysprof-document-log.c',
|
'sysprof-document-log.c',
|
||||||
'sysprof-document-mark.c',
|
'sysprof-document-mark.c',
|
||||||
|
'sysprof-document-metadata.c',
|
||||||
'sysprof-document-mmap.c',
|
'sysprof-document-mmap.c',
|
||||||
'sysprof-document-process.c',
|
'sysprof-document-process.c',
|
||||||
'sysprof-document-sample.c',
|
'sysprof-document-sample.c',
|
||||||
@ -16,6 +17,7 @@ libsysprof_analyze_public_headers = [
|
|||||||
'sysprof-document-frame.h',
|
'sysprof-document-frame.h',
|
||||||
'sysprof-document-log.h',
|
'sysprof-document-log.h',
|
||||||
'sysprof-document-mark.h',
|
'sysprof-document-mark.h',
|
||||||
|
'sysprof-document-metadata.h',
|
||||||
'sysprof-document-mmap.h',
|
'sysprof-document-mmap.h',
|
||||||
'sysprof-document-process.h',
|
'sysprof-document-process.h',
|
||||||
'sysprof-document-sample.h',
|
'sysprof-document-sample.h',
|
||||||
|
|||||||
@ -30,6 +30,7 @@ G_BEGIN_DECLS
|
|||||||
# include "sysprof-document-frame.h"
|
# include "sysprof-document-frame.h"
|
||||||
# include "sysprof-document-log.h"
|
# include "sysprof-document-log.h"
|
||||||
# include "sysprof-document-mark.h"
|
# include "sysprof-document-mark.h"
|
||||||
|
# include "sysprof-document-metadata.h"
|
||||||
# include "sysprof-document-mmap.h"
|
# include "sysprof-document-mmap.h"
|
||||||
# include "sysprof-document-process.h"
|
# include "sysprof-document-process.h"
|
||||||
# include "sysprof-document-sample.h"
|
# include "sysprof-document-sample.h"
|
||||||
|
|||||||
117
src/libsysprof-analyze/sysprof-document-metadata.c
Normal file
117
src/libsysprof-analyze/sysprof-document-metadata.c
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/* sysprof-document-metadata.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-frame-private.h"
|
||||||
|
#include "sysprof-document-metadata.h"
|
||||||
|
|
||||||
|
struct _SysprofDocumentMetadata
|
||||||
|
{
|
||||||
|
SysprofDocumentFrame parent_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _SysprofDocumentMetadataClass
|
||||||
|
{
|
||||||
|
SysprofDocumentFrameClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_ID,
|
||||||
|
PROP_VALUE,
|
||||||
|
N_PROPS
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_FINAL_TYPE (SysprofDocumentMetadata, sysprof_document_metadata, SYSPROF_TYPE_DOCUMENT_FRAME)
|
||||||
|
|
||||||
|
static GParamSpec *properties [N_PROPS];
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_document_metadata_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
SysprofDocumentMetadata *self = SYSPROF_DOCUMENT_METADATA (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_ID:
|
||||||
|
g_value_set_string (value, sysprof_document_metadata_get_id (self));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_VALUE:
|
||||||
|
g_value_set_string (value, sysprof_document_metadata_get_value (self));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_document_metadata_class_init (SysprofDocumentMetadataClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->get_property = sysprof_document_metadata_get_property;
|
||||||
|
|
||||||
|
properties [PROP_ID] =
|
||||||
|
g_param_spec_string ("id", NULL, NULL,
|
||||||
|
NULL,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
properties [PROP_VALUE] =
|
||||||
|
g_param_spec_string ("value", NULL, NULL,
|
||||||
|
NULL,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_document_metadata_init (SysprofDocumentMetadata *self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
sysprof_document_metadata_get_id (SysprofDocumentMetadata *self)
|
||||||
|
{
|
||||||
|
const SysprofCaptureMetadata *meta;
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_METADATA (self), 0);
|
||||||
|
|
||||||
|
meta = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureMetadata);
|
||||||
|
|
||||||
|
return SYSPROF_DOCUMENT_FRAME_CSTRING (self, meta->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
sysprof_document_metadata_get_value (SysprofDocumentMetadata *self)
|
||||||
|
{
|
||||||
|
const SysprofCaptureMetadata *meta;
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_METADATA (self), 0);
|
||||||
|
|
||||||
|
meta = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureMetadata);
|
||||||
|
|
||||||
|
return SYSPROF_DOCUMENT_FRAME_CSTRING (self, meta->metadata);
|
||||||
|
}
|
||||||
43
src/libsysprof-analyze/sysprof-document-metadata.h
Normal file
43
src/libsysprof-analyze/sysprof-document-metadata.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/* sysprof-document-metadata.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-frame.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define SYSPROF_TYPE_DOCUMENT_METADATA (sysprof_document_metadata_get_type())
|
||||||
|
#define SYSPROF_IS_DOCUMENT_METADATA(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, SYSPROF_TYPE_DOCUMENT_METADATA)
|
||||||
|
#define SYSPROF_DOCUMENT_METADATA(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, SYSPROF_TYPE_DOCUMENT_METADATA, SysprofDocumentMetadata)
|
||||||
|
#define SYSPROF_DOCUMENT_METADATA_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, SYSPROF_TYPE_DOCUMENT_METADATA, SysprofDocumentMetadataClass)
|
||||||
|
|
||||||
|
typedef struct _SysprofDocumentMetadata SysprofDocumentMetadata;
|
||||||
|
typedef struct _SysprofDocumentMetadataClass SysprofDocumentMetadataClass;
|
||||||
|
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
GType sysprof_document_metadata_get_type (void) G_GNUC_CONST;
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
const char *sysprof_document_metadata_get_id (SysprofDocumentMetadata *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
const char *sysprof_document_metadata_get_value (SysprofDocumentMetadata *self);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
@ -54,6 +54,10 @@ main (int argc,
|
|||||||
sysprof_document_mark_get_message (SYSPROF_DOCUMENT_MARK (frame)));
|
sysprof_document_mark_get_message (SYSPROF_DOCUMENT_MARK (frame)));
|
||||||
else if (SYSPROF_IS_DOCUMENT_PROCESS (frame))
|
else if (SYSPROF_IS_DOCUMENT_PROCESS (frame))
|
||||||
g_print (" cmdline=%s", sysprof_document_process_get_command_line (SYSPROF_DOCUMENT_PROCESS (frame)));
|
g_print (" cmdline=%s", sysprof_document_process_get_command_line (SYSPROF_DOCUMENT_PROCESS (frame)));
|
||||||
|
else if (SYSPROF_IS_DOCUMENT_METADATA (frame))
|
||||||
|
g_print (" id=%s value=%s",
|
||||||
|
sysprof_document_metadata_get_id (SYSPROF_DOCUMENT_METADATA (frame)),
|
||||||
|
sysprof_document_metadata_get_value (SYSPROF_DOCUMENT_METADATA (frame)));
|
||||||
|
|
||||||
g_print ("\n");
|
g_print ("\n");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user