mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-analyze: add callgraph flags for thread-ids
This allows you to set a flag to show the thread id of what was recorded. Use this to help disassociate similar threads in a process to figure out which thread is consuming a majority of the Total time of that process.
This commit is contained in:
@ -41,7 +41,7 @@ enum {
|
||||
PROP_IS_FREE,
|
||||
PROP_SIZE,
|
||||
PROP_STACK_DEPTH,
|
||||
PROP_TID,
|
||||
PROP_THREAD_ID,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
@ -76,12 +76,26 @@ sysprof_document_allocation_get_stack_addresses (SysprofDocumentTraceable *trace
|
||||
return depth;
|
||||
}
|
||||
|
||||
static int
|
||||
sysprof_document_allocation_get_thread_id (SysprofDocumentTraceable *traceable)
|
||||
{
|
||||
SysprofDocumentAllocation *self = (SysprofDocumentAllocation *)traceable;
|
||||
const SysprofCaptureAllocation *allocation;
|
||||
|
||||
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_ALLOCATION (self), 0);
|
||||
|
||||
allocation = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureAllocation);
|
||||
|
||||
return SYSPROF_DOCUMENT_FRAME_INT32 (self, allocation->tid);
|
||||
}
|
||||
|
||||
static void
|
||||
traceable_iface_init (SysprofDocumentTraceableInterface *iface)
|
||||
{
|
||||
iface->get_stack_depth = sysprof_document_allocation_get_stack_depth;
|
||||
iface->get_stack_address = sysprof_document_allocation_get_stack_address;
|
||||
iface->get_stack_addresses = sysprof_document_allocation_get_stack_addresses;
|
||||
iface->get_thread_id = sysprof_document_allocation_get_thread_id;
|
||||
}
|
||||
|
||||
G_DEFINE_FINAL_TYPE_WITH_CODE (SysprofDocumentAllocation, sysprof_document_allocation, SYSPROF_TYPE_DOCUMENT_FRAME,
|
||||
@ -115,8 +129,8 @@ sysprof_document_allocation_get_property (GObject *object,
|
||||
g_value_set_uint (value, sysprof_document_traceable_get_stack_depth (SYSPROF_DOCUMENT_TRACEABLE (self)));
|
||||
break;
|
||||
|
||||
case PROP_TID:
|
||||
g_value_set_int (value, sysprof_document_allocation_get_tid (self));
|
||||
case PROP_THREAD_ID:
|
||||
g_value_set_int (value, sysprof_document_traceable_get_thread_id (SYSPROF_DOCUMENT_TRACEABLE (self)));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -132,17 +146,17 @@ sysprof_document_allocation_class_init (SysprofDocumentAllocationClass *klass)
|
||||
object_class->get_property = sysprof_document_allocation_get_property;
|
||||
|
||||
/**
|
||||
* SysprofDocumentAllocation:tid:
|
||||
* SysprofDocumentAllocation:thread-id:
|
||||
*
|
||||
* The task-id or thread-id of the thread which was traced.
|
||||
* The thread-id where the stack was traced.
|
||||
*
|
||||
* On Linux, this is generally set to the value of the gettid() syscall.
|
||||
* On Linux, this is generally set to the value of `gettid()`.
|
||||
*
|
||||
* Since: 45
|
||||
*/
|
||||
properties [PROP_TID] =
|
||||
g_param_spec_int ("tid", NULL, NULL,
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
properties [PROP_THREAD_ID] =
|
||||
g_param_spec_int ("thread-id", NULL, NULL,
|
||||
-1, G_MAXINT32, 0,
|
||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
@ -226,18 +240,6 @@ sysprof_document_allocation_get_size (SysprofDocumentAllocation *self)
|
||||
return SYSPROF_DOCUMENT_FRAME_INT64 (self, allocation->alloc_size);
|
||||
}
|
||||
|
||||
int
|
||||
sysprof_document_allocation_get_tid (SysprofDocumentAllocation *self)
|
||||
{
|
||||
const SysprofCaptureAllocation *allocation;
|
||||
|
||||
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_ALLOCATION (self), 0);
|
||||
|
||||
allocation = SYSPROF_DOCUMENT_FRAME_GET (self, SysprofCaptureAllocation);
|
||||
|
||||
return SYSPROF_DOCUMENT_FRAME_INT32 (self, allocation->tid);
|
||||
}
|
||||
|
||||
gboolean
|
||||
sysprof_document_allocation_is_free (SysprofDocumentAllocation *self)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user