gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r7709 - in flightrecorder/src: include libflightrecorder


From: gnunet
Subject: [GNUnet-SVN] r7709 - in flightrecorder/src: include libflightrecorder
Date: Sun, 14 Sep 2008 08:50:10 -0600 (MDT)

Author: durner
Date: 2008-09-14 08:50:10 -0600 (Sun, 14 Sep 2008)
New Revision: 7709

Modified:
   flightrecorder/src/include/flightrecorder.h
   flightrecorder/src/libflightrecorder/clientapi.c
   flightrecorder/src/libflightrecorder/func.c
   flightrecorder/src/libflightrecorder/opt.c
   flightrecorder/src/libflightrecorder/stack_trace.c
   flightrecorder/src/libflightrecorder/threads.c
Log:
fixes

Modified: flightrecorder/src/include/flightrecorder.h
===================================================================
--- flightrecorder/src/include/flightrecorder.h 2008-09-14 11:58:22 UTC (rev 
7708)
+++ flightrecorder/src/include/flightrecorder.h 2008-09-14 14:50:10 UTC (rev 
7709)
@@ -50,6 +50,14 @@
 char *fr_strdup (char *p);
 void fr_free(void *p);
 
+/**
+ * @brief Initializes a session with the flightrecorder server
+ * @param server server name, NULL for in-process operation
+ * @param port server port
+ * @return 1 on success, 0 otherwise
+ */
+int fr_init(char *server, unsigned int port);
+
 /* --- Sessions --- */
 struct FR_Session *fr_session_create();
 void fr_session_destroy(struct FR_Session *ses);

Modified: flightrecorder/src/libflightrecorder/clientapi.c
===================================================================
--- flightrecorder/src/libflightrecorder/clientapi.c    2008-09-14 11:58:22 UTC 
(rev 7708)
+++ flightrecorder/src/libflightrecorder/clientapi.c    2008-09-14 14:50:10 UTC 
(rev 7709)
@@ -128,5 +128,5 @@
 
 void fr_opt_cleanup()
 {
- fr_srv_opt_cleanup(fr_session_get_local());
+  fr_srv_opt_cleanup(fr_session_get_local());
 }

Modified: flightrecorder/src/libflightrecorder/func.c
===================================================================
--- flightrecorder/src/libflightrecorder/func.c 2008-09-14 11:58:22 UTC (rev 
7708)
+++ flightrecorder/src/libflightrecorder/func.c 2008-09-14 14:50:10 UTC (rev 
7709)
@@ -25,10 +25,7 @@
 int fr_srv_func_enter(struct FR_Session *ses, unsigned int tid, char *file, 
unsigned int line, char *function)
 {
        if (fr_srv_opt_get_int(ses, FR_OPT_RECORD_STACK_TRACE))
-       {
-               if (!fr_srv_st_enter(ses, tid, file, line, function))
-                       return 0;
-       }
+               return fr_srv_st_enter(ses, tid, file, line, function);
 
        return 1;
 }
@@ -36,10 +33,7 @@
 int fr_srv_func_leave(struct FR_Session *ses, unsigned int tid, char *file, 
unsigned int line, char *function)
 {
        if (fr_srv_opt_get_int(ses, FR_OPT_RECORD_STACK_TRACE))
-       {
-               if (!fr_srv_st_leave(ses, tid, file, line, function))
-                       return 0;
-       }
+               return fr_srv_st_leave(ses, tid, file, line, function);
 
        return 1;
 }
@@ -47,10 +41,7 @@
 int fr_srv_func_add_info(struct FR_Session *ses, unsigned int tid, char *info)
 {
        if (fr_srv_opt_get_int(ses, FR_OPT_RECORD_STACK_TRACE))
-       {
-               if (!fr_srv_st_add_info(ses, tid, info))
-                       return 0;
-       }
+               return fr_srv_st_add_info(ses, tid, info);
 
        return 1;
 }

Modified: flightrecorder/src/libflightrecorder/opt.c
===================================================================
--- flightrecorder/src/libflightrecorder/opt.c  2008-09-14 11:58:22 UTC (rev 
7708)
+++ flightrecorder/src/libflightrecorder/opt.c  2008-09-14 14:50:10 UTC (rev 
7709)
@@ -31,32 +31,30 @@
 
        found = 0;
        option = ses->options;
-       for (idx = 0; idx <= ses->option_count; idx++)
+       for (idx = ses->option_count; idx > 0; idx--)
        {
                if (opt == option->opt)
                {
                        found = 1;
                        break;
                }
+               option++;
        }
 
        if (!found)
        {
-               if (ses->option_count == 0)
-                       ses->options = (struct FR_Option_Entry *) 
fr_malloc(sizeof(struct FR_Option_Entry));
-               else
-                       ses->options = (struct FR_Option_Entry *) 
fr_realloc(ses->options, (ses->option_count + 1) * sizeof(struct 
FR_Option_Entry));
+               ses->options = (struct FR_Option_Entry *) 
fr_realloc(ses->options,
+                   (ses->option_count + 1) * sizeof(struct FR_Option_Entry));
+               option = ses->options + ses->option_count;
+               ses->option_count++;
        }
 
        if (!ses->options)
                return 0;
 
-       option = ses->options + ses->option_count;
-
        option->opt = opt;
        option->val = fr_malloc(len);
        memcpy(option->val, val, len);
-       ses->option_count++;
 
        return 1;
 }
@@ -77,10 +75,11 @@
        unsigned int idx;
 
        option = ses->options;
-       for (idx = 0; idx <= ses->option_count; idx++)
+       for (idx = ses->option_count; idx > 0; idx--)
        {
                if (opt == option->opt)
                        return option->val;
+               option++;
        }
 
        return NULL;
@@ -102,7 +101,7 @@
        unsigned int idx;
 
        opt = ses->options;
-       for (idx = 0; idx <= ses->option_count; idx++)
+       for (idx = ses->option_count; idx > 0; idx--)
        {
                fr_free(opt->val);
                opt++;

Modified: flightrecorder/src/libflightrecorder/stack_trace.c
===================================================================
--- flightrecorder/src/libflightrecorder/stack_trace.c  2008-09-14 11:58:22 UTC 
(rev 7708)
+++ flightrecorder/src/libflightrecorder/stack_trace.c  2008-09-14 14:50:10 UTC 
(rev 7709)
@@ -29,16 +29,8 @@
   struct StackTrace *trace;
   unsigned idx;
 
-  if (!ses->trace_count)
-  {
-    ses->traces = (struct StackTrace *) fr_malloc(sizeof(struct StackTrace));
-    ses->trace_count++;
-
-    return ses->traces;
-  }
-
   trace = ses->traces;
-  for (idx = 0; idx < ses->trace_count; idx++)
+  for (idx = ses->trace_count; idx > 0; idx--)
   {
     if (fr_thread_cmp(trace->tid, tid))
       return trace;
@@ -46,8 +38,8 @@
       trace++;
   }
 
-  ses->traces = (struct StackTrace *) fr_realloc(ses->traces, 
++ses->trace_count * sizeof(struct StackTrace));
-
+  ses->traces = (struct StackTrace *) fr_realloc(ses->traces,
+      ++ses->trace_count * sizeof(struct StackTrace));
   if (!ses->traces)
     return NULL;
 
@@ -76,18 +68,16 @@
   if (!trace)
     return 0;
 
-  if (trace->depth == 0)
-    trace->entries = (struct StackTraceEntry *) fr_malloc(sizeof(struct 
StackTraceEntry));
-  else
-    trace->entries = (struct StackTraceEntry *) fr_realloc(trace->entries, 
(trace->depth + 1) * sizeof(struct StackTraceEntry));
+  trace->entries = (struct StackTraceEntry *) fr_realloc(trace->entries,
+      (trace->depth + 1) * sizeof(struct StackTraceEntry));
   if (!trace->entries)
     return 0;
 
   trace->depth++;
   entry = trace->entries + trace->depth - 1;
-  entry->file = file;
+  entry->file = fr_strdup(file);
   entry->line = line;
-  entry->function = function;
+  entry->function = fr_strdup(function);
   entry->info = NULL;
   entry->info_count = 0;
 
@@ -120,8 +110,10 @@
     for(idx = 0; idx < entry->info_count; idx++)
       fr_free(entry->info[idx]);
 
+    free(entry->file);
+    free(entry->function);
     trace->entries = (struct StackTraceEntry *) fr_realloc(trace->entries, 
--trace->depth * sizeof(struct StackTraceEntry));
-    if (!trace->entries)
+    if (!trace->entries && trace->entries)
       return 0;
   }
   else
@@ -150,10 +142,7 @@
     return 0;
 
   entry = trace->entries + trace->depth - 1;
-  if (entry->info_count)
-    entry->info = (char **) fr_realloc(entry->info, (entry->info_count + 1) * 
sizeof(char *));
-  else
-    entry->info = (char **) fr_malloc(sizeof(char *));
+  entry->info = (char **) fr_realloc(entry->info, (entry->info_count + 1) * 
sizeof(char *));
 
   if (!entry->info)
     return 0;
@@ -204,12 +193,12 @@
   struct StackTraceEntry *entry;
   unsigned idx;
 
-  entry = trace->entries;
+  entry = trace->entries + trace->depth - 1;
   for (idx = trace->depth; idx > 0; idx--)
   {
     if (! iter(entry))
       break;
 
-    entry++;
+    entry--;
   }
 }

Modified: flightrecorder/src/libflightrecorder/threads.c
===================================================================
--- flightrecorder/src/libflightrecorder/threads.c      2008-09-14 11:58:22 UTC 
(rev 7708)
+++ flightrecorder/src/libflightrecorder/threads.c      2008-09-14 14:50:10 UTC 
(rev 7709)
@@ -1,4 +1,4 @@
-/* 
+/*
    libflightrecorder - Client library for flightrecorder, a recorder for
    runtime information gathered by AOP advices or other process internal
    checks
@@ -41,7 +41,7 @@
 #elif HAVE_PTHREADS
   return (unsigned int) pthread_self();
 #else
-  #error Port fr_util_get_tid()
+  #error Port fr_thread_get_tid()
 #endif
 }
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]