mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 07:00:53 +00:00
*** empty log message ***
This commit is contained in:
@ -265,7 +265,7 @@ process_lookup_symbol (Process *process, gulong address)
|
|||||||
{
|
{
|
||||||
if (undefined.name)
|
if (undefined.name)
|
||||||
g_free (undefined.name);
|
g_free (undefined.name);
|
||||||
undefined.name = g_strdup_printf ("??? (%s)", process->cmdline);
|
undefined.name = g_strdup_printf ("??? %s", process->cmdline);
|
||||||
undefined.address = 0xBABE0001;
|
undefined.address = 0xBABE0001;
|
||||||
|
|
||||||
return &undefined;
|
return &undefined;
|
||||||
|
|||||||
56
profile.c
56
profile.c
@ -79,7 +79,12 @@ insert (SaveContext *context, int id, gpointer pointer)
|
|||||||
static int
|
static int
|
||||||
get_id (SaveContext *context, gpointer pointer)
|
get_id (SaveContext *context, gpointer pointer)
|
||||||
{
|
{
|
||||||
int id = GPOINTER_TO_INT (g_hash_table_lookup (context->id_by_pointer, pointer));
|
int id;
|
||||||
|
|
||||||
|
if (!pointer)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
id = GPOINTER_TO_INT (g_hash_table_lookup (context->id_by_pointer, pointer));
|
||||||
|
|
||||||
if (!id)
|
if (!id)
|
||||||
{
|
{
|
||||||
@ -96,25 +101,62 @@ serialize_object (gpointer key, gpointer value, gpointer data)
|
|||||||
SaveContext *context = data;
|
SaveContext *context = data;
|
||||||
ProfileObject *object = key;
|
ProfileObject *object = key;
|
||||||
|
|
||||||
g_string_append_printf (context->str, "<object id=%d name=%s total=%d self=%d/>\n",
|
g_string_append_printf (context->str, " <object id=%d name=\"%s\" total=%d self=%d/>\n",
|
||||||
get_id (context, object),
|
get_id (context, object),
|
||||||
object->name,
|
object->name,
|
||||||
object->total,
|
object->total,
|
||||||
object->self);
|
object->self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
serialize_call_tree (Node *node, SaveContext *context)
|
||||||
|
{
|
||||||
|
if (!node)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_string_append_printf (context->str,
|
||||||
|
" <node id=%d object=%d siblings=%d children=%d parent=%d next=%d total=%d self=%d>\n",
|
||||||
|
get_id (context, node),
|
||||||
|
get_id (context, node->object),
|
||||||
|
get_id (context, node->siblings),
|
||||||
|
get_id (context, node->children),
|
||||||
|
get_id (context, node->parent),
|
||||||
|
get_id (context, node->next),
|
||||||
|
node->total,
|
||||||
|
node->self);
|
||||||
|
|
||||||
|
serialize_call_tree (node->siblings, context);
|
||||||
|
serialize_call_tree (node->children, context);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
profile_save (Profile *profile,
|
profile_save (Profile *profile,
|
||||||
const char *file_name,
|
const char *file_name,
|
||||||
GError **err)
|
GError **err)
|
||||||
{
|
{
|
||||||
GString *str = g_string_new ("");
|
SaveContext context;
|
||||||
|
|
||||||
g_string_append_printf (str, "<profile>\n");
|
context.str = g_string_new ("");
|
||||||
|
context.id_by_pointer = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||||
|
context.pointer_by_id = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||||
|
context.last_id = 0;
|
||||||
|
|
||||||
g_hash_table_foreach (profile->nodes_by_object, serialize_object, str);
|
g_string_append_printf (context.str, "<profile>\n <objects>\n");
|
||||||
g_string_append_printf (str, "</profile>\n");
|
|
||||||
/* FIXME */
|
g_hash_table_foreach (profile->nodes_by_object, serialize_object, &context);
|
||||||
|
|
||||||
|
g_string_append_printf (context.str, " </objects>\n <nodes>\n");
|
||||||
|
|
||||||
|
serialize_call_tree (profile->call_tree, &context);
|
||||||
|
|
||||||
|
g_string_append_printf (context.str, " </nodes>\n</profile>\n");
|
||||||
|
|
||||||
|
g_hash_table_destroy (context.id_by_pointer);
|
||||||
|
g_hash_table_destroy (context.pointer_by_id);
|
||||||
|
|
||||||
|
g_print (context.str->str);
|
||||||
|
|
||||||
|
g_string_free (context.str, TRUE);
|
||||||
|
|
||||||
/* Actually the way to fix this is probably to save StackStashes instead
|
/* Actually the way to fix this is probably to save StackStashes instead
|
||||||
* of profiles
|
* of profiles
|
||||||
|
|||||||
36
sysprof.c
36
sysprof.c
@ -331,23 +331,14 @@ fill_main_list (Application *app)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_profile_toggled (gpointer widget, gpointer data)
|
ensure_profile (Application *app)
|
||||||
{
|
{
|
||||||
Application *app = data;
|
if (app->profile)
|
||||||
|
|
||||||
if (app->generating_profile || !gtk_toggle_tool_button_get_active (widget))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (app->profile)
|
|
||||||
profile_free (app->profile);
|
|
||||||
|
|
||||||
/* take care of reentrancy */
|
/* take care of reentrancy */
|
||||||
app->generating_profile = TRUE;
|
|
||||||
|
|
||||||
app->profile = profile_new (app->stash);
|
app->profile = profile_new (app->stash);
|
||||||
|
|
||||||
app->generating_profile = FALSE;
|
|
||||||
|
|
||||||
fill_main_list (app);
|
fill_main_list (app);
|
||||||
|
|
||||||
app->state = DISPLAYING;
|
app->state = DISPLAYING;
|
||||||
@ -361,6 +352,23 @@ on_profile_toggled (gpointer widget, gpointer data)
|
|||||||
update_sensitivity (app);
|
update_sensitivity (app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_profile_toggled (gpointer widget, gpointer data)
|
||||||
|
{
|
||||||
|
Application *app = data;
|
||||||
|
|
||||||
|
if (gtk_toggle_tool_button_get_active (widget))
|
||||||
|
{
|
||||||
|
if (app->profile)
|
||||||
|
{
|
||||||
|
profile_free (app->profile);
|
||||||
|
app->profile = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_profile (app);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sorry (GtkWidget *parent_window,
|
sorry (GtkWidget *parent_window,
|
||||||
const gchar *format,
|
const gchar *format,
|
||||||
@ -410,7 +418,13 @@ on_save_as_clicked (gpointer widget, gpointer data)
|
|||||||
{
|
{
|
||||||
Application *app = data;
|
Application *app = data;
|
||||||
|
|
||||||
|
ensure_profile (app);
|
||||||
|
|
||||||
|
profile_save (app->profile, NULL, NULL);
|
||||||
|
|
||||||
|
#if 0
|
||||||
sorry (NULL, "Saving profiles is not yet implemented.");
|
sorry (NULL, "Saving profiles is not yet implemented.");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (app)
|
if (app)
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user