mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
libsysprof-analyze: add process title including PID
This commit is contained in:
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
#include "sysprof-document-frame-private.h"
|
#include "sysprof-document-frame-private.h"
|
||||||
#include "sysprof-document-process-private.h"
|
#include "sysprof-document-process-private.h"
|
||||||
#include "sysprof-mount.h"
|
#include "sysprof-mount.h"
|
||||||
@ -40,6 +42,7 @@ enum {
|
|||||||
PROP_COMMAND_LINE,
|
PROP_COMMAND_LINE,
|
||||||
PROP_DURATION,
|
PROP_DURATION,
|
||||||
PROP_EXIT_TIME,
|
PROP_EXIT_TIME,
|
||||||
|
PROP_TITLE,
|
||||||
N_PROPS
|
N_PROPS
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -79,6 +82,10 @@ sysprof_document_process_get_property (GObject *object,
|
|||||||
g_value_set_int64 (value, sysprof_document_process_get_exit_time (self));
|
g_value_set_int64 (value, sysprof_document_process_get_exit_time (self));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_TITLE:
|
||||||
|
g_value_take_string (value, sysprof_document_process_dup_title (self));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
}
|
}
|
||||||
@ -107,6 +114,11 @@ sysprof_document_process_class_init (SysprofDocumentProcessClass *klass)
|
|||||||
G_MININT64, G_MAXINT64, 0,
|
G_MININT64, G_MAXINT64, 0,
|
||||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
properties [PROP_TITLE] =
|
||||||
|
g_param_spec_string ("title", NULL, NULL,
|
||||||
|
NULL,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,3 +223,27 @@ sysprof_document_process_get_duration (SysprofDocumentProcess *self)
|
|||||||
|
|
||||||
return sysprof_document_process_get_exit_time (self) - t;
|
return sysprof_document_process_get_exit_time (self) - t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysprof_document_process_dup_title:
|
||||||
|
* @self: a #SysprofDocumentProcess
|
||||||
|
*
|
||||||
|
* Gets a suitable title for the process.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a string containing a process title
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
sysprof_document_process_dup_title (SysprofDocumentProcess *self)
|
||||||
|
{
|
||||||
|
const char *command_line;
|
||||||
|
int pid;
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_PROCESS (self), NULL);
|
||||||
|
|
||||||
|
pid = sysprof_document_frame_get_pid (SYSPROF_DOCUMENT_FRAME (self));
|
||||||
|
|
||||||
|
if ((command_line = sysprof_document_process_get_command_line (self)))
|
||||||
|
return g_strdup_printf (_("%s [Process %d]"), command_line, pid);
|
||||||
|
|
||||||
|
return g_strdup_printf (_("Process %d"), pid);
|
||||||
|
}
|
||||||
|
|||||||
@ -43,6 +43,8 @@ gint64 sysprof_document_process_get_exit_time (SysprofDocumentProcess *s
|
|||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
gint64 sysprof_document_process_get_duration (SysprofDocumentProcess *self);
|
gint64 sysprof_document_process_get_duration (SysprofDocumentProcess *self);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
char *sysprof_document_process_dup_title (SysprofDocumentProcess *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
GListModel *sysprof_document_process_list_memory_maps (SysprofDocumentProcess *self);
|
GListModel *sysprof_document_process_list_memory_maps (SysprofDocumentProcess *self);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
GListModel *sysprof_document_process_list_mounts (SysprofDocumentProcess *self);
|
GListModel *sysprof_document_process_list_mounts (SysprofDocumentProcess *self);
|
||||||
|
|||||||
@ -70,7 +70,7 @@
|
|||||||
<lookup name="exit-time" type="SysprofDocumentProcess"/>
|
<lookup name="exit-time" type="SysprofDocumentProcess"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="label-expression">
|
<property name="label-expression">
|
||||||
<lookup name="command-line" type="SysprofDocumentProcess"/>
|
<lookup name="title" type="SysprofDocumentProcess"/>
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
Reference in New Issue
Block a user