mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
Simpler message formatting
This commit is contained in:
10
collector.c
10
collector.c
@ -405,8 +405,6 @@ collector_new (CollectorFunc callback,
|
|||||||
static void
|
static void
|
||||||
process_mmap (Collector *collector, mmap_event_t *mmap)
|
process_mmap (Collector *collector, mmap_event_t *mmap)
|
||||||
{
|
{
|
||||||
g_print ("%d %d => %s at %llx\n", mmap->pid, mmap->tid, mmap->filename, mmap->addr);
|
|
||||||
|
|
||||||
tracker_add_map (collector->tracker,
|
tracker_add_map (collector->tracker,
|
||||||
mmap->pid,
|
mmap->pid,
|
||||||
mmap->addr,
|
mmap->addr,
|
||||||
@ -482,8 +480,8 @@ process_event (Collector *collector,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
g_print ("unknown event: %d (%d)\n",
|
g_warning ("Got unknown event: %d (%d)\n",
|
||||||
event->header.type, event->header.size);
|
event->header.type, event->header.size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -496,8 +494,6 @@ collector_start (Collector *collector,
|
|||||||
GList *list;
|
GList *list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
g_print ("starting\n");
|
|
||||||
|
|
||||||
if (!collector->stash)
|
if (!collector->stash)
|
||||||
collector->stash = stack_stash_new (NULL);
|
collector->stash = stack_stash_new (NULL);
|
||||||
if (!collector->tracker)
|
if (!collector->tracker)
|
||||||
@ -520,8 +516,6 @@ collector_start (Collector *collector,
|
|||||||
for (list = collector->counters; list != NULL; list = list->next)
|
for (list = collector->counters; list != NULL; list = list->next)
|
||||||
counter_enable (list->data);
|
counter_enable (list->data);
|
||||||
|
|
||||||
g_print ("started\n");
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
56
tracker.c
56
tracker.c
@ -2,6 +2,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <glib/gprintf.h>
|
||||||
|
|
||||||
#include "tracker.h"
|
#include "tracker.h"
|
||||||
#include "stackstash.h"
|
#include "stackstash.h"
|
||||||
@ -88,7 +89,8 @@ fake_new_process (tracker_t *tracker, pid_t pid)
|
|||||||
{
|
{
|
||||||
if (strncmp ("Name:", lines[i], 5) == 0)
|
if (strncmp ("Name:", lines[i], 5) == 0)
|
||||||
{
|
{
|
||||||
tracker_add_process (tracker, pid, g_strstrip (strchr (lines[i], ':')));
|
tracker_add_process (
|
||||||
|
tracker, pid, g_strstrip (strchr (lines[i], ':') + 1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,6 +192,7 @@ tracker_t *
|
|||||||
tracker_new (void)
|
tracker_new (void)
|
||||||
{
|
{
|
||||||
tracker_t *tracker = g_new0 (tracker_t, 1);
|
tracker_t *tracker = g_new0 (tracker_t, 1);
|
||||||
|
GTimeVal before, after;
|
||||||
|
|
||||||
tracker->n_event_bytes = 0;
|
tracker->n_event_bytes = 0;
|
||||||
tracker->n_allocated_bytes = DEFAULT_SIZE;
|
tracker->n_allocated_bytes = DEFAULT_SIZE;
|
||||||
@ -197,8 +200,6 @@ tracker_new (void)
|
|||||||
|
|
||||||
tracker->stash = stack_stash_new (NULL);
|
tracker->stash = stack_stash_new (NULL);
|
||||||
|
|
||||||
GTimeVal before, after;
|
|
||||||
|
|
||||||
g_get_current_time (&before);
|
g_get_current_time (&before);
|
||||||
|
|
||||||
populate_from_proc (tracker);
|
populate_from_proc (tracker);
|
||||||
@ -286,8 +287,6 @@ tracker_add_map (tracker_t * tracker,
|
|||||||
event.inode = inode;
|
event.inode = inode;
|
||||||
|
|
||||||
tracker_append (tracker, &event, sizeof (event));
|
tracker_append (tracker, &event, sizeof (event));
|
||||||
|
|
||||||
g_print (" Added new map: %d (%s) %llx -- %llx \n", pid, filename, start, end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -583,8 +582,10 @@ get_kernel_symbols (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!kernel_syms)
|
if (!kernel_syms)
|
||||||
|
{
|
||||||
g_print ("Warning: /proc/kallsyms could not be "
|
g_print ("Warning: /proc/kallsyms could not be "
|
||||||
"read. Kernel symbols will not be available\n");
|
"read. Kernel symbols will not be available\n");
|
||||||
|
}
|
||||||
|
|
||||||
initialized = TRUE;
|
initialized = TRUE;
|
||||||
}
|
}
|
||||||
@ -642,15 +643,26 @@ process_locate_map (process_t *process, gulong addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
make_message (state_t *state, const char *message)
|
make_message (state_t *state, const char *format, ...)
|
||||||
{
|
{
|
||||||
char *result = g_hash_table_lookup (state->unique_comms, message);
|
va_list args;
|
||||||
|
char *message;
|
||||||
|
char *result;
|
||||||
|
|
||||||
if (!result)
|
va_start (args, format);
|
||||||
|
g_vasprintf (&message, format, args);
|
||||||
|
va_end (args);
|
||||||
|
|
||||||
|
result = g_hash_table_lookup (state->unique_comms, message);
|
||||||
|
if (result)
|
||||||
{
|
{
|
||||||
result = g_strdup (message);
|
g_free (message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = message;
|
||||||
|
|
||||||
g_hash_table_insert (state->unique_comms, (char *)result, (char *)result);
|
g_hash_table_insert (state->unique_comms, result, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -676,11 +688,7 @@ lookup_symbol (state_t *state,
|
|||||||
|
|
||||||
if (!map)
|
if (!map)
|
||||||
{
|
{
|
||||||
char *message = g_strdup_printf ("No map [%s]", process->comm);
|
sym = make_message (state, "No map [%s]", process->comm);
|
||||||
|
|
||||||
sym = make_message (state, message);
|
|
||||||
|
|
||||||
g_free (message);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -697,11 +705,7 @@ lookup_symbol (state_t *state,
|
|||||||
/* If the inodes don't match, it's probably because the
|
/* If the inodes don't match, it's probably because the
|
||||||
* file has changed since the process was started.
|
* file has changed since the process was started.
|
||||||
*/
|
*/
|
||||||
char *message = g_strdup_printf ("inode mismatch for %s", map->filename);
|
sym = make_message (state, "%s: inode mismatch", map->filename);
|
||||||
|
|
||||||
sym = make_message (state, message);
|
|
||||||
|
|
||||||
g_free (message);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -757,10 +761,10 @@ static void
|
|||||||
process_sample (state_t *state, StackStash *resolved, sample_t *sample)
|
process_sample (state_t *state, StackStash *resolved, sample_t *sample)
|
||||||
{
|
{
|
||||||
const context_info_t *context = NULL;
|
const context_info_t *context = NULL;
|
||||||
|
const char *cmdline;
|
||||||
uint64_t *resolved_traces;
|
uint64_t *resolved_traces;
|
||||||
process_t *process;
|
process_t *process;
|
||||||
StackNode *n;
|
StackNode *n;
|
||||||
char *cmdline;
|
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
process = g_hash_table_lookup (
|
process = g_hash_table_lookup (
|
||||||
@ -811,15 +815,7 @@ process_sample (state_t *state, StackStash *resolved, sample_t *sample)
|
|||||||
resolved_traces[len++] = POINTER_TO_U64 (symbol);
|
resolved_traces[len++] = POINTER_TO_U64 (symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdline = g_hash_table_lookup (
|
cmdline = make_message (state, "[%s]", process->comm);
|
||||||
state->unique_comms, process->comm);
|
|
||||||
|
|
||||||
if (!cmdline)
|
|
||||||
{
|
|
||||||
cmdline = g_strdup (process->comm);
|
|
||||||
|
|
||||||
g_hash_table_insert (state->unique_comms, cmdline, cmdline);
|
|
||||||
}
|
|
||||||
|
|
||||||
resolved_traces[len++] = POINTER_TO_U64 (cmdline);
|
resolved_traces[len++] = POINTER_TO_U64 (cmdline);
|
||||||
resolved_traces[len++] = POINTER_TO_U64 (
|
resolved_traces[len++] = POINTER_TO_U64 (
|
||||||
|
|||||||
Reference in New Issue
Block a user