mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-analyze: add SysprofDocumentCtrset
This represents the SysprofCaptureCtrset and allows fetching the raw values for a given counter. These are raw because they may not be endian swapped and that is the responsibility of the consumer. SysprofDocument will use these eventually to store the values for a given counter and the time of the value shift.
This commit is contained in:
@ -4,6 +4,7 @@ libsysprof_analyze_public_sources = [
|
||||
'sysprof-document-allocation.c',
|
||||
'sysprof-document-counter.c',
|
||||
'sysprof-document-ctrdef.c',
|
||||
'sysprof-document-ctrset.c',
|
||||
'sysprof-document-exit.c',
|
||||
'sysprof-document-file.c',
|
||||
'sysprof-document-file-chunk.c',
|
||||
@ -52,6 +53,7 @@ libsysprof_analyze_public_headers = [
|
||||
'sysprof-document-allocation.h',
|
||||
'sysprof-document-counter.h',
|
||||
'sysprof-document-ctrdef.h',
|
||||
'sysprof-document-ctrset.h',
|
||||
'sysprof-document-exit.h',
|
||||
'sysprof-document-file.h',
|
||||
'sysprof-document-file-chunk.h',
|
||||
|
||||
@ -30,6 +30,7 @@ G_BEGIN_DECLS
|
||||
# include "sysprof-document-allocation.h"
|
||||
# include "sysprof-document-counter.h"
|
||||
# include "sysprof-document-ctrdef.h"
|
||||
# include "sysprof-document-ctrset.h"
|
||||
# include "sysprof-document-exit.h"
|
||||
# include "sysprof-document-file.h"
|
||||
# include "sysprof-document-file-chunk.h"
|
||||
|
||||
88
src/libsysprof-analyze/sysprof-document-ctrset.c
Normal file
88
src/libsysprof-analyze/sysprof-document-ctrset.c
Normal file
@ -0,0 +1,88 @@
|
||||
/* sysprof-document-ctrset.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-ctrset.h"
|
||||
|
||||
struct _SysprofDocumentCtrset
|
||||
{
|
||||
SysprofDocumentFrame parent_instance;
|
||||
};
|
||||
|
||||
struct _SysprofDocumentCtrsetClass
|
||||
{
|
||||
SysprofDocumentFrameClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_FINAL_TYPE (SysprofDocumentCtrset, sysprof_document_ctrset, SYSPROF_TYPE_DOCUMENT_FRAME)
|
||||
|
||||
static void
|
||||
sysprof_document_ctrset_class_init (SysprofDocumentCtrsetClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_document_ctrset_init (SysprofDocumentCtrset *self)
|
||||
{
|
||||
}
|
||||
|
||||
guint
|
||||
sysprof_document_ctrset_get_n_values (SysprofDocumentCtrset *self)
|
||||
{
|
||||
const SysprofCaptureCounterSet *ctrset;
|
||||
|
||||
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_CTRSET (self), 0);
|
||||
|
||||
ctrset = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureCounterSet);
|
||||
|
||||
return SYSPROF_DOCUMENT_FRAME_UINT16 (self, ctrset->n_values);
|
||||
}
|
||||
|
||||
/**
|
||||
* sysprof_document_ctrset_get_raw_value: (skip)
|
||||
* @self: a #SysprofDocumentCtrset
|
||||
* @nth: the nth value to get
|
||||
* @id: (out): a location for the counter id
|
||||
* @value: a location to store the raw value
|
||||
*
|
||||
* The raw value is 8 bytes and may not be converted to local
|
||||
* byte ordering.
|
||||
*
|
||||
* @nth must be less-than sysprof_document_ctrset_get_n_values().
|
||||
*/
|
||||
void
|
||||
sysprof_document_ctrset_get_raw_value (SysprofDocumentCtrset *self,
|
||||
guint nth,
|
||||
guint *id,
|
||||
guint8 value[restrict 8])
|
||||
{
|
||||
const SysprofCaptureCounterSet *ctrset;
|
||||
|
||||
g_return_if_fail (SYSPROF_IS_DOCUMENT_CTRSET (self));
|
||||
g_return_if_fail (nth < sysprof_document_ctrset_get_n_values (self));
|
||||
g_return_if_fail (value != NULL);
|
||||
|
||||
ctrset = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureCounterSet);
|
||||
|
||||
*id = ctrset->values[nth / 8].ids[nth % 8];
|
||||
memcpy (value, &ctrset->values[nth / 8].values[nth % 8], 8);
|
||||
}
|
||||
50
src/libsysprof-analyze/sysprof-document-ctrset.h
Normal file
50
src/libsysprof-analyze/sysprof-document-ctrset.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* sysprof-document-ctrset.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 <gio/gio.h>
|
||||
|
||||
#include "sysprof-document-frame.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_TYPE_DOCUMENT_CTRSET (sysprof_document_ctrset_get_type())
|
||||
#define SYSPROF_IS_DOCUMENT_CTRSET(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, SYSPROF_TYPE_DOCUMENT_CTRSET)
|
||||
#define SYSPROF_DOCUMENT_CTRSET(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, SYSPROF_TYPE_DOCUMENT_CTRSET, SysprofDocumentCtrset)
|
||||
#define SYSPROF_DOCUMENT_CTRSET_CLASS(klass) G_TYPE_CHECK_CLASS_CAST(klass, SYSPROF_TYPE_DOCUMENT_CTRSET, SysprofDocumentCtrsetClass)
|
||||
|
||||
typedef struct _SysprofDocumentCtrset SysprofDocumentCtrset;
|
||||
typedef struct _SysprofDocumentCtrsetClass SysprofDocumentCtrsetClass;
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GType sysprof_document_ctrset_get_type (void) G_GNUC_CONST;
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
guint sysprof_document_ctrset_get_n_values (SysprofDocumentCtrset *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_document_ctrset_get_raw_value (SysprofDocumentCtrset *self,
|
||||
guint nth,
|
||||
guint *id,
|
||||
guint8 value[restrict 8]);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofDocumentCtrset, g_object_unref)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
|
||||
#include "sysprof-document-allocation.h"
|
||||
#include "sysprof-document-ctrdef.h"
|
||||
#include "sysprof-document-ctrset.h"
|
||||
#include "sysprof-document-exit.h"
|
||||
#include "sysprof-document-file-chunk.h"
|
||||
#include "sysprof-document-fork.h"
|
||||
@ -183,6 +184,10 @@ _sysprof_document_frame_new (GMappedFile *mapped_file,
|
||||
gtype = SYSPROF_TYPE_DOCUMENT_CTRDEF;
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_CTRSET:
|
||||
gtype = SYSPROF_TYPE_DOCUMENT_CTRSET;
|
||||
break;
|
||||
|
||||
default:
|
||||
gtype = SYSPROF_TYPE_DOCUMENT_FRAME;
|
||||
break;
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include "sysprof-document-bitset-index-private.h"
|
||||
#include "sysprof-document-counter-private.h"
|
||||
#include "sysprof-document-ctrdef.h"
|
||||
#include "sysprof-document-ctrset.h"
|
||||
#include "sysprof-document-file-chunk.h"
|
||||
#include "sysprof-document-file-private.h"
|
||||
#include "sysprof-document-frame-private.h"
|
||||
@ -66,6 +67,7 @@ struct _SysprofDocument
|
||||
GtkBitset *pids;
|
||||
GtkBitset *jitmaps;
|
||||
GtkBitset *ctrdefs;
|
||||
GtkBitset *ctrsets;
|
||||
|
||||
GHashTable *files_first_position;
|
||||
GHashTable *pid_to_process_info;
|
||||
@ -205,6 +207,7 @@ sysprof_document_finalize (GObject *object)
|
||||
g_clear_pointer (&self->frames, g_array_unref);
|
||||
|
||||
g_clear_pointer (&self->ctrdefs, gtk_bitset_unref);
|
||||
g_clear_pointer (&self->ctrsets, gtk_bitset_unref);
|
||||
g_clear_pointer (&self->file_chunks, gtk_bitset_unref);
|
||||
g_clear_pointer (&self->jitmaps, gtk_bitset_unref);
|
||||
g_clear_pointer (&self->mmaps, gtk_bitset_unref);
|
||||
@ -243,6 +246,7 @@ sysprof_document_init (SysprofDocument *self)
|
||||
(GDestroyNotify)g_array_unref);
|
||||
|
||||
self->ctrdefs = gtk_bitset_new_empty ();
|
||||
self->ctrsets = gtk_bitset_new_empty ();
|
||||
self->file_chunks = gtk_bitset_new_empty ();
|
||||
self->jitmaps = gtk_bitset_new_empty ();
|
||||
self->mmaps = gtk_bitset_new_empty ();
|
||||
@ -574,6 +578,10 @@ sysprof_document_load_worker (GTask *task,
|
||||
gtk_bitset_add (self->ctrdefs, self->frames->len);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_CTRSET:
|
||||
gtk_bitset_add (self->ctrsets, self->frames->len);
|
||||
break;
|
||||
|
||||
case SYSPROF_CAPTURE_FRAME_JITMAP:
|
||||
gtk_bitset_add (self->jitmaps, self->frames->len);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user