mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
libsysprof-profile: include spawnable information in metadata
This commit is contained in:
@ -226,6 +226,47 @@ sysprof_recording_fiber (gpointer user_data)
|
|||||||
add_metadata (self, "HOSTTYPE", g_getenv ("HOSTTYPE"));
|
add_metadata (self, "HOSTTYPE", g_getenv ("HOSTTYPE"));
|
||||||
add_metadata (self, "OSTYPE", g_getenv ("OSTYPE"));
|
add_metadata (self, "OSTYPE", g_getenv ("OSTYPE"));
|
||||||
|
|
||||||
|
/* Log information about the spawning process */
|
||||||
|
if (self->spawnable != NULL)
|
||||||
|
{
|
||||||
|
const char * const *argv = sysprof_spawnable_get_argv (self->spawnable);
|
||||||
|
const char * const *env = sysprof_spawnable_get_environ (self->spawnable);
|
||||||
|
const char *cwd = sysprof_spawnable_get_cwd (self->spawnable);
|
||||||
|
|
||||||
|
if (cwd)
|
||||||
|
add_metadata (self, "spawnable.cwd", cwd);
|
||||||
|
|
||||||
|
if (env != NULL)
|
||||||
|
{
|
||||||
|
g_autoptr(GString) str = g_string_new (NULL);
|
||||||
|
|
||||||
|
for (guint e = 0; env[e]; e++)
|
||||||
|
{
|
||||||
|
g_autofree char *quoted = g_shell_quote (env[e]);
|
||||||
|
|
||||||
|
g_string_append (str, quoted);
|
||||||
|
g_string_append_c (str, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
add_metadata (self, "spawnable.environ", str->str);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv != NULL)
|
||||||
|
{
|
||||||
|
g_autoptr(GString) str = g_string_new (NULL);
|
||||||
|
|
||||||
|
for (guint a = 0; argv[a]; a++)
|
||||||
|
{
|
||||||
|
g_autofree char *quoted = g_shell_quote (argv[a]);
|
||||||
|
|
||||||
|
g_string_append (str, quoted);
|
||||||
|
g_string_append_c (str, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
add_metadata (self, "spawnable.argv", str->str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Save a copy of os-release for troubleshooting */
|
/* Save a copy of os-release for troubleshooting */
|
||||||
dex_await (_sysprof_recording_add_file (self, "/etc/os-release", FALSE), NULL);
|
dex_await (_sysprof_recording_add_file (self, "/etc/os-release", FALSE), NULL);
|
||||||
|
|
||||||
|
|||||||
@ -320,17 +320,21 @@ sysprof_spawnable_spawn (SysprofSpawnable *self,
|
|||||||
return g_subprocess_launcher_spawnv (launcher, argv, error);
|
return g_subprocess_launcher_spawnv (launcher, argv, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
sysprof_spawnable_get_cwd (SysprofSpawnable *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_SPAWNABLE (self), NULL);
|
||||||
|
|
||||||
|
return self->cwd;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sysprof_spawnable_set_cwd (SysprofSpawnable *self,
|
sysprof_spawnable_set_cwd (SysprofSpawnable *self,
|
||||||
const gchar *cwd)
|
const gchar *cwd)
|
||||||
{
|
{
|
||||||
g_return_if_fail (SYSPROF_IS_SPAWNABLE (self));
|
g_return_if_fail (SYSPROF_IS_SPAWNABLE (self));
|
||||||
|
|
||||||
if (g_strcmp0 (cwd, self->cwd) != 0)
|
g_set_str (&self->cwd, cwd);
|
||||||
{
|
|
||||||
g_free (self->cwd);
|
|
||||||
self->cwd = g_strdup (cwd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -47,6 +47,8 @@ SYSPROF_AVAILABLE_IN_ALL
|
|||||||
void sysprof_spawnable_append_args (SysprofSpawnable *self,
|
void sysprof_spawnable_append_args (SysprofSpawnable *self,
|
||||||
const char * const *argv);
|
const char * const *argv);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
const char *sysprof_spawnable_get_cwd (SysprofSpawnable *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
void sysprof_spawnable_set_cwd (SysprofSpawnable *self,
|
void sysprof_spawnable_set_cwd (SysprofSpawnable *self,
|
||||||
const char *cwd);
|
const char *cwd);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
|||||||
Reference in New Issue
Block a user