From d878fbf372bbe2f69158aa35fb62aff0e544f46b Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 27 Apr 2023 17:50:28 -0700 Subject: [PATCH] libsysprof-analyze: add document type for task exit We don't have any extra data here currently, but it can be nice to be able to check a gtype when consuming frames. --- src/libsysprof-analyze/meson.build | 2 + src/libsysprof-analyze/sysprof-analyze.h | 1 + .../sysprof-document-exit.c | 46 +++++++++++++++++++ .../sysprof-document-exit.h | 39 ++++++++++++++++ .../sysprof-document-frame.c | 4 ++ 5 files changed, 92 insertions(+) create mode 100644 src/libsysprof-analyze/sysprof-document-exit.c create mode 100644 src/libsysprof-analyze/sysprof-document-exit.h diff --git a/src/libsysprof-analyze/meson.build b/src/libsysprof-analyze/meson.build index 7e13118d..edf80506 100644 --- a/src/libsysprof-analyze/meson.build +++ b/src/libsysprof-analyze/meson.build @@ -1,5 +1,6 @@ libsysprof_analyze_public_sources = [ 'sysprof-document.c', + 'sysprof-document-exit.c', 'sysprof-document-frame.c', 'sysprof-document-log.c', 'sysprof-document-mark.c', @@ -11,6 +12,7 @@ libsysprof_analyze_public_sources = [ libsysprof_analyze_public_headers = [ 'sysprof-analyze.h', 'sysprof-document.h', + 'sysprof-document-exit.h', 'sysprof-document-frame.h', 'sysprof-document-log.h', 'sysprof-document-mark.h', diff --git a/src/libsysprof-analyze/sysprof-analyze.h b/src/libsysprof-analyze/sysprof-analyze.h index d41763d9..73dfeeb2 100644 --- a/src/libsysprof-analyze/sysprof-analyze.h +++ b/src/libsysprof-analyze/sysprof-analyze.h @@ -26,6 +26,7 @@ G_BEGIN_DECLS #define SYSPROF_ANALYZE_INSIDE # include "sysprof-document.h" +# include "sysprof-document-exit.h" # include "sysprof-document-frame.h" # include "sysprof-document-log.h" # include "sysprof-document-mark.h" diff --git a/src/libsysprof-analyze/sysprof-document-exit.c b/src/libsysprof-analyze/sysprof-document-exit.c new file mode 100644 index 00000000..4e83cbab --- /dev/null +++ b/src/libsysprof-analyze/sysprof-document-exit.c @@ -0,0 +1,46 @@ +/* sysprof-document-exit.c + * + * Copyright 2023 Christian Hergert + * + * 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#include "config.h" + +#include "sysprof-document-frame-private.h" +#include "sysprof-document-exit.h" + +struct _SysprofDocumentExit +{ + SysprofDocumentFrame parent_instance; +}; + +struct _SysprofDocumentExitClass +{ + SysprofDocumentFrameClass parent_class; +}; + +G_DEFINE_FINAL_TYPE (SysprofDocumentExit, sysprof_document_exit, SYSPROF_TYPE_DOCUMENT_FRAME) + +static void +sysprof_document_exit_class_init (SysprofDocumentExitClass *klass) +{ +} + +static void +sysprof_document_exit_init (SysprofDocumentExit *self) +{ +} diff --git a/src/libsysprof-analyze/sysprof-document-exit.h b/src/libsysprof-analyze/sysprof-document-exit.h new file mode 100644 index 00000000..3c902cf2 --- /dev/null +++ b/src/libsysprof-analyze/sysprof-document-exit.h @@ -0,0 +1,39 @@ +/* sysprof-document-exit.h + * + * Copyright 2023 Christian Hergert + * + * 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "sysprof-document-frame.h" + +G_BEGIN_DECLS + +#define SYSPROF_TYPE_DOCUMENT_EXIT (sysprof_document_exit_get_type()) +#define SYSPROF_IS_DOCUMENT_EXIT(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, SYSPROF_TYPE_DOCUMENT_EXIT) +#define SYSPROF_DOCUMENT_EXIT(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, SYSPROF_TYPE_DOCUMENT_EXIT, SysprofDocumentExit) +#define SYSPROF_DOCUMENT_EXIT_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, SYSPROF_TYPE_DOCUMENT_EXIT, SysprofDocumentExitClass) + +typedef struct _SysprofDocumentExit SysprofDocumentExit; +typedef struct _SysprofDocumentExitClass SysprofDocumentExitClass; + +SYSPROF_AVAILABLE_IN_ALL +GType sysprof_document_exit_get_type (void) G_GNUC_CONST; + +G_END_DECLS + diff --git a/src/libsysprof-analyze/sysprof-document-frame.c b/src/libsysprof-analyze/sysprof-document-frame.c index daa6605c..0b13a3dd 100644 --- a/src/libsysprof-analyze/sysprof-document-frame.c +++ b/src/libsysprof-analyze/sysprof-document-frame.c @@ -21,6 +21,8 @@ #include "config.h" #include "sysprof-document-frame-private.h" + +#include "sysprof-document-exit.h" #include "sysprof-document-log.h" #include "sysprof-document-mark.h" #include "sysprof-document-mmap.h" @@ -136,6 +138,8 @@ _sysprof_document_frame_new (GMappedFile *mapped_file, gtype = SYSPROF_TYPE_DOCUMENT_MARK; else if (frame->type == SYSPROF_CAPTURE_FRAME_PROCESS) gtype = SYSPROF_TYPE_DOCUMENT_PROCESS; + else if (frame->type == SYSPROF_CAPTURE_FRAME_EXIT) + gtype = SYSPROF_TYPE_DOCUMENT_EXIT; self = g_object_new (gtype, NULL); self->mapped_file = g_mapped_file_ref (mapped_file);