mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-analyze: add document type for fork
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
libsysprof_analyze_public_sources = [
|
libsysprof_analyze_public_sources = [
|
||||||
'sysprof-document.c',
|
'sysprof-document.c',
|
||||||
'sysprof-document-exit.c',
|
'sysprof-document-exit.c',
|
||||||
|
'sysprof-document-fork.c',
|
||||||
'sysprof-document-frame.c',
|
'sysprof-document-frame.c',
|
||||||
'sysprof-document-log.c',
|
'sysprof-document-log.c',
|
||||||
'sysprof-document-mark.c',
|
'sysprof-document-mark.c',
|
||||||
@ -14,6 +15,7 @@ libsysprof_analyze_public_headers = [
|
|||||||
'sysprof-analyze.h',
|
'sysprof-analyze.h',
|
||||||
'sysprof-document.h',
|
'sysprof-document.h',
|
||||||
'sysprof-document-exit.h',
|
'sysprof-document-exit.h',
|
||||||
|
'sysprof-document-fork.h',
|
||||||
'sysprof-document-frame.h',
|
'sysprof-document-frame.h',
|
||||||
'sysprof-document-log.h',
|
'sysprof-document-log.h',
|
||||||
'sysprof-document-mark.h',
|
'sysprof-document-mark.h',
|
||||||
|
|||||||
@ -27,6 +27,7 @@ G_BEGIN_DECLS
|
|||||||
#define SYSPROF_ANALYZE_INSIDE
|
#define SYSPROF_ANALYZE_INSIDE
|
||||||
# include "sysprof-document.h"
|
# include "sysprof-document.h"
|
||||||
# include "sysprof-document-exit.h"
|
# include "sysprof-document-exit.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"
|
||||||
# include "sysprof-document-mark.h"
|
# include "sysprof-document-mark.h"
|
||||||
|
|||||||
95
src/libsysprof-analyze/sysprof-document-fork.c
Normal file
95
src/libsysprof-analyze/sysprof-document-fork.c
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/* sysprof-document-fork.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-fork.h"
|
||||||
|
|
||||||
|
struct _SysprofDocumentFork
|
||||||
|
{
|
||||||
|
SysprofDocumentFrame parent_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _SysprofDocumentForkClass
|
||||||
|
{
|
||||||
|
SysprofDocumentFrameClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_CHILD_PID,
|
||||||
|
N_PROPS
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_FINAL_TYPE (SysprofDocumentFork, sysprof_document_fork, SYSPROF_TYPE_DOCUMENT_FRAME)
|
||||||
|
|
||||||
|
static GParamSpec *properties [N_PROPS];
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_document_fork_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
SysprofDocumentFork *self = SYSPROF_DOCUMENT_FORK (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_CHILD_PID:
|
||||||
|
g_value_set_int (value, sysprof_document_fork_get_child_pid (self));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_document_fork_class_init (SysprofDocumentForkClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->get_property = sysprof_document_fork_get_property;
|
||||||
|
|
||||||
|
properties [PROP_CHILD_PID] =
|
||||||
|
g_param_spec_int ("child-pid", NULL, NULL,
|
||||||
|
G_MININT, G_MAXINT, 0,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_document_fork_init (SysprofDocumentFork *self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
sysprof_document_fork_get_child_pid (SysprofDocumentFork *self)
|
||||||
|
{
|
||||||
|
const SysprofCaptureFork *fork;
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_FORK (self), 0);
|
||||||
|
|
||||||
|
fork = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureFork);
|
||||||
|
|
||||||
|
return SYSPROF_DOCUMENT_FRAME_INT32 (self, fork->child_pid);
|
||||||
|
}
|
||||||
41
src/libsysprof-analyze/sysprof-document-fork.h
Normal file
41
src/libsysprof-analyze/sysprof-document-fork.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/* sysprof-document-fork.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_FORK (sysprof_document_fork_get_type())
|
||||||
|
#define SYSPROF_IS_DOCUMENT_FORK(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, SYSPROF_TYPE_DOCUMENT_FORK)
|
||||||
|
#define SYSPROF_DOCUMENT_FORK(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, SYSPROF_TYPE_DOCUMENT_FORK, SysprofDocumentFork)
|
||||||
|
#define SYSPROF_DOCUMENT_FORK_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, SYSPROF_TYPE_DOCUMENT_FORK, SysprofDocumentForkClass)
|
||||||
|
|
||||||
|
typedef struct _SysprofDocumentFork SysprofDocumentFork;
|
||||||
|
typedef struct _SysprofDocumentForkClass SysprofDocumentForkClass;
|
||||||
|
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
GType sysprof_document_fork_get_type (void) G_GNUC_CONST;
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
int sysprof_document_fork_get_child_pid (SysprofDocumentFork *self);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
@ -23,6 +23,7 @@
|
|||||||
#include "sysprof-document-frame-private.h"
|
#include "sysprof-document-frame-private.h"
|
||||||
|
|
||||||
#include "sysprof-document-exit.h"
|
#include "sysprof-document-exit.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"
|
||||||
#include "sysprof-document-mmap.h"
|
#include "sysprof-document-mmap.h"
|
||||||
@ -124,22 +125,43 @@ _sysprof_document_frame_new (GMappedFile *mapped_file,
|
|||||||
guint16 frame_len,
|
guint16 frame_len,
|
||||||
gboolean needs_swap)
|
gboolean needs_swap)
|
||||||
{
|
{
|
||||||
GType gtype = SYSPROF_TYPE_DOCUMENT_FRAME;
|
|
||||||
SysprofDocumentFrame *self;
|
SysprofDocumentFrame *self;
|
||||||
|
GType gtype;
|
||||||
|
|
||||||
if (0) {}
|
switch (frame->type)
|
||||||
else if (frame->type == SYSPROF_CAPTURE_FRAME_SAMPLE)
|
{
|
||||||
gtype = SYSPROF_TYPE_DOCUMENT_SAMPLE;
|
case SYSPROF_CAPTURE_FRAME_SAMPLE:
|
||||||
else if (frame->type == SYSPROF_CAPTURE_FRAME_MAP)
|
gtype = SYSPROF_TYPE_DOCUMENT_SAMPLE;
|
||||||
gtype = SYSPROF_TYPE_DOCUMENT_MMAP;
|
break;
|
||||||
else if (frame->type == SYSPROF_CAPTURE_FRAME_LOG)
|
|
||||||
gtype = SYSPROF_TYPE_DOCUMENT_LOG;
|
case SYSPROF_CAPTURE_FRAME_MAP:
|
||||||
else if (frame->type == SYSPROF_CAPTURE_FRAME_MARK)
|
gtype = SYSPROF_TYPE_DOCUMENT_MMAP;
|
||||||
gtype = SYSPROF_TYPE_DOCUMENT_MARK;
|
break;
|
||||||
else if (frame->type == SYSPROF_CAPTURE_FRAME_PROCESS)
|
|
||||||
gtype = SYSPROF_TYPE_DOCUMENT_PROCESS;
|
case SYSPROF_CAPTURE_FRAME_LOG:
|
||||||
else if (frame->type == SYSPROF_CAPTURE_FRAME_EXIT)
|
gtype = SYSPROF_TYPE_DOCUMENT_LOG;
|
||||||
gtype = SYSPROF_TYPE_DOCUMENT_EXIT;
|
break;
|
||||||
|
|
||||||
|
case SYSPROF_CAPTURE_FRAME_MARK:
|
||||||
|
gtype = SYSPROF_TYPE_DOCUMENT_MARK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SYSPROF_CAPTURE_FRAME_PROCESS:
|
||||||
|
gtype = SYSPROF_TYPE_DOCUMENT_PROCESS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SYSPROF_CAPTURE_FRAME_EXIT:
|
||||||
|
gtype = SYSPROF_TYPE_DOCUMENT_EXIT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SYSPROF_CAPTURE_FRAME_FORK:
|
||||||
|
gtype = SYSPROF_TYPE_DOCUMENT_FORK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
gtype = SYSPROF_TYPE_DOCUMENT_FRAME;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
self = g_object_new (gtype, NULL);
|
self = g_object_new (gtype, NULL);
|
||||||
self->mapped_file = g_mapped_file_ref (mapped_file);
|
self->mapped_file = g_mapped_file_ref (mapped_file);
|
||||||
|
|||||||
@ -58,6 +58,9 @@ main (int argc,
|
|||||||
g_print (" id=%s value=%s",
|
g_print (" id=%s value=%s",
|
||||||
sysprof_document_metadata_get_id (SYSPROF_DOCUMENT_METADATA (frame)),
|
sysprof_document_metadata_get_id (SYSPROF_DOCUMENT_METADATA (frame)),
|
||||||
sysprof_document_metadata_get_value (SYSPROF_DOCUMENT_METADATA (frame)));
|
sysprof_document_metadata_get_value (SYSPROF_DOCUMENT_METADATA (frame)));
|
||||||
|
else if (SYSPROF_IS_DOCUMENT_FORK (frame))
|
||||||
|
g_print (" child-pid=%d",
|
||||||
|
sysprof_document_fork_get_child_pid (SYSPROF_DOCUMENT_FORK (frame)));
|
||||||
|
|
||||||
g_print ("\n");
|
g_print ("\n");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user