[sysprof/ftrace: 12/16] Get rid of read_entry() function



commit 5b10248de615a5670232b536ec39ecbbc2efbe9e
Author: Søren Sandmann Pedersen <sandmann daimi au dk>
Date:   Fri Aug 14 02:19:22 2009 -0400

    Get rid of read_entry() function

 collector.c |   36 +++++++++++++-----------------------
 1 files changed, 13 insertions(+), 23 deletions(-)
---
diff --git a/collector.c b/collector.c
index 068c017..8405121 100644
--- a/collector.c
+++ b/collector.c
@@ -125,8 +125,6 @@ static void
 add_trace_to_stash (const CPUInfo *info,
 		    StackStash    *stash)
 {
-    int i;
-    gulong *addrs;
     Process *process = process_get_from_pid (info->pid);
     int n_addresses;
     int n_kernel_words;
@@ -134,6 +132,8 @@ add_trace_to_stash (const CPUInfo *info,
     gulong addrs_stack[2048];
     int n_alloc;
     gboolean bad = FALSE;
+    gulong *addrs;
+    int i;
 
     n_addresses = info->n_addresses;
     n_kernel_words = info->n_kernel_words;
@@ -161,7 +161,6 @@ add_trace_to_stash (const CPUInfo *info,
     }
 
     /* Add user addresses */
-
     for (i = 0; i < n_addresses; ++i)
     {
 	gulong addr = (gulong)info->addresses[i];
@@ -275,21 +274,6 @@ dump_entry (Entry *entry)
     g_printerr ("\n");
 }
 
-static void
-read_entry (const guchar *input, Entry *entry)
-{
-    memcpy (entry, input, sizeof (Entry));
-    
-    if (entry->type < -1 || entry->type > 3 || entry->pid < 0)
-    {
-	g_printerr ("bad entry: %ld (pid: %d)\n", entry->type, entry->pid);
-
-	dump_entry (entry);
-	
-	g_assert (FALSE);
-    }
-}
-	
 static CPUInfo *
 find_cpu_info (Collector *collector, int pid)
 {
@@ -309,6 +293,15 @@ process_entry (Collector *collector, Entry *entry)
 {
     CPUInfo *info = NULL;
 
+    if (entry->type < -1 || entry->type > 3 || entry->pid < 0)
+    {
+	g_printerr ("bad entry: %ld (pid: %d)\n", entry->type, entry->pid);
+
+	dump_entry (entry);
+	
+	g_assert (FALSE);
+    }
+	
     /* There can be up to N_CPU stacktraces in progress at the same
      * time, but processes can move between CPU's in the middle of
      * the stack-tracing, so we can't have CPU specific states.
@@ -394,10 +387,7 @@ on_read (gpointer data)
 	    s = (const guchar *)collector->input->str;
 	    while (len >= sizeof (Entry))
 	    {
-		Entry entry;
-
-		read_entry (s, &entry);
-		process_entry (collector, &entry);
+		process_entry (collector, (Entry *)s);
 
 		len -= sizeof (Entry);
 		s += sizeof (Entry);
@@ -429,7 +419,7 @@ start_tracing (Collector  *collector,
 	{ SYSPROF_DIR "current_tracer",        "sysprof" },
 	{ SYSPROF_DIR "trace_options",         "raw" },
 	{ SYSPROF_DIR "trace_options",         "bin" },
-	{ SYSPROF_DIR "sysprof_sample_period", "10000" },
+	{ SYSPROF_DIR "sysprof_sample_period", "2000" },
     };
     
     int fd;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]