#include "gnunet_scheduler_lib.h"
#include "gnunet_signal_lib.h"
#include "gnunet_time_lib.h"
+#ifdef LINUX
+#include "execinfo.h"
+#define EXECINFO GNUNET_NO
+#define MAX_TRACE_DEPTH 50
+#endif
#define DEBUG_TASKS GNUNET_NO
*/
enum GNUNET_SCHEDULER_Priority priority;
+#if EXECINFO
+ /**
+ * Array of strings which make up a backtrace from the point when this
+ * task was scheduled (essentially, who scheduled the task?)
+ */
+ char **backtrace_strings;
+
+ /**
+ * Size of the backtrace_strings array
+ */
+ int num_backtrace_strings;
+#endif
+
};
GNUNET_NETWORK_fdset_destroy (t->read_set);
if (NULL != t->write_set)
GNUNET_NETWORK_fdset_destroy (t->write_set);
+#if EXECINFO
+ GNUNET_free (t->backtrace_strings);
+#endif
GNUNET_free (t);
}
enum GNUNET_SCHEDULER_Reason reason)
{
struct Task *t;
-
+#if EXECINFO
+ void *backtrace_array[50];
+#endif
t = GNUNET_malloc (sizeof (struct Task));
+#if EXECINFO
+ t->num_backtrace_strings = backtrace(backtrace_array, 50);
+ t->backtrace_strings = backtrace_symbols(backtrace_array, t->num_backtrace_strings);
+#endif
t->callback = task;
t->callback_cls = task_cls;
t->id = ++sched->last_id;
GNUNET_SCHEDULER_Task task, void *task_cls)
{
struct Task *t;
+#if EXECINFO
+ void *backtrace_array[MAX_TRACE_DEPTH];
+#endif
+ GNUNET_assert (NULL != task);
t = GNUNET_malloc (sizeof (struct Task));
t->callback = task;
t->callback_cls = task_cls;
+#if EXECINFO
+ t->num_backtrace_strings = backtrace(backtrace_array, MAX_TRACE_DEPTH);
+ t->backtrace_strings = backtrace_symbols(backtrace_array, t->num_backtrace_strings);
+#endif
if (rs != NULL)
{
t->read_set = GNUNET_NETWORK_fdset_create ();