libsysprof-analyze: add document type for processes

Generally this is all the processes at startup, but can also be a process
that is executed while the capture is running. Useful to pair with an
Exit frame for pid/tid duration.
This commit is contained in:
Christian Hergert
2023-04-27 17:45:04 -07:00
parent 6031233cc3
commit 24d0d4af52
5 changed files with 142 additions and 0 deletions

View File

@ -4,6 +4,7 @@ libsysprof_analyze_public_sources = [
'sysprof-document-log.c',
'sysprof-document-mark.c',
'sysprof-document-mmap.c',
'sysprof-document-process.c',
'sysprof-document-sample.c',
]
@ -14,6 +15,7 @@ libsysprof_analyze_public_headers = [
'sysprof-document-log.h',
'sysprof-document-mark.h',
'sysprof-document-mmap.h',
'sysprof-document-process.h',
'sysprof-document-sample.h',
]

View File

@ -30,6 +30,7 @@ G_BEGIN_DECLS
# include "sysprof-document-log.h"
# include "sysprof-document-mark.h"
# include "sysprof-document-mmap.h"
# include "sysprof-document-process.h"
# include "sysprof-document-sample.h"
#undef SYSPROF_ANALYZE_INSIDE

View File

@ -24,6 +24,7 @@
#include "sysprof-document-log.h"
#include "sysprof-document-mark.h"
#include "sysprof-document-mmap.h"
#include "sysprof-document-process.h"
#include "sysprof-document-sample.h"
G_DEFINE_TYPE (SysprofDocumentFrame, sysprof_document_frame, G_TYPE_OBJECT)
@ -133,6 +134,8 @@ _sysprof_document_frame_new (GMappedFile *mapped_file,
gtype = SYSPROF_TYPE_DOCUMENT_LOG;
else if (frame->type == SYSPROF_CAPTURE_FRAME_MARK)
gtype = SYSPROF_TYPE_DOCUMENT_MARK;
else if (frame->type == SYSPROF_CAPTURE_FRAME_PROCESS)
gtype = SYSPROF_TYPE_DOCUMENT_PROCESS;
self = g_object_new (gtype, NULL);
self->mapped_file = g_mapped_file_ref (mapped_file);

View File

@ -0,0 +1,95 @@
/* sysprof-document-process.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-process.h"
struct _SysprofDocumentProcess
{
SysprofDocumentFrame parent_instance;
};
struct _SysprofDocumentProcessClass
{
SysprofDocumentFrameClass parent_class;
};
enum {
PROP_0,
PROP_COMMAND_LINE,
N_PROPS
};
G_DEFINE_FINAL_TYPE (SysprofDocumentProcess, sysprof_document_process, SYSPROF_TYPE_DOCUMENT_FRAME)
static GParamSpec *properties [N_PROPS];
static void
sysprof_document_process_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SysprofDocumentProcess *self = SYSPROF_DOCUMENT_PROCESS (object);
switch (prop_id)
{
case PROP_COMMAND_LINE:
g_value_set_string (value, sysprof_document_process_get_command_line (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
sysprof_document_process_class_init (SysprofDocumentProcessClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = sysprof_document_process_get_property;
properties [PROP_COMMAND_LINE] =
g_param_spec_string ("command-line", NULL, NULL,
NULL,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
sysprof_document_process_init (SysprofDocumentProcess *self)
{
}
const char *
sysprof_document_process_get_command_line (SysprofDocumentProcess *self)
{
const SysprofCaptureProcess *proc;
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_PROCESS (self), 0);
proc = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureProcess);
return SYSPROF_DOCUMENT_FRAME_CSTRING (self, proc->cmdline);
}

View File

@ -0,0 +1,41 @@
/* sysprof-document-process.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_PROCESS (sysprof_document_process_get_type())
#define SYSPROF_IS_DOCUMENT_PROCESS(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, SYSPROF_TYPE_DOCUMENT_PROCESS)
#define SYSPROF_DOCUMENT_PROCESS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, SYSPROF_TYPE_DOCUMENT_PROCESS, SysprofDocumentProcess)
#define SYSPROF_DOCUMENT_PROCESS_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, SYSPROF_TYPE_DOCUMENT_PROCESS, SysprofDocumentProcessClass)
typedef struct _SysprofDocumentProcess SysprofDocumentProcess;
typedef struct _SysprofDocumentProcessClass SysprofDocumentProcessClass;
SYSPROF_AVAILABLE_IN_ALL
GType sysprof_document_process_get_type (void) G_GNUC_CONST;
SYSPROF_AVAILABLE_IN_ALL
const char *sysprof_document_process_get_command_line (SysprofDocumentProcess *self);
G_END_DECLS