mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-11 23:51:06 +00:00
libsysprof: add API to lookup a process by PID
This commit is contained in:
@ -2498,3 +2498,40 @@ sysprof_document_serialize_symbols_finish (SysprofDocument *self,
|
|||||||
|
|
||||||
return dex_async_result_propagate_pointer (DEX_ASYNC_RESULT (result), error);
|
return dex_async_result_propagate_pointer (DEX_ASYNC_RESULT (result), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysprof_document_lookup_process:
|
||||||
|
* @self: a #SysprofDocument
|
||||||
|
* @pid: the process identifier
|
||||||
|
*
|
||||||
|
* Looks up a process by PID.
|
||||||
|
*
|
||||||
|
* If multiple copies of the process exist, the result is undefined.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full) (nullable): a #SysprofDocumentProcess or %NULL
|
||||||
|
*/
|
||||||
|
SysprofDocumentProcess *
|
||||||
|
sysprof_document_lookup_process (SysprofDocument *self,
|
||||||
|
int pid)
|
||||||
|
{
|
||||||
|
EggBitsetIter iter;
|
||||||
|
guint position;
|
||||||
|
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_DOCUMENT (self), NULL);
|
||||||
|
|
||||||
|
if (egg_bitset_iter_init_first (&iter, self->processes, &position))
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
g_autoptr(SysprofDocumentProcess) process = g_list_model_get_item (G_LIST_MODEL (self), position);
|
||||||
|
|
||||||
|
g_assert (SYSPROF_IS_DOCUMENT_PROCESS (process));
|
||||||
|
|
||||||
|
if (sysprof_document_frame_get_pid (SYSPROF_DOCUMENT_FRAME (process)) == pid)
|
||||||
|
return g_steal_pointer (&process);
|
||||||
|
}
|
||||||
|
while (egg_bitset_iter_next (&iter, &position));
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
#include "sysprof-callgraph.h"
|
#include "sysprof-callgraph.h"
|
||||||
#include "sysprof-document-counter.h"
|
#include "sysprof-document-counter.h"
|
||||||
#include "sysprof-document-file.h"
|
#include "sysprof-document-file.h"
|
||||||
|
#include "sysprof-document-process.h"
|
||||||
#include "sysprof-document-traceable.h"
|
#include "sysprof-document-traceable.h"
|
||||||
#include "sysprof-mark-catalog.h"
|
#include "sysprof-mark-catalog.h"
|
||||||
#include "sysprof-symbol.h"
|
#include "sysprof-symbol.h"
|
||||||
@ -47,6 +48,9 @@ SYSPROF_AVAILABLE_IN_ALL
|
|||||||
SysprofDocumentFile *sysprof_document_lookup_file (SysprofDocument *self,
|
SysprofDocumentFile *sysprof_document_lookup_file (SysprofDocument *self,
|
||||||
const char *path);
|
const char *path);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
SysprofDocumentProcess *sysprof_document_lookup_process (SysprofDocument *self,
|
||||||
|
int pid);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
GListModel *sysprof_document_list_cpu_info (SysprofDocument *self);
|
GListModel *sysprof_document_list_cpu_info (SysprofDocument *self);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
GListModel *sysprof_document_list_files (SysprofDocument *self);
|
GListModel *sysprof_document_list_files (SysprofDocument *self);
|
||||||
|
|||||||
Reference in New Issue
Block a user