mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
libsysprof-analyze: add SysprofDocumentFileChunk
This object will represent frames in the list model which are file chunks.
This commit is contained in:
@ -3,6 +3,7 @@ libsysprof_analyze_public_sources = [
|
|||||||
'sysprof-document.c',
|
'sysprof-document.c',
|
||||||
'sysprof-document-allocation.c',
|
'sysprof-document-allocation.c',
|
||||||
'sysprof-document-exit.c',
|
'sysprof-document-exit.c',
|
||||||
|
'sysprof-document-file-chunk.c',
|
||||||
'sysprof-document-fork.c',
|
'sysprof-document-fork.c',
|
||||||
'sysprof-document-frame.c',
|
'sysprof-document-frame.c',
|
||||||
'sysprof-document-log.c',
|
'sysprof-document-log.c',
|
||||||
@ -32,6 +33,7 @@ libsysprof_analyze_public_headers = [
|
|||||||
'sysprof-document.h',
|
'sysprof-document.h',
|
||||||
'sysprof-document-allocation.h',
|
'sysprof-document-allocation.h',
|
||||||
'sysprof-document-exit.h',
|
'sysprof-document-exit.h',
|
||||||
|
'sysprof-document-file-chunk.h',
|
||||||
'sysprof-document-fork.h',
|
'sysprof-document-fork.h',
|
||||||
'sysprof-document-frame.h',
|
'sysprof-document-frame.h',
|
||||||
'sysprof-document-log.h',
|
'sysprof-document-log.h',
|
||||||
|
|||||||
@ -29,6 +29,7 @@ G_BEGIN_DECLS
|
|||||||
# include "sysprof-document.h"
|
# include "sysprof-document.h"
|
||||||
# include "sysprof-document-allocation.h"
|
# include "sysprof-document-allocation.h"
|
||||||
# include "sysprof-document-exit.h"
|
# include "sysprof-document-exit.h"
|
||||||
|
# include "sysprof-document-file-chunk.h"
|
||||||
# include "sysprof-document-fork.h"
|
# include "sysprof-document-fork.h"
|
||||||
# include "sysprof-document-frame.h"
|
# include "sysprof-document-frame.h"
|
||||||
# include "sysprof-document-log.h"
|
# include "sysprof-document-log.h"
|
||||||
|
|||||||
156
src/libsysprof-analyze/sysprof-document-file-chunk.c
Normal file
156
src/libsysprof-analyze/sysprof-document-file-chunk.c
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/* sysprof-document-file-chunk.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-file-chunk.h"
|
||||||
|
|
||||||
|
struct _SysprofDocumentFileChunk
|
||||||
|
{
|
||||||
|
SysprofDocumentFrame parent_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _SysprofDocumentFileChunkClass
|
||||||
|
{
|
||||||
|
SysprofDocumentFrameClass parent_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_IS_LAST,
|
||||||
|
PROP_SIZE,
|
||||||
|
PROP_PATH,
|
||||||
|
N_PROPS
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_FINAL_TYPE (SysprofDocumentFileChunk, sysprof_document_file_chunk, SYSPROF_TYPE_DOCUMENT_FRAME)
|
||||||
|
|
||||||
|
static GParamSpec *properties [N_PROPS];
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_document_file_chunk_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
SysprofDocumentFileChunk *self = SYSPROF_DOCUMENT_FILE_CHUNK (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_IS_LAST:
|
||||||
|
g_value_set_boolean (value, sysprof_document_file_chunk_get_is_last (self));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_SIZE:
|
||||||
|
g_value_set_uint (value, sysprof_document_file_chunk_get_size (self));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_PATH:
|
||||||
|
g_value_set_string (value, sysprof_document_file_chunk_get_path (self));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_document_file_chunk_class_init (SysprofDocumentFileChunkClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->get_property = sysprof_document_file_chunk_get_property;
|
||||||
|
|
||||||
|
properties [PROP_IS_LAST] =
|
||||||
|
g_param_spec_boolean ("is-last", NULL, NULL,
|
||||||
|
FALSE,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
properties [PROP_SIZE] =
|
||||||
|
g_param_spec_uint ("size", NULL, NULL,
|
||||||
|
0, G_MAXUINT16, 0,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
properties [PROP_PATH] =
|
||||||
|
g_param_spec_string ("path", NULL, NULL,
|
||||||
|
NULL,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_document_file_chunk_init (SysprofDocumentFileChunk *self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
sysprof_document_file_chunk_get_is_last (SysprofDocumentFileChunk *self)
|
||||||
|
{
|
||||||
|
const SysprofCaptureFileChunk *file_chunk;
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_FILE_CHUNK (self), FALSE);
|
||||||
|
|
||||||
|
file_chunk = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureFileChunk);
|
||||||
|
|
||||||
|
return file_chunk->is_last;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint
|
||||||
|
sysprof_document_file_chunk_get_size (SysprofDocumentFileChunk *self)
|
||||||
|
{
|
||||||
|
const SysprofCaptureFileChunk *file_chunk;
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_FILE_CHUNK (self), FALSE);
|
||||||
|
|
||||||
|
file_chunk = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureFileChunk);
|
||||||
|
|
||||||
|
return SYSPROF_DOCUMENT_FRAME_UINT16 (self, file_chunk->len);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
sysprof_document_file_chunk_get_path (SysprofDocumentFileChunk *self)
|
||||||
|
{
|
||||||
|
const SysprofCaptureFileChunk *file_chunk;
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_FILE_CHUNK (self), FALSE);
|
||||||
|
|
||||||
|
file_chunk = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureFileChunk);
|
||||||
|
|
||||||
|
return SYSPROF_DOCUMENT_FRAME_CSTRING (self, file_chunk->path);
|
||||||
|
}
|
||||||
|
|
||||||
|
const guint8 *
|
||||||
|
sysprof_document_file_chunk_get_data (SysprofDocumentFileChunk *self,
|
||||||
|
guint *size)
|
||||||
|
{
|
||||||
|
const SysprofCaptureFileChunk *file_chunk;
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_FILE_CHUNK (self), FALSE);
|
||||||
|
|
||||||
|
file_chunk = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureFileChunk);
|
||||||
|
|
||||||
|
if (size != NULL)
|
||||||
|
*size = sysprof_document_file_chunk_get_size (self);
|
||||||
|
|
||||||
|
return file_chunk->data;
|
||||||
|
}
|
||||||
49
src/libsysprof-analyze/sysprof-document-file-chunk.h
Normal file
49
src/libsysprof-analyze/sysprof-document-file-chunk.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* sysprof-document-file-chunk.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_FILE_CHUNK (sysprof_document_file_chunk_get_type())
|
||||||
|
#define SYSPROF_IS_DOCUMENT_FILE_CHUNK(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, SYSPROF_TYPE_DOCUMENT_FILE_CHUNK)
|
||||||
|
#define SYSPROF_DOCUMENT_FILE_CHUNK(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, SYSPROF_TYPE_DOCUMENT_FILE_CHUNK, SysprofDocumentFileChunk)
|
||||||
|
#define SYSPROF_DOCUMENT_FILE_CHUNK_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, SYSPROF_TYPE_DOCUMENT_FILE_CHUNK, SysprofDocumentFileChunkClass)
|
||||||
|
|
||||||
|
typedef struct _SysprofDocumentFileChunk SysprofDocumentFileChunk;
|
||||||
|
typedef struct _SysprofDocumentFileChunkClass SysprofDocumentFileChunkClass;
|
||||||
|
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
GType sysprof_document_file_chunk_get_type (void) G_GNUC_CONST;
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
gboolean sysprof_document_file_chunk_get_is_last (SysprofDocumentFileChunk *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
guint sysprof_document_file_chunk_get_size (SysprofDocumentFileChunk *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
const char *sysprof_document_file_chunk_get_path (SysprofDocumentFileChunk *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
const guint8 *sysprof_document_file_chunk_get_data (SysprofDocumentFileChunk *self,
|
||||||
|
guint *size);
|
||||||
|
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofDocumentFileChunk, g_object_unref)
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "sysprof-document-allocation.h"
|
#include "sysprof-document-allocation.h"
|
||||||
#include "sysprof-document-exit.h"
|
#include "sysprof-document-exit.h"
|
||||||
|
#include "sysprof-document-file-chunk.h"
|
||||||
#include "sysprof-document-fork.h"
|
#include "sysprof-document-fork.h"
|
||||||
#include "sysprof-document-log.h"
|
#include "sysprof-document-log.h"
|
||||||
#include "sysprof-document-mark.h"
|
#include "sysprof-document-mark.h"
|
||||||
@ -163,6 +164,10 @@ _sysprof_document_frame_new (GMappedFile *mapped_file,
|
|||||||
gtype = SYSPROF_TYPE_DOCUMENT_ALLOCATION;
|
gtype = SYSPROF_TYPE_DOCUMENT_ALLOCATION;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SYSPROF_CAPTURE_FRAME_FILE_CHUNK:
|
||||||
|
gtype = SYSPROF_TYPE_DOCUMENT_FILE_CHUNK;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
gtype = SYSPROF_TYPE_DOCUMENT_FRAME;
|
gtype = SYSPROF_TYPE_DOCUMENT_FRAME;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user