pythontracer-8.10.16/0000755000175000017500000000000011075706335013720 5ustar peakerpeakerpythontracer-8.10.16/tracer/0000755000175000017500000000000011075706213015173 5ustar peakerpeakerpythontracer-8.10.16/tracer/pytracer.pyx0000644000175000017500000002160611075672727017607 0ustar peakerpeakercimport posix cimport rotatingtree include "times.pyx" include "memory.pyx" include "python.pyx" include "darray.pyx" include "files.pyx" include "graphfile.pxd" import os import sys # This is the format that gets written directly to file: ctypedef short CodeIndex ctypedef struct CodeIndexEntry: rotatingtree.rotating_node_t header CodeIndex code_index ctypedef struct InvocationData: CodeIndex index int lineno double user_time, sys_time, real_time ctypedef struct CallInvocation: InvocationData data # List of children darray children cdef void call_invocation_empty(CallInvocation *invocation): memset(invocation, 0, sizeof(invocation[0])) darray_init(&invocation.children, sizeof(graphfile_linkable_t)) cdef fwrite_string(object name, FILE *index_file): cdef char *name_buf cdef Py_ssize_t name_length cdef short short_name_length PyString_AsStringAndSize(name, &name_buf, &name_length) short_name_length = name_length # Don't let overlaps occur assert short_name_length == name_length safe_fwrite(&short_name_length, sizeof(short_name_length), index_file) safe_fwrite(name_buf, name_length, index_file) cdef int freeEntry(rotatingtree.rotating_node_t *header, void *arg): free(header) return 0 class Error(Exception): pass cdef class _Linkable: cdef graphfile_linkable_t linkable cdef class Tracer: cdef readonly object fileobj cdef readonly object index_fileobj cdef rotatingtree.rotating_node_t *written_indexes cdef posix.FILE *index_file cdef graphfile_writer_t writer cdef darray stack cdef posix.pid_t tracer_pid cdef CodeIndex next_code_index cdef object _prev_os_exit def __cinit__(self, fileobj, index_fileobj): self.next_code_index = 0 self.index_file = file_from_obj(index_fileobj) self.index_fileobj = index_fileobj if 0 != graphfile_writer_init(&self.writer, file_from_obj(fileobj)): raise Error("graphfile_writer_init") self.fileobj = fileobj self.tracer_pid = -1 def __dealloc__(self): graphfile_writer_fini(&self.writer) cdef int call_invocation_init(self, CallInvocation *invocation, object code_obj, int lineno, double user_time, double sys_time, double real_time) except -1: invocation.data.index = self._index_of_code(code_obj) invocation.data.lineno = lineno invocation.data.user_time = user_time invocation.data.sys_time = sys_time invocation.data.real_time = real_time darray_init(&invocation.children, sizeof(graphfile_linkable_t)) return 0 cdef int _trace_event(self, object frame, int event, void *trace_arg) except -1: cdef double user_time, sys_time, real_time if self.tracer_pid != posix.getpid(): # Ignore forked children events... Don't let them corrupt # our file. return 0 if event != PyTrace_CALL and event != PyTrace_RETURN: return 0 get_user_sys_times(&user_time, &sys_time) get_real_time(&real_time) if event == PyTrace_CALL: self._push_call(frame.f_code, frame.f_lineno, user_time, sys_time, real_time) else: # event == PyTrace_RETURN: don't assert this for performance reasons self._pop_call(user_time, sys_time, real_time) return 0 cdef int _push_call(self, object code_obj, int lineno, double user_time, double sys_time, double real_time) except -1: cdef CallInvocation *invocation invocation = darray_add(&self.stack) self.call_invocation_init(invocation, code_obj, lineno, user_time, sys_time, real_time) return 0 cdef int _pop_call(self, double user_time, double sys_time, double real_time) except -1: cdef CallInvocation *invocation cdef graphfile_linkable_t linkable cdef graphfile_linkable_t *new_child_ptr invocation = darray_last(&self.stack) invocation.data.user_time = user_time - invocation.data.user_time invocation.data.sys_time = sys_time - invocation.data.sys_time invocation.data.real_time = real_time - invocation.data.real_time self._write(&invocation.data, sizeof(invocation.data), &invocation.children, &linkable) darray_fini(&invocation.children) darray_fast_remove_last(&self.stack) # The parent invocation: invocation = darray_last(&self.stack) new_child_ptr = darray_add(&invocation.children) new_child_ptr[0] = linkable return 0 cdef int _index_of_code(self, object code) except -1: cdef unsigned long key cdef CodeIndexEntry *node # TODO: Is it ok to assume code objects keep around with their ID's? key = id(code) node = rotatingtree.RotatingTree_Get(&self.written_indexes, key) if node != NULL: return node.code_index node = malloc(sizeof(CodeIndexEntry)) node.header.key = key node.code_index = self.next_code_index # Prevent wraparounds: assert self.next_code_index != 0 safe_fwrite(&node.code_index, sizeof(node.code_index), self.index_file) fwrite_string(code.co_filename, self.index_file) fwrite_string(code.co_name, self.index_file) rotatingtree.RotatingTree_Add(&self.written_indexes, &node.header) self.next_code_index = node.code_index + 1 return node.code_index cdef int _write(self, char *buffer, unsigned int buffer_length, darray *children, graphfile_linkable_t *result) except -1: cdef int status status = graphfile_writer_write(&self.writer, buffer, buffer_length, children.array, children.used_count, result) if status != 0: raise Error("graphfile_writer_write") return 0 cdef _push_root(self): cdef CallInvocation *invocation invocation = darray_add(&self.stack) call_invocation_empty(invocation) cdef _pop_root(self): cdef graphfile_linkable_t root cdef CallInvocation *invocation assert self.stack.used_count == 1 # darray may have moved around due to re-allocations, re-take pointer: invocation = darray_last(&self.stack) self._write(NULL, 0, &invocation.children, &root) darray_fast_remove_last(&self.stack) if 0 != graphfile_writer_set_root(&self.writer, &root): raise Error("graphfile_writer_set_root") cdef _pop_to_root(self): cdef double user_time, sys_time, real_time get_user_sys_times(&user_time, &sys_time) get_real_time(&real_time) while self.stack.used_count > 1: self._pop_call(user_time, sys_time, real_time) self._pop_root() def _wrap_os_exit(self, status): self._pop_to_root() self._prev_os_exit(status) def trace(self, func): assert self.tracer_pid == -1, "Cannot create a nested trace" darray_init(&self.stack, sizeof(CallInvocation)) self._push_root() self.tracer_pid = posix.getpid() self.written_indexes = rotatingtree.EMPTY_ROTATING_TREE try: PyEval_SetProfile(&callback, self) self._prev_os_exit = os._exit os._exit = self._wrap_os_exit try: try: try: return func() finally: assert os._exit == self._wrap_os_exit os._exit = self._prev_os_exit PyEval_SetProfile(NULL, None) except: if self.tracer_pid == posix.getpid(): exc_type, exc_value, exc_tb = sys.exc_info() try: self._pop_root() except: # Raise the original exception raise exc_type, exc_value, exc_tb raise finally: # Normal return (we already covered exceptional # return) requires finally, as we use "return" above if self.tracer_pid == posix.getpid(): self._pop_root() finally: rotatingtree.RotatingTree_Enum(self.written_indexes, &freeEntry, NULL) self.written_indexes = NULL self.tracer_pid = -1 darray_fini(&self.stack) cdef int callback(Tracer tracer, object frame, int event, void *trace_arg) except -1: tracer._trace_event(frame, event, trace_arg) return 0 pythontracer-8.10.16/tracer/rotatingtree.c0000664000175000017500000000541211066155564020061 0ustar peakerpeaker#include "rotatingtree.h" #define KEY_LOWER_THAN(key1, key2) ((char*)(key1) < (char*)(key2)) /* The randombits() function below is a fast-and-dirty generator that * is probably irregular enough for our purposes. Note that it's biased: * I think that ones are slightly more probable than zeroes. It's not * important here, though. */ static unsigned int random_value = 1; static unsigned int random_stream = 0; static int randombits(int bits) { int result; if (random_stream < (1U << bits)) { random_value *= 1082527; random_stream = random_value; } result = random_stream & ((1<>= bits; return result; } /* Insert a new node into the tree. (*root) is modified to point to the new root. */ void RotatingTree_Add(rotating_node_t **root, rotating_node_t *node) { while (*root != NULL) { if (KEY_LOWER_THAN(node->key, (*root)->key)) root = &((*root)->left); else root = &((*root)->right); } node->left = NULL; node->right = NULL; *root = node; } /* Locate the node with the given key. This is the most complicated function because it occasionally rebalances the tree to move the resulting node closer to the root. */ rotating_node_t * RotatingTree_Get(rotating_node_t **root, void *key) { if (randombits(3) != 4) { /* Fast path, no rebalancing */ rotating_node_t *node = *root; while (node != NULL) { if (node->key == key) return node; if (KEY_LOWER_THAN(key, node->key)) node = node->left; else node = node->right; } return NULL; } else { rotating_node_t **pnode = root; rotating_node_t *node = *pnode; rotating_node_t *next; int rotate; if (node == NULL) return NULL; while (1) { if (node->key == key) return node; rotate = !randombits(1); if (KEY_LOWER_THAN(key, node->key)) { next = node->left; if (next == NULL) return NULL; if (rotate) { node->left = next->right; next->right = node; *pnode = next; } else pnode = &(node->left); } else { next = node->right; if (next == NULL) return NULL; if (rotate) { node->right = next->left; next->left = node; *pnode = next; } else pnode = &(node->right); } node = next; } } } /* Enumerate all nodes in the tree. The callback enumfn() should return zero to continue the enumeration, or non-zero to interrupt it. A non-zero value is directly returned by RotatingTree_Enum(). */ int RotatingTree_Enum(rotating_node_t *root, rotating_tree_enum_fn enumfn, void *arg) { int result; rotating_node_t *node; while (root != NULL) { result = RotatingTree_Enum(root->left, enumfn, arg); if (result != 0) return result; node = root->right; result = enumfn(root, arg); if (result != 0) return result; root = node; } return 0; } pythontracer-8.10.16/tracer/rotatingtree.h0000664000175000017500000000160511071710155020053 0ustar peakerpeaker/* "Rotating trees" (Armin Rigo) * * Google "splay trees" for the general idea. * * It's a dict-like data structure that works best when accesses are not * random, but follow a strong pattern. The one implemented here is for * access patterns where the same small set of keys is looked up over * and over again, and this set of keys evolves slowly over time. */ #include #define EMPTY_ROTATING_TREE ((rotating_node_t *)NULL) typedef struct rotating_node_s rotating_node_t; typedef int (*rotating_tree_enum_fn) (rotating_node_t *node, void *arg); struct rotating_node_s { void *key; rotating_node_t *left; rotating_node_t *right; }; void RotatingTree_Add(rotating_node_t **root, rotating_node_t *node); rotating_node_t* RotatingTree_Get(rotating_node_t **root, void *key); int RotatingTree_Enum(rotating_node_t *root, rotating_tree_enum_fn enumfn, void *arg); pythontracer-8.10.16/tracer/pytracefile.py0000644000175000017500000000607311075706213020062 0ustar peakerpeaker#!/usr/bin/env python from __future__ import with_statement import sys import os import traceback import getopt from pytracer import Tracer import pytracerview from contextlib import nested def exec_wrapper(python_program): def wrapper(): g = {'__name__':'__main__'} try: execfile(python_program, g, g) except: print "Traced function completed with an exception:" traceback.print_exc() else: print "Traced function completed successfully" return wrapper def usage(): print """\ Tracing: %s [-h|--help] [-o|--output ] [-s] Viewing: %s [-v|--view ] Tracing: -o or --output specify the prefix to use for generating the output filenames when running a trace. By default, if no prefix is given, "profile.out" will be used as a prefix. This will generate two files: "profile.out" and "profile.out.index". If -s or --single is given, the trace will also be followed by the viewer. Viewing: If -v or --view is given, then no trace will occur, and no output filename can be specified. Instead, the trace viewer will be launched to view a previous trace result specified by the input prefix. """ % (sys.argv[0], sys.argv[0]) def main(): try: opts, args = getopt.getopt(sys.argv[1:], "hso:v:", ["help", "single", "output=", "view="]) except getopt.GetoptError, err: print str(err) usage() sys.exit(2) output_prefix = None view_prefix = None also_view = False for o, val in opts: if o in ("-h", "--help"): usage() sys.exit() elif o in ("-o", "--output"): output_prefix = val elif o in ("-v", "--view"): view_prefix = val elif o in ("-s", "--single"): also_view = True else: assert False, "unhandled option" if view_prefix is not None: # View mode: if output_prefix is not None or also_view or args: print "Cannot both view and output a trace." print "Use -s to trace & view" sys.exit(3) elif output_prefix is None: output_prefix = "profile.out" if output_prefix is not None: # Trace mode: if not args: print "No given" usage() sys.exit(4) sys.argv = args python_program = sys.argv[0] dirname = os.path.dirname(python_program) sys.path.insert(0, dirname) print "Tracing into %r" % (output_prefix,) with nested(open(output_prefix, "wb"), open(output_prefix + '.index', "wb")) as (output_fileobj, index_fileobj): tracer = Tracer(output_fileobj, index_fileobj) tracer.trace(exec_wrapper(python_program)) if also_view: view_prefix = output_prefix if view_prefix is not None: pytracerview.tracerview(view_prefix) if __name__ == "__main__": main() pythontracer-8.10.16/tracer/test.py0000644000175000017500000000026311066155433016527 0ustar peakerpeakerimport time def g(): time.sleep(0.1) print 'g' def h(): print 'h' 1/0 def f(): for i in xrange(10): g() h() if __name__ == '__main__': f() pythontracer-8.10.16/tracer/pytracer.c0000644000175000017500000026037611075676657017230 0ustar peakerpeaker/* Generated by Pyrex 0.9.6.4 on Thu Oct 16 19:45:19 2008 */ #define PY_SSIZE_T_CLEAN #include "Python.h" #include "structmember.h" #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #if PY_VERSION_HEX < 0x02050000 typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX #define PY_SSIZE_T_MIN INT_MIN #define PyInt_FromSsize_t(z) PyInt_FromLong(z) #define PyInt_AsSsize_t(o) PyInt_AsLong(o) #endif #ifndef WIN32 #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #endif #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #include #include "sys/time.h" #include "time.h" #include "sys/resource.h" #include "sys/param.h" #include "stdlib.h" #include "string.h" #include "graphfile.h" #include "errno.h" #include "sys/types.h" #include "stdio.h" #include "unistd.h" #include "rotatingtree.h" typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ static PyObject *__pyx_m; static PyObject *__pyx_b; static int __pyx_lineno; static char *__pyx_filename; static char **__pyx_f; static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ static void __Pyx_WriteUnraisable(char *name); /*proto*/ static PyObject *__Pyx_UnpackItem(PyObject *); /*proto*/ static int __Pyx_EndUnpack(PyObject *); /*proto*/ static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ static void __Pyx_AddTraceback(char *funcname); /*proto*/ /* Declarations from posix */ /* Declarations from rotatingtree */ /* Declarations from pytracer */ typedef struct { void *array; size_t item_size; unsigned int used_count; unsigned int allocated_count; } __pyx_t_8pytracer_darray; typedef short __pyx_t_8pytracer_CodeIndex; typedef struct { rotating_node_t header; __pyx_t_8pytracer_CodeIndex code_index; } __pyx_t_8pytracer_CodeIndexEntry; typedef struct { __pyx_t_8pytracer_CodeIndex index; int lineno; double user_time; double sys_time; double real_time; } __pyx_t_8pytracer_InvocationData; typedef struct { __pyx_t_8pytracer_InvocationData data; __pyx_t_8pytracer_darray children; } __pyx_t_8pytracer_CallInvocation; struct __pyx_obj_8pytracer__Linkable { PyObject_HEAD graphfile_linkable_t linkable; }; struct __pyx_obj_8pytracer_Tracer { PyObject_HEAD struct __pyx_vtabstruct_8pytracer_Tracer *__pyx_vtab; PyObject *fileobj; PyObject *index_fileobj; rotating_node_t *written_indexes; FILE *index_file; graphfile_writer_t writer; __pyx_t_8pytracer_darray stack; pid_t tracer_pid; __pyx_t_8pytracer_CodeIndex next_code_index; PyObject *_prev_os_exit; }; struct __pyx_vtabstruct_8pytracer_Tracer { int (*call_invocation_init)(struct __pyx_obj_8pytracer_Tracer *,__pyx_t_8pytracer_CallInvocation *,PyObject *,int,double,double,double); int (*_trace_event)(struct __pyx_obj_8pytracer_Tracer *,PyObject *,int,void *); int (*_push_call)(struct __pyx_obj_8pytracer_Tracer *,PyObject *,int,double,double,double); int (*_pop_call)(struct __pyx_obj_8pytracer_Tracer *,double,double,double); int (*_index_of_code)(struct __pyx_obj_8pytracer_Tracer *,PyObject *); int (*_write)(struct __pyx_obj_8pytracer_Tracer *,char *,unsigned int,__pyx_t_8pytracer_darray *,graphfile_linkable_t *); PyObject *(*_push_root)(struct __pyx_obj_8pytracer_Tracer *); PyObject *(*_pop_root)(struct __pyx_obj_8pytracer_Tracer *); PyObject *(*_pop_to_root)(struct __pyx_obj_8pytracer_Tracer *); }; static struct __pyx_vtabstruct_8pytracer_Tracer *__pyx_vtabptr_8pytracer_Tracer; static PyTypeObject *__pyx_ptype_8pytracer__Linkable = 0; static PyTypeObject *__pyx_ptype_8pytracer_Tracer = 0; static double __pyx_f_8pytracer_double_of_tv(struct timeval *); /*proto*/ static int __pyx_f_8pytracer_get_user_sys_times(double *,double *); /*proto*/ static int __pyx_f_8pytracer_get_real_time(double *); /*proto*/ static void *__pyx_f_8pytracer_allocate(size_t); /*proto*/ static int __pyx_f_8pytracer_reallocate(void **,size_t); /*proto*/ static FILE *__pyx_f_8pytracer_file_from_obj(PyObject *); /*proto*/ static int __pyx_f_8pytracer_darray_init(__pyx_t_8pytracer_darray *,size_t); /*proto*/ static void *__pyx_f_8pytracer_darray_add(__pyx_t_8pytracer_darray *); /*proto*/ static void *__pyx_f_8pytracer_darray_last(__pyx_t_8pytracer_darray *); /*proto*/ static void __pyx_f_8pytracer_darray_fini(__pyx_t_8pytracer_darray *); /*proto*/ static int __pyx_f_8pytracer_darray_fast_remove_last(__pyx_t_8pytracer_darray *); /*proto*/ static int __pyx_f_8pytracer_safe_fflush(FILE *); /*proto*/ static size_t __pyx_f_8pytracer_safe_fread(void *,size_t,FILE *); /*proto*/ static size_t __pyx_f_8pytracer_safe_fwrite(void *,size_t,FILE *); /*proto*/ static void __pyx_f_8pytracer_call_invocation_empty(__pyx_t_8pytracer_CallInvocation *); /*proto*/ static PyObject *__pyx_f_8pytracer_fwrite_string(PyObject *,FILE *); /*proto*/ static int __pyx_f_8pytracer_freeEntry(rotating_node_t *,void *); /*proto*/ static int __pyx_f_8pytracer_callback(struct __pyx_obj_8pytracer_Tracer *,PyObject *,int,void *); /*proto*/ /* Implementation of pytracer */ static PyObject *__pyx_n_os; static PyObject *__pyx_n_sys; static PyObject *__pyx_n_Error; static PyObject *__pyx_n_Exception; static double __pyx_f_8pytracer_double_of_tv(struct timeval *__pyx_v_tv) { double __pyx_r; __pyx_r = ((((double)1000000) * __pyx_v_tv->tv_sec) + ((double)__pyx_v_tv->tv_usec)); goto __pyx_L0; __pyx_r = 0; __pyx_L0:; return __pyx_r; } static PyObject *__pyx_n_OSError; static PyObject *__pyx_n_getrusage; static int __pyx_f_8pytracer_get_user_sys_times(double *__pyx_v_user_time,double *__pyx_v_sys_time) { int __pyx_v_getrusage_return; struct rusage __pyx_v_getrusage_result; PyObject *__pyx_v_errno; int __pyx_r; PyObject *__pyx_1 = 0; int __pyx_2; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; __pyx_v_errno = Py_None; Py_INCREF(Py_None); /* "pyrex-lib/times.pyx":34 */ __pyx_1 = PyInt_FromLong(0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; goto __pyx_L1;} Py_DECREF(__pyx_v_errno); __pyx_v_errno = __pyx_1; __pyx_1 = 0; /* "pyrex-lib/times.pyx":35 */ __pyx_v_getrusage_return = getrusage(RUSAGE_SELF,(&__pyx_v_getrusage_result)); /* "pyrex-lib/times.pyx":36 */ __pyx_2 = (__pyx_v_getrusage_return == (-1)); if (__pyx_2) { __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} Py_INCREF(__pyx_v_errno); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_errno); Py_INCREF(__pyx_n_getrusage); PyTuple_SET_ITEM(__pyx_3, 1, __pyx_n_getrusage); __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "pyrex-lib/times.pyx":38 */ (__pyx_v_user_time[0]) = __pyx_f_8pytracer_double_of_tv((&__pyx_v_getrusage_result.ru_utime)); /* "pyrex-lib/times.pyx":39 */ (__pyx_v_sys_time[0]) = __pyx_f_8pytracer_double_of_tv((&__pyx_v_getrusage_result.ru_stime)); /* "pyrex-lib/times.pyx":40 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("pytracer.get_user_sys_times"); __pyx_r = (-1); __pyx_L0:; Py_DECREF(__pyx_v_errno); return __pyx_r; } static PyObject *__pyx_n_gettimeofday; static int __pyx_f_8pytracer_get_real_time(double *__pyx_v_real_time) { struct timeval __pyx_v_tv; int __pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; /* "pyrex-lib/times.pyx":46 */ __pyx_1 = (0 != gettimeofday((&__pyx_v_tv),NULL)); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} Py_INCREF(__pyx_n_gettimeofday); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_gettimeofday); __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "pyrex-lib/times.pyx":48 */ (__pyx_v_real_time[0]) = __pyx_f_8pytracer_double_of_tv((&__pyx_v_tv)); /* "pyrex-lib/times.pyx":49 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("pytracer.get_real_time"); __pyx_r = (-1); __pyx_L0:; return __pyx_r; } static PyObject *__pyx_n_MemoryError; static void *__pyx_f_8pytracer_allocate(size_t __pyx_v_size) { void *__pyx_v_ptr; void *__pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; /* "pyrex-lib/memory.pyx":16 */ __pyx_v_ptr = malloc(__pyx_v_size); /* "pyrex-lib/memory.pyx":17 */ __pyx_1 = (__pyx_v_ptr == NULL); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_MemoryError); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 18; goto __pyx_L1;} __Pyx_Raise(__pyx_2, 0, 0); Py_DECREF(__pyx_2); __pyx_2 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 18; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "pyrex-lib/memory.pyx":19 */ __pyx_r = __pyx_v_ptr; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); __Pyx_AddTraceback("pytracer.allocate"); __pyx_r = NULL; __pyx_L0:; return __pyx_r; } static int __pyx_f_8pytracer_reallocate(void **__pyx_v_ptr,size_t __pyx_v_size) { void *__pyx_v_new_ptr; int __pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; /* "pyrex-lib/memory.pyx":23 */ __pyx_1 = (__pyx_v_size == 0); if (__pyx_1) { /* "pyrex-lib/memory.pyx":24 */ free((__pyx_v_ptr[0])); /* "pyrex-lib/memory.pyx":25 */ (__pyx_v_ptr[0]) = NULL; /* "pyrex-lib/memory.pyx":26 */ __pyx_r = 0; goto __pyx_L0; goto __pyx_L2; } __pyx_L2:; /* "pyrex-lib/memory.pyx":27 */ __pyx_v_new_ptr = realloc((__pyx_v_ptr[0]),__pyx_v_size); /* "pyrex-lib/memory.pyx":28 */ __pyx_1 = (__pyx_v_new_ptr == NULL); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_MemoryError); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; goto __pyx_L1;} __Pyx_Raise(__pyx_2, 0, 0); Py_DECREF(__pyx_2); __pyx_2 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; goto __pyx_L1;} goto __pyx_L3; } __pyx_L3:; /* "pyrex-lib/memory.pyx":30 */ (__pyx_v_ptr[0]) = __pyx_v_new_ptr; /* "pyrex-lib/memory.pyx":31 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); __Pyx_AddTraceback("pytracer.reallocate"); __pyx_r = (-1); __pyx_L0:; return __pyx_r; } static PyObject *__pyx_k6p; static char __pyx_k6[] = "Invalid fileobj"; static FILE *__pyx_f_8pytracer_file_from_obj(PyObject *__pyx_v_fileobj) { FILE *__pyx_v_file; FILE *__pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; Py_INCREF(__pyx_v_fileobj); /* "pyrex-lib/python.pyx":24 */ __pyx_v_file = PyFile_AsFile(__pyx_v_fileobj); /* "pyrex-lib/python.pyx":25 */ __pyx_1 = (NULL == __pyx_v_file); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; goto __pyx_L1;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; goto __pyx_L1;} Py_INCREF(__pyx_k6p); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k6p); __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "pyrex-lib/python.pyx":27 */ __pyx_r = __pyx_v_file; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("pytracer.file_from_obj"); __pyx_r = NULL; __pyx_L0:; Py_DECREF(__pyx_v_fileobj); return __pyx_r; } static int __pyx_f_8pytracer_darray_init(__pyx_t_8pytracer_darray *__pyx_v_darray,size_t __pyx_v_item_size) { int __pyx_r; int __pyx_1; /* "pyrex-lib/darray.pyx":10 */ __pyx_v_darray->array = NULL; /* "pyrex-lib/darray.pyx":11 */ __pyx_v_darray->item_size = __pyx_v_item_size; /* "pyrex-lib/darray.pyx":12 */ __pyx_v_darray->used_count = 0; /* "pyrex-lib/darray.pyx":13 */ __pyx_v_darray->allocated_count = 8; /* "pyrex-lib/darray.pyx":14 */ __pyx_1 = __pyx_f_8pytracer_reallocate((&__pyx_v_darray->array),(__pyx_v_darray->allocated_count * __pyx_v_darray->item_size)); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 14; goto __pyx_L1;} /* "pyrex-lib/darray.pyx":16 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; __Pyx_AddTraceback("pytracer.darray_init"); __pyx_r = (-1); __pyx_L0:; return __pyx_r; } static PyObject *__pyx_n_max; static void *__pyx_f_8pytracer_darray_add(__pyx_t_8pytracer_darray *__pyx_v_darray) { void *__pyx_v_result; unsigned int __pyx_v_new_used_count; unsigned int __pyx_v_new_allocated_count; void *__pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; unsigned int __pyx_6; /* "pyrex-lib/darray.pyx":22 */ __pyx_v_new_used_count = (__pyx_v_darray->used_count + 1); /* "pyrex-lib/darray.pyx":23 */ __pyx_1 = (__pyx_v_new_used_count > __pyx_v_darray->allocated_count); if (__pyx_1) { /* "pyrex-lib/darray.pyx":24 */ __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_max); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; goto __pyx_L1;} __pyx_3 = PyInt_FromLong(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; goto __pyx_L1;} __pyx_4 = PyLong_FromUnsignedLong(__pyx_v_darray->allocated_count); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; goto __pyx_L1;} __pyx_5 = PyTuple_New(2); if (!__pyx_5) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_5, 0, __pyx_3); PyTuple_SET_ITEM(__pyx_5, 1, __pyx_4); __pyx_3 = 0; __pyx_4 = 0; __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_4 = PyInt_FromLong(2); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; goto __pyx_L1;} __pyx_2 = PyNumber_Multiply(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __pyx_6 = PyInt_AsUnsignedLongMask(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_v_new_allocated_count = __pyx_6; /* "pyrex-lib/darray.pyx":25 */ #ifndef PYREX_WITHOUT_ASSERTIONS if (!(__pyx_v_new_allocated_count >= __pyx_v_new_used_count)) { PyErr_SetNone(PyExc_AssertionError); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 25; goto __pyx_L1;} } #endif /* "pyrex-lib/darray.pyx":26 */ __pyx_1 = __pyx_f_8pytracer_reallocate((&__pyx_v_darray->array),(__pyx_v_new_allocated_count * __pyx_v_darray->item_size)); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 26; goto __pyx_L1;} /* "pyrex-lib/darray.pyx":28 */ __pyx_v_darray->allocated_count = __pyx_v_new_allocated_count; goto __pyx_L2; } __pyx_L2:; /* "pyrex-lib/darray.pyx":30 */ __pyx_v_result = (&(((unsigned char *)__pyx_v_darray->array)[(__pyx_v_darray->used_count * __pyx_v_darray->item_size)])); /* "pyrex-lib/darray.pyx":31 */ __pyx_v_darray->used_count = __pyx_v_new_used_count; /* "pyrex-lib/darray.pyx":32 */ __pyx_r = __pyx_v_result; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); __Pyx_AddTraceback("pytracer.darray_add"); __pyx_r = NULL; __pyx_L0:; return __pyx_r; } static void *__pyx_f_8pytracer_darray_last(__pyx_t_8pytracer_darray *__pyx_v_darray) { void *__pyx_r; __pyx_r = (&(((unsigned char *)__pyx_v_darray->array)[((__pyx_v_darray->used_count - 1) * __pyx_v_darray->item_size)])); goto __pyx_L0; __pyx_r = 0; __pyx_L0:; return __pyx_r; } static void __pyx_f_8pytracer_darray_fini(__pyx_t_8pytracer_darray *__pyx_v_darray) { /* "pyrex-lib/darray.pyx":38 */ free(__pyx_v_darray->array); /* "pyrex-lib/darray.pyx":39 */ __pyx_v_darray->array = NULL; /* "pyrex-lib/darray.pyx":40 */ __pyx_v_darray->used_count = (-1); } static int __pyx_f_8pytracer_darray_fast_remove_last(__pyx_t_8pytracer_darray *__pyx_v_darray) { unsigned int __pyx_v_new_used_count; int __pyx_r; /* "pyrex-lib/darray.pyx":46 */ #ifndef PYREX_WITHOUT_ASSERTIONS if (!(__pyx_v_darray->used_count > 0)) { PyErr_SetNone(PyExc_AssertionError); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 46; goto __pyx_L1;} } #endif /* "pyrex-lib/darray.pyx":47 */ __pyx_v_new_used_count = (__pyx_v_darray->used_count - 1); /* "pyrex-lib/darray.pyx":48 */ __pyx_v_darray->used_count = __pyx_v_new_used_count; /* "pyrex-lib/darray.pyx":49 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; __Pyx_AddTraceback("pytracer.darray_fast_remove_last"); __pyx_r = (-1); __pyx_L0:; return __pyx_r; } static PyObject *__pyx_n_fflush; static int __pyx_f_8pytracer_safe_fflush(FILE *__pyx_v_stream) { int __pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; /* "pyrex-lib/files.pyx":4 */ __pyx_1 = ((-1) == fflush(__pyx_v_stream)); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; goto __pyx_L1;} __pyx_3 = PyInt_FromLong(errno); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; goto __pyx_L1;} __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); Py_INCREF(__pyx_n_fflush); PyTuple_SET_ITEM(__pyx_4, 1, __pyx_n_fflush); __pyx_3 = 0; __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_3, 0, 0); Py_DECREF(__pyx_3); __pyx_3 = 0; {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "pyrex-lib/files.pyx":6 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("pytracer.safe_fflush"); __pyx_r = (-1); __pyx_L0:; return __pyx_r; } static PyObject *__pyx_n_fread; static size_t __pyx_f_8pytracer_safe_fread(void *__pyx_v_ptr,size_t __pyx_v_size,FILE *__pyx_v_stream) { int __pyx_v_rc; size_t __pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; /* "pyrex-lib/files.pyx":10 */ __pyx_v_rc = fread(__pyx_v_ptr,1,__pyx_v_size,__pyx_v_stream); /* "pyrex-lib/files.pyx":11 */ __pyx_1 = (__pyx_v_rc == (-1)); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; goto __pyx_L1;} __pyx_3 = PyInt_FromLong(errno); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; goto __pyx_L1;} __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); Py_INCREF(__pyx_n_fread); PyTuple_SET_ITEM(__pyx_4, 1, __pyx_n_fread); __pyx_3 = 0; __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_3, 0, 0); Py_DECREF(__pyx_3); __pyx_3 = 0; {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "pyrex-lib/files.pyx":13 */ __pyx_r = __pyx_v_rc; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("pytracer.safe_fread"); __pyx_r = (-1); __pyx_L0:; return __pyx_r; } static PyObject *__pyx_n_fwrite; static size_t __pyx_f_8pytracer_safe_fwrite(void *__pyx_v_ptr,size_t __pyx_v_size,FILE *__pyx_v_stream) { int __pyx_v_rc; size_t __pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; /* "pyrex-lib/files.pyx":17 */ __pyx_v_rc = fwrite(__pyx_v_ptr,1,__pyx_v_size,__pyx_v_stream); /* "pyrex-lib/files.pyx":18 */ __pyx_1 = (__pyx_v_rc == (-1)); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_OSError); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; goto __pyx_L1;} __pyx_3 = PyInt_FromLong(errno); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; goto __pyx_L1;} __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); Py_INCREF(__pyx_n_fwrite); PyTuple_SET_ITEM(__pyx_4, 1, __pyx_n_fwrite); __pyx_3 = 0; __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_3, 0, 0); Py_DECREF(__pyx_3); __pyx_3 = 0; {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "pyrex-lib/files.pyx":20 */ __pyx_r = __pyx_v_rc; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("pytracer.safe_fwrite"); __pyx_r = (-1); __pyx_L0:; return __pyx_r; } static void __pyx_f_8pytracer_call_invocation_empty(__pyx_t_8pytracer_CallInvocation *__pyx_v_invocation) { int __pyx_1; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":31 */ memset(__pyx_v_invocation,0,(sizeof((__pyx_v_invocation[0])))); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":32 */ __pyx_1 = __pyx_f_8pytracer_darray_init((&__pyx_v_invocation->children),(sizeof(graphfile_linkable_t))); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 32; goto __pyx_L1;} goto __pyx_L0; __pyx_L1:; __Pyx_WriteUnraisable("pytracer.call_invocation_empty"); __pyx_L0:; } static PyObject *__pyx_f_8pytracer_fwrite_string(PyObject *__pyx_v_name,FILE *__pyx_v_index_file) { char *__pyx_v_name_buf; Py_ssize_t __pyx_v_name_length; short __pyx_v_short_name_length; PyObject *__pyx_r; int __pyx_1; size_t __pyx_2; Py_INCREF(__pyx_v_name); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":38 */ __pyx_1 = PyString_AsStringAndSize(__pyx_v_name,(&__pyx_v_name_buf),(&__pyx_v_name_length)); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 38; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":39 */ __pyx_v_short_name_length = __pyx_v_name_length; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":42 */ #ifndef PYREX_WITHOUT_ASSERTIONS if (!(__pyx_v_short_name_length == __pyx_v_name_length)) { PyErr_SetNone(PyExc_AssertionError); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 42; goto __pyx_L1;} } #endif /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":44 */ __pyx_2 = __pyx_f_8pytracer_safe_fwrite((&__pyx_v_short_name_length),(sizeof(__pyx_v_short_name_length)),__pyx_v_index_file); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 44; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":45 */ __pyx_2 = __pyx_f_8pytracer_safe_fwrite(__pyx_v_name_buf,__pyx_v_name_length,__pyx_v_index_file); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; goto __pyx_L1;} __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; __Pyx_AddTraceback("pytracer.fwrite_string"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_name); return __pyx_r; } static int __pyx_f_8pytracer_freeEntry(rotating_node_t *__pyx_v_header,void *__pyx_v_arg) { int __pyx_r; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":48 */ free(__pyx_v_header); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":49 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; __pyx_L0:; return __pyx_r; } static PyObject *__pyx_n_graphfile_writer_init; static int __pyx_f_8pytracer_6Tracer___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_f_8pytracer_6Tracer___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_fileobj = 0; PyObject *__pyx_v_index_fileobj = 0; int __pyx_r; FILE *__pyx_1; int __pyx_2; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"fileobj","index_fileobj",0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_fileobj, &__pyx_v_index_fileobj)) return -1; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_fileobj); Py_INCREF(__pyx_v_index_fileobj); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":67 */ ((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->next_code_index = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":68 */ __pyx_1 = __pyx_f_8pytracer_file_from_obj(__pyx_v_index_fileobj); if (__pyx_1 == NULL) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 68; goto __pyx_L1;} ((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->index_file = __pyx_1; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":69 */ Py_INCREF(__pyx_v_index_fileobj); Py_DECREF(((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->index_fileobj); ((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->index_fileobj = __pyx_v_index_fileobj; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":71 */ __pyx_1 = __pyx_f_8pytracer_file_from_obj(__pyx_v_fileobj); if (__pyx_1 == NULL) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 71; goto __pyx_L1;} __pyx_2 = (0 != graphfile_writer_init((&((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->writer),__pyx_1)); if (__pyx_2) { __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_Error); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 72; goto __pyx_L1;} __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 72; goto __pyx_L1;} Py_INCREF(__pyx_n_graphfile_writer_init); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_graphfile_writer_init); __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 72; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); Py_DECREF(__pyx_5); __pyx_5 = 0; {__pyx_filename = __pyx_f[5]; __pyx_lineno = 72; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":73 */ Py_INCREF(__pyx_v_fileobj); Py_DECREF(((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->fileobj); ((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->fileobj = __pyx_v_fileobj; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":74 */ ((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->tracer_pid = (-1); __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); __Pyx_AddTraceback("pytracer.Tracer.__cinit__"); __pyx_r = -1; __pyx_L0:; Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_fileobj); Py_DECREF(__pyx_v_index_fileobj); return __pyx_r; } static void __pyx_f_8pytracer_6Tracer___dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_f_8pytracer_6Tracer___dealloc__(PyObject *__pyx_v_self) { Py_INCREF(__pyx_v_self); graphfile_writer_fini((&((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->writer)); Py_DECREF(__pyx_v_self); } static int __pyx_f_8pytracer_6Tracer_call_invocation_init(struct __pyx_obj_8pytracer_Tracer *__pyx_v_self,__pyx_t_8pytracer_CallInvocation *__pyx_v_invocation,PyObject *__pyx_v_code_obj,int __pyx_v_lineno,double __pyx_v_user_time,double __pyx_v_sys_time,double __pyx_v_real_time) { int __pyx_r; int __pyx_1; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_code_obj); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":84 */ __pyx_1 = ((struct __pyx_vtabstruct_8pytracer_Tracer *)__pyx_v_self->__pyx_vtab)->_index_of_code(__pyx_v_self,__pyx_v_code_obj); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; goto __pyx_L1;} __pyx_v_invocation->data.index = __pyx_1; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":85 */ __pyx_v_invocation->data.lineno = __pyx_v_lineno; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":86 */ __pyx_v_invocation->data.user_time = __pyx_v_user_time; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":87 */ __pyx_v_invocation->data.sys_time = __pyx_v_sys_time; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":88 */ __pyx_v_invocation->data.real_time = __pyx_v_real_time; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":89 */ __pyx_1 = __pyx_f_8pytracer_darray_init((&__pyx_v_invocation->children),(sizeof(graphfile_linkable_t))); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 89; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":90 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; __Pyx_AddTraceback("pytracer.Tracer.call_invocation_init"); __pyx_r = (-1); __pyx_L0:; Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_code_obj); return __pyx_r; } static PyObject *__pyx_n_f_code; static PyObject *__pyx_n_f_lineno; static int __pyx_f_8pytracer_6Tracer__trace_event(struct __pyx_obj_8pytracer_Tracer *__pyx_v_self,PyObject *__pyx_v_frame,int __pyx_v_event,void *__pyx_v_trace_arg) { double __pyx_v_user_time; double __pyx_v_sys_time; double __pyx_v_real_time; int __pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; int __pyx_4; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_frame); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":95 */ __pyx_1 = (__pyx_v_self->tracer_pid != getpid()); if (__pyx_1) { __pyx_r = 0; goto __pyx_L0; goto __pyx_L2; } __pyx_L2:; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":99 */ __pyx_1 = (__pyx_v_event != PyTrace_CALL); if (__pyx_1) { __pyx_1 = (__pyx_v_event != PyTrace_RETURN); } if (__pyx_1) { __pyx_r = 0; goto __pyx_L0; goto __pyx_L3; } __pyx_L3:; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":102 */ __pyx_1 = __pyx_f_8pytracer_get_user_sys_times((&__pyx_v_user_time),(&__pyx_v_sys_time)); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 102; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":103 */ __pyx_1 = __pyx_f_8pytracer_get_real_time((&__pyx_v_real_time)); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 103; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":105 */ __pyx_1 = (__pyx_v_event == PyTrace_CALL); if (__pyx_1) { __pyx_2 = PyObject_GetAttr(__pyx_v_frame, __pyx_n_f_code); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 106; goto __pyx_L1;} __pyx_3 = PyObject_GetAttr(__pyx_v_frame, __pyx_n_f_lineno); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 106; goto __pyx_L1;} __pyx_1 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 106; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_4 = ((struct __pyx_vtabstruct_8pytracer_Tracer *)__pyx_v_self->__pyx_vtab)->_push_call(__pyx_v_self,__pyx_2,__pyx_1,__pyx_v_user_time,__pyx_v_sys_time,__pyx_v_real_time); if (__pyx_4 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 106; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; goto __pyx_L4; } /*else*/ { __pyx_1 = ((struct __pyx_vtabstruct_8pytracer_Tracer *)__pyx_v_self->__pyx_vtab)->_pop_call(__pyx_v_self,__pyx_v_user_time,__pyx_v_sys_time,__pyx_v_real_time); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 108; goto __pyx_L1;} } __pyx_L4:; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":109 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); __Pyx_AddTraceback("pytracer.Tracer._trace_event"); __pyx_r = (-1); __pyx_L0:; Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_frame); return __pyx_r; } static int __pyx_f_8pytracer_6Tracer__push_call(struct __pyx_obj_8pytracer_Tracer *__pyx_v_self,PyObject *__pyx_v_code_obj,int __pyx_v_lineno,double __pyx_v_user_time,double __pyx_v_sys_time,double __pyx_v_real_time) { __pyx_t_8pytracer_CallInvocation *__pyx_v_invocation; int __pyx_r; void *__pyx_1; int __pyx_2; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_code_obj); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":114 */ __pyx_1 = __pyx_f_8pytracer_darray_add((&__pyx_v_self->stack)); if (__pyx_1 == NULL) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 114; goto __pyx_L1;} __pyx_v_invocation = ((__pyx_t_8pytracer_CallInvocation *)__pyx_1); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":115 */ __pyx_2 = ((struct __pyx_vtabstruct_8pytracer_Tracer *)__pyx_v_self->__pyx_vtab)->call_invocation_init(__pyx_v_self,__pyx_v_invocation,__pyx_v_code_obj,__pyx_v_lineno,__pyx_v_user_time,__pyx_v_sys_time,__pyx_v_real_time); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 115; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":116 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; __Pyx_AddTraceback("pytracer.Tracer._push_call"); __pyx_r = (-1); __pyx_L0:; Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_code_obj); return __pyx_r; } static int __pyx_f_8pytracer_6Tracer__pop_call(struct __pyx_obj_8pytracer_Tracer *__pyx_v_self,double __pyx_v_user_time,double __pyx_v_sys_time,double __pyx_v_real_time) { __pyx_t_8pytracer_CallInvocation *__pyx_v_invocation; graphfile_linkable_t __pyx_v_linkable; graphfile_linkable_t *__pyx_v_new_child_ptr; int __pyx_r; void *__pyx_1; int __pyx_2; void *__pyx_3; Py_INCREF(__pyx_v_self); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":123 */ __pyx_1 = __pyx_f_8pytracer_darray_last((&__pyx_v_self->stack)); if (__pyx_1 == NULL) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 123; goto __pyx_L1;} __pyx_v_invocation = ((__pyx_t_8pytracer_CallInvocation *)__pyx_1); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":124 */ __pyx_v_invocation->data.user_time = (__pyx_v_user_time - __pyx_v_invocation->data.user_time); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":125 */ __pyx_v_invocation->data.sys_time = (__pyx_v_sys_time - __pyx_v_invocation->data.sys_time); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":126 */ __pyx_v_invocation->data.real_time = (__pyx_v_real_time - __pyx_v_invocation->data.real_time); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":127 */ __pyx_2 = ((struct __pyx_vtabstruct_8pytracer_Tracer *)__pyx_v_self->__pyx_vtab)->_write(__pyx_v_self,((char *)(&__pyx_v_invocation->data)),(sizeof(__pyx_v_invocation->data)),(&__pyx_v_invocation->children),(&__pyx_v_linkable)); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 127; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":129 */ __pyx_f_8pytracer_darray_fini((&__pyx_v_invocation->children)); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":130 */ __pyx_2 = __pyx_f_8pytracer_darray_fast_remove_last((&__pyx_v_self->stack)); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 130; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":132 */ __pyx_1 = __pyx_f_8pytracer_darray_last((&__pyx_v_self->stack)); if (__pyx_1 == NULL) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 132; goto __pyx_L1;} __pyx_v_invocation = ((__pyx_t_8pytracer_CallInvocation *)__pyx_1); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":133 */ __pyx_3 = __pyx_f_8pytracer_darray_add((&__pyx_v_invocation->children)); if (__pyx_3 == NULL) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 133; goto __pyx_L1;} __pyx_v_new_child_ptr = ((graphfile_linkable_t *)__pyx_3); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":134 */ (__pyx_v_new_child_ptr[0]) = __pyx_v_linkable; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":135 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; __Pyx_AddTraceback("pytracer.Tracer._pop_call"); __pyx_r = (-1); __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } static PyObject *__pyx_n_id; static PyObject *__pyx_n_co_filename; static PyObject *__pyx_n_co_name; static int __pyx_f_8pytracer_6Tracer__index_of_code(struct __pyx_obj_8pytracer_Tracer *__pyx_v_self,PyObject *__pyx_v_code) { unsigned long __pyx_v_key; __pyx_t_8pytracer_CodeIndexEntry *__pyx_v_node; int __pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; unsigned long __pyx_4; int __pyx_5; size_t __pyx_6; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_code); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":142 */ __pyx_1 = __Pyx_GetName(__pyx_b, __pyx_n_id); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 142; goto __pyx_L1;} __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 142; goto __pyx_L1;} Py_INCREF(__pyx_v_code); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_code); __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 142; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_4 = PyInt_AsUnsignedLongMask(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 142; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_v_key = __pyx_4; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":143 */ __pyx_v_node = ((__pyx_t_8pytracer_CodeIndexEntry *)RotatingTree_Get((&__pyx_v_self->written_indexes),((void *)__pyx_v_key))); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":144 */ __pyx_5 = (__pyx_v_node != NULL); if (__pyx_5) { __pyx_r = __pyx_v_node->code_index; goto __pyx_L0; goto __pyx_L2; } __pyx_L2:; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":147 */ __pyx_v_node = ((__pyx_t_8pytracer_CodeIndexEntry *)malloc((sizeof(__pyx_t_8pytracer_CodeIndexEntry)))); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":148 */ __pyx_v_node->header.key = ((void *)__pyx_v_key); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":149 */ __pyx_v_node->code_index = __pyx_v_self->next_code_index; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":152 */ #ifndef PYREX_WITHOUT_ASSERTIONS if (!(__pyx_v_self->next_code_index != 0)) { PyErr_SetNone(PyExc_AssertionError); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 152; goto __pyx_L1;} } #endif /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":154 */ __pyx_6 = __pyx_f_8pytracer_safe_fwrite((&__pyx_v_node->code_index),(sizeof(__pyx_v_node->code_index)),__pyx_v_self->index_file); if (__pyx_6 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 154; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":156 */ __pyx_1 = PyObject_GetAttr(__pyx_v_code, __pyx_n_co_filename); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 156; goto __pyx_L1;} __pyx_2 = __pyx_f_8pytracer_fwrite_string(__pyx_1,__pyx_v_self->index_file); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 156; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":157 */ __pyx_3 = PyObject_GetAttr(__pyx_v_code, __pyx_n_co_name); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 157; goto __pyx_L1;} __pyx_1 = __pyx_f_8pytracer_fwrite_string(__pyx_3,__pyx_v_self->index_file); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 157; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":159 */ RotatingTree_Add((&__pyx_v_self->written_indexes),(&__pyx_v_node->header)); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":160 */ __pyx_v_self->next_code_index = (__pyx_v_node->code_index + 1); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":161 */ __pyx_r = __pyx_v_node->code_index; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); __Pyx_AddTraceback("pytracer.Tracer._index_of_code"); __pyx_r = (-1); __pyx_L0:; Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_code); return __pyx_r; } static PyObject *__pyx_n_graphfile_writer_write; static int __pyx_f_8pytracer_6Tracer__write(struct __pyx_obj_8pytracer_Tracer *__pyx_v_self,char *__pyx_v_buffer,unsigned int __pyx_v_buffer_length,__pyx_t_8pytracer_darray *__pyx_v_children,graphfile_linkable_t *__pyx_v_result) { int __pyx_v_status; int __pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; Py_INCREF(__pyx_v_self); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":166 */ __pyx_v_status = graphfile_writer_write((&__pyx_v_self->writer),__pyx_v_buffer,__pyx_v_buffer_length,((graphfile_linkable_t *)__pyx_v_children->array),__pyx_v_children->used_count,__pyx_v_result); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":168 */ __pyx_1 = (__pyx_v_status != 0); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 169; goto __pyx_L1;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 169; goto __pyx_L1;} Py_INCREF(__pyx_n_graphfile_writer_write); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_graphfile_writer_write); __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 169; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[5]; __pyx_lineno = 169; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":170 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("pytracer.Tracer._write"); __pyx_r = (-1); __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } static PyObject *__pyx_f_8pytracer_6Tracer__push_root(struct __pyx_obj_8pytracer_Tracer *__pyx_v_self) { __pyx_t_8pytracer_CallInvocation *__pyx_v_invocation; PyObject *__pyx_r; void *__pyx_1; Py_INCREF(__pyx_v_self); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":174 */ __pyx_1 = __pyx_f_8pytracer_darray_add((&__pyx_v_self->stack)); if (__pyx_1 == NULL) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 174; goto __pyx_L1;} __pyx_v_invocation = ((__pyx_t_8pytracer_CallInvocation *)__pyx_1); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":175 */ __pyx_f_8pytracer_call_invocation_empty(__pyx_v_invocation); __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; __Pyx_AddTraceback("pytracer.Tracer._push_root"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } static PyObject *__pyx_n_graphfile_writer_set_root; static PyObject *__pyx_f_8pytracer_6Tracer__pop_root(struct __pyx_obj_8pytracer_Tracer *__pyx_v_self) { graphfile_linkable_t __pyx_v_root; __pyx_t_8pytracer_CallInvocation *__pyx_v_invocation; PyObject *__pyx_r; void *__pyx_1; int __pyx_2; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; Py_INCREF(__pyx_v_self); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":180 */ #ifndef PYREX_WITHOUT_ASSERTIONS if (!(__pyx_v_self->stack.used_count == 1)) { PyErr_SetNone(PyExc_AssertionError); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 180; goto __pyx_L1;} } #endif /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":182 */ __pyx_1 = __pyx_f_8pytracer_darray_last((&__pyx_v_self->stack)); if (__pyx_1 == NULL) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 182; goto __pyx_L1;} __pyx_v_invocation = ((__pyx_t_8pytracer_CallInvocation *)__pyx_1); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":183 */ __pyx_2 = ((struct __pyx_vtabstruct_8pytracer_Tracer *)__pyx_v_self->__pyx_vtab)->_write(__pyx_v_self,NULL,0,(&__pyx_v_invocation->children),(&__pyx_v_root)); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 183; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":184 */ __pyx_2 = __pyx_f_8pytracer_darray_fast_remove_last((&__pyx_v_self->stack)); if (__pyx_2 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 184; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":185 */ __pyx_2 = (0 != graphfile_writer_set_root((&__pyx_v_self->writer),(&__pyx_v_root))); if (__pyx_2) { __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_Error); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 186; goto __pyx_L1;} __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 186; goto __pyx_L1;} Py_INCREF(__pyx_n_graphfile_writer_set_root); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_graphfile_writer_set_root); __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 186; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); Py_DECREF(__pyx_5); __pyx_5 = 0; {__pyx_filename = __pyx_f[5]; __pyx_lineno = 186; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); __Pyx_AddTraceback("pytracer.Tracer._pop_root"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } static PyObject *__pyx_f_8pytracer_6Tracer__pop_to_root(struct __pyx_obj_8pytracer_Tracer *__pyx_v_self) { double __pyx_v_user_time; double __pyx_v_sys_time; double __pyx_v_real_time; PyObject *__pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; Py_INCREF(__pyx_v_self); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":190 */ __pyx_1 = __pyx_f_8pytracer_get_user_sys_times((&__pyx_v_user_time),(&__pyx_v_sys_time)); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":191 */ __pyx_1 = __pyx_f_8pytracer_get_real_time((&__pyx_v_real_time)); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":192 */ while (1) { __pyx_1 = (__pyx_v_self->stack.used_count > 1); if (!__pyx_1) break; __pyx_1 = ((struct __pyx_vtabstruct_8pytracer_Tracer *)__pyx_v_self->__pyx_vtab)->_pop_call(__pyx_v_self,__pyx_v_user_time,__pyx_v_sys_time,__pyx_v_real_time); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 193; goto __pyx_L1;} } /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":194 */ __pyx_2 = ((struct __pyx_vtabstruct_8pytracer_Tracer *)__pyx_v_self->__pyx_vtab)->_pop_root(__pyx_v_self); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 194; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); __Pyx_AddTraceback("pytracer.Tracer._pop_to_root"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); return __pyx_r; } static PyObject *__pyx_f_8pytracer_6Tracer__wrap_os_exit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_8pytracer_6Tracer__wrap_os_exit(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_status = 0; PyObject *__pyx_r; PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; static char *__pyx_argnames[] = {"status",0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_status)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_status); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":197 */ __pyx_1 = ((struct __pyx_vtabstruct_8pytracer_Tracer *)((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->__pyx_vtab)->_pop_to_root(((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 197; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":198 */ __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 198; goto __pyx_L1;} Py_INCREF(__pyx_v_status); PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_status); __pyx_2 = PyObject_CallObject(((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->_prev_os_exit, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 198; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); __Pyx_AddTraceback("pytracer.Tracer._wrap_os_exit"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_status); return __pyx_r; } static PyObject *__pyx_n__exit; static PyObject *__pyx_n__wrap_os_exit; static PyObject *__pyx_n_exc_info; static PyObject *__pyx_k13p; static char __pyx_k13[] = "Cannot create a nested trace"; static PyObject *__pyx_f_8pytracer_6Tracer_trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_8pytracer_6Tracer_trace(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_func = 0; PyObject *__pyx_v_exc_type; PyObject *__pyx_v_exc_value; PyObject *__pyx_v_exc_tb; PyObject *__pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; PyObject *__pyx_6 = 0; PyObject *__pyx_7 = 0; static char *__pyx_argnames[] = {"func",0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_func)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_func); __pyx_v_exc_type = Py_None; Py_INCREF(Py_None); __pyx_v_exc_value = Py_None; Py_INCREF(Py_None); __pyx_v_exc_tb = Py_None; Py_INCREF(Py_None); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":201 */ #ifndef PYREX_WITHOUT_ASSERTIONS if (!(((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->tracer_pid == (-1))) { PyErr_SetObject(PyExc_AssertionError, __pyx_k13p); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 201; goto __pyx_L1;} } #endif /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":202 */ __pyx_1 = __pyx_f_8pytracer_darray_init((&((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->stack),(sizeof(__pyx_t_8pytracer_CallInvocation))); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 202; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":203 */ __pyx_2 = ((struct __pyx_vtabstruct_8pytracer_Tracer *)((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->__pyx_vtab)->_push_root(((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 203; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":204 */ ((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->tracer_pid = getpid(); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":205 */ ((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->written_indexes = EMPTY_ROTATING_TREE; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":206 */ /*try:*/ { /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":207 */ PyEval_SetProfile(((Py_tracefunc)(&__pyx_f_8pytracer_callback)),__pyx_v_self); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":208 */ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 208; goto __pyx_L3;} __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n__exit); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 208; goto __pyx_L3;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->_prev_os_exit); ((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->_prev_os_exit = __pyx_3; __pyx_3 = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":209 */ __pyx_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n__wrap_os_exit); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 209; goto __pyx_L3;} __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 209; goto __pyx_L3;} if (PyObject_SetAttr(__pyx_3, __pyx_n__exit, __pyx_2) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 209; goto __pyx_L3;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":210 */ /*try:*/ { /*try:*/ { /*try:*/ { __pyx_2 = PyObject_CallObject(__pyx_v_func, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 213; goto __pyx_L11;} __pyx_r = __pyx_2; __pyx_2 = 0; goto __pyx_L10; } /*finally:*/ { int __pyx_why; PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; int __pyx_exc_lineno; __pyx_why = 0; goto __pyx_L12; __pyx_L10: __pyx_why = 3; goto __pyx_L12; __pyx_L11: { __pyx_why = 4; Py_XDECREF(__pyx_3); __pyx_3 = 0; Py_XDECREF(__pyx_2); __pyx_2 = 0; PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); __pyx_exc_lineno = __pyx_lineno; goto __pyx_L12; } __pyx_L12:; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":215 */ #ifndef PYREX_WITHOUT_ASSERTIONS __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 215; goto __pyx_L13;} __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n__exit); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 215; goto __pyx_L13;} Py_DECREF(__pyx_3); __pyx_3 = 0; __pyx_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n__wrap_os_exit); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 215; goto __pyx_L13;} if (PyObject_Cmp(__pyx_2, __pyx_3, &__pyx_1) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 215; goto __pyx_L13;} __pyx_1 = __pyx_1 == 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; if (!__pyx_1) { PyErr_SetNone(PyExc_AssertionError); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 215; goto __pyx_L13;} } #endif /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":216 */ __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_os); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 216; goto __pyx_L13;} if (PyObject_SetAttr(__pyx_2, __pyx_n__exit, ((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->_prev_os_exit) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 216; goto __pyx_L13;} Py_DECREF(__pyx_2); __pyx_2 = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":217 */ PyEval_SetProfile(NULL,Py_None); goto __pyx_L14; __pyx_L13:; if (__pyx_why == 4) { Py_XDECREF(__pyx_exc_type); Py_XDECREF(__pyx_exc_value); Py_XDECREF(__pyx_exc_tb); } goto __pyx_L8; __pyx_L14:; switch (__pyx_why) { case 3: goto __pyx_L5; case 4: { PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); __pyx_lineno = __pyx_exc_lineno; __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; goto __pyx_L8; } } } } goto __pyx_L9; __pyx_L8:; Py_XDECREF(__pyx_3); __pyx_3 = 0; Py_XDECREF(__pyx_2); __pyx_2 = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":218 */ /*except:*/ { __Pyx_AddTraceback("pytracer.trace"); if (__Pyx_GetException(&__pyx_3, &__pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 218; goto __pyx_L6;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":219 */ __pyx_1 = (((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->tracer_pid == getpid()); if (__pyx_1) { /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":220 */ __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_sys); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 220; goto __pyx_L6;} __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_exc_info); if (!__pyx_6) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 220; goto __pyx_L6;} Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_5 = PyObject_CallObject(__pyx_6, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 220; goto __pyx_L6;} Py_DECREF(__pyx_6); __pyx_6 = 0; __pyx_6 = PyObject_GetIter(__pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 220; goto __pyx_L6;} Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_5 = __Pyx_UnpackItem(__pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 220; goto __pyx_L6;} Py_DECREF(__pyx_v_exc_type); __pyx_v_exc_type = __pyx_5; __pyx_5 = 0; __pyx_5 = __Pyx_UnpackItem(__pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 220; goto __pyx_L6;} Py_DECREF(__pyx_v_exc_value); __pyx_v_exc_value = __pyx_5; __pyx_5 = 0; __pyx_5 = __Pyx_UnpackItem(__pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 220; goto __pyx_L6;} Py_DECREF(__pyx_v_exc_tb); __pyx_v_exc_tb = __pyx_5; __pyx_5 = 0; if (__Pyx_EndUnpack(__pyx_6) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 220; goto __pyx_L6;} Py_DECREF(__pyx_6); __pyx_6 = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":221 */ /*try:*/ { __pyx_5 = ((struct __pyx_vtabstruct_8pytracer_Tracer *)((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->__pyx_vtab)->_pop_root(((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 222; goto __pyx_L16;} Py_DECREF(__pyx_5); __pyx_5 = 0; } goto __pyx_L17; __pyx_L16:; Py_XDECREF(__pyx_6); __pyx_6 = 0; Py_XDECREF(__pyx_5); __pyx_5 = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":223 */ /*except:*/ { __Pyx_AddTraceback("pytracer.trace"); if (__Pyx_GetException(&__pyx_6, &__pyx_5, &__pyx_7) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 223; goto __pyx_L6;} __Pyx_Raise(__pyx_v_exc_type, __pyx_v_exc_value, __pyx_v_exc_tb); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 225; goto __pyx_L6;} Py_DECREF(__pyx_6); __pyx_6 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; Py_DECREF(__pyx_7); __pyx_7 = 0; goto __pyx_L17; } __pyx_L17:; goto __pyx_L15; } __pyx_L15:; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":226 */ __Pyx_Raise(__pyx_3, __pyx_2, __pyx_4); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 226; goto __pyx_L6;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; goto __pyx_L9; } __pyx_L9:; } /*finally:*/ { int __pyx_why; PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; int __pyx_exc_lineno; __pyx_why = 0; goto __pyx_L7; __pyx_L5: __pyx_why = 3; goto __pyx_L7; __pyx_L6: { __pyx_why = 4; Py_XDECREF(__pyx_6); __pyx_6 = 0; Py_XDECREF(__pyx_5); __pyx_5 = 0; Py_XDECREF(__pyx_7); __pyx_7 = 0; Py_XDECREF(__pyx_3); __pyx_3 = 0; Py_XDECREF(__pyx_2); __pyx_2 = 0; Py_XDECREF(__pyx_4); __pyx_4 = 0; PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); __pyx_exc_lineno = __pyx_lineno; goto __pyx_L7; } __pyx_L7:; __pyx_1 = (((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->tracer_pid == getpid()); if (__pyx_1) { __pyx_6 = ((struct __pyx_vtabstruct_8pytracer_Tracer *)((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->__pyx_vtab)->_pop_root(((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)); if (!__pyx_6) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 231; goto __pyx_L18;} Py_DECREF(__pyx_6); __pyx_6 = 0; goto __pyx_L19; } __pyx_L19:; goto __pyx_L20; __pyx_L18:; if (__pyx_why == 4) { Py_XDECREF(__pyx_exc_type); Py_XDECREF(__pyx_exc_value); Py_XDECREF(__pyx_exc_tb); } goto __pyx_L3; __pyx_L20:; switch (__pyx_why) { case 3: goto __pyx_L2; case 4: { PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); __pyx_lineno = __pyx_exc_lineno; __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; goto __pyx_L3; } } } } /*finally:*/ { int __pyx_why; PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; int __pyx_exc_lineno; __pyx_why = 0; goto __pyx_L4; __pyx_L2: __pyx_why = 3; goto __pyx_L4; __pyx_L3: { __pyx_why = 4; Py_XDECREF(__pyx_5); __pyx_5 = 0; Py_XDECREF(__pyx_7); __pyx_7 = 0; Py_XDECREF(__pyx_3); __pyx_3 = 0; Py_XDECREF(__pyx_2); __pyx_2 = 0; Py_XDECREF(__pyx_4); __pyx_4 = 0; Py_XDECREF(__pyx_6); __pyx_6 = 0; PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); __pyx_exc_lineno = __pyx_lineno; goto __pyx_L4; } __pyx_L4:; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":233 */ RotatingTree_Enum(((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->written_indexes,(&__pyx_f_8pytracer_freeEntry),NULL); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":234 */ ((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->written_indexes = NULL; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":235 */ ((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->tracer_pid = (-1); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":236 */ __pyx_f_8pytracer_darray_fini((&((struct __pyx_obj_8pytracer_Tracer *)__pyx_v_self)->stack)); switch (__pyx_why) { case 3: goto __pyx_L0; case 4: { PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); __pyx_lineno = __pyx_exc_lineno; __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; goto __pyx_L1; } } } __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); Py_XDECREF(__pyx_6); Py_XDECREF(__pyx_7); __Pyx_AddTraceback("pytracer.Tracer.trace"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_exc_type); Py_DECREF(__pyx_v_exc_value); Py_DECREF(__pyx_v_exc_tb); Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_func); return __pyx_r; } static int __pyx_f_8pytracer_callback(struct __pyx_obj_8pytracer_Tracer *__pyx_v_tracer,PyObject *__pyx_v_frame,int __pyx_v_event,void *__pyx_v_trace_arg) { int __pyx_r; int __pyx_1; Py_INCREF(__pyx_v_tracer); Py_INCREF(__pyx_v_frame); /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":239 */ __pyx_1 = ((struct __pyx_vtabstruct_8pytracer_Tracer *)__pyx_v_tracer->__pyx_vtab)->_trace_event(__pyx_v_tracer,__pyx_v_frame,__pyx_v_event,__pyx_v_trace_arg); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 239; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":240 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; __Pyx_AddTraceback("pytracer.callback"); __pyx_r = (-1); __pyx_L0:; Py_DECREF(__pyx_v_tracer); Py_DECREF(__pyx_v_frame); return __pyx_r; } static __Pyx_InternTabEntry __pyx_intern_tab[] = { {&__pyx_n_Error, "Error"}, {&__pyx_n_Exception, "Exception"}, {&__pyx_n_MemoryError, "MemoryError"}, {&__pyx_n_OSError, "OSError"}, {&__pyx_n__exit, "_exit"}, {&__pyx_n__wrap_os_exit, "_wrap_os_exit"}, {&__pyx_n_co_filename, "co_filename"}, {&__pyx_n_co_name, "co_name"}, {&__pyx_n_exc_info, "exc_info"}, {&__pyx_n_f_code, "f_code"}, {&__pyx_n_f_lineno, "f_lineno"}, {&__pyx_n_fflush, "fflush"}, {&__pyx_n_fread, "fread"}, {&__pyx_n_fwrite, "fwrite"}, {&__pyx_n_getrusage, "getrusage"}, {&__pyx_n_gettimeofday, "gettimeofday"}, {&__pyx_n_graphfile_writer_init, "graphfile_writer_init"}, {&__pyx_n_graphfile_writer_set_root, "graphfile_writer_set_root"}, {&__pyx_n_graphfile_writer_write, "graphfile_writer_write"}, {&__pyx_n_id, "id"}, {&__pyx_n_max, "max"}, {&__pyx_n_os, "os"}, {&__pyx_n_sys, "sys"}, {0, 0} }; static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_k6p, __pyx_k6, sizeof(__pyx_k6)}, {&__pyx_k13p, __pyx_k13, sizeof(__pyx_k13)}, {0, 0, 0} }; static PyObject *__pyx_tp_new_8pytracer__Linkable(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; return o; } static void __pyx_tp_dealloc_8pytracer__Linkable(PyObject *o) { (*o->ob_type->tp_free)(o); } static int __pyx_tp_traverse_8pytracer__Linkable(PyObject *o, visitproc v, void *a) { return 0; } static int __pyx_tp_clear_8pytracer__Linkable(PyObject *o) { return 0; } static struct PyMethodDef __pyx_methods_8pytracer__Linkable[] = { {0, 0, 0, 0} }; static PyNumberMethods __pyx_tp_as_number__Linkable = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ 0, /*nb_divide*/ 0, /*nb_remainder*/ 0, /*nb_divmod*/ 0, /*nb_power*/ 0, /*nb_negative*/ 0, /*nb_positive*/ 0, /*nb_absolute*/ 0, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ 0, /*nb_coerce*/ 0, /*nb_int*/ 0, /*nb_long*/ 0, /*nb_float*/ 0, /*nb_oct*/ 0, /*nb_hex*/ 0, /*nb_inplace_add*/ 0, /*nb_inplace_subtract*/ 0, /*nb_inplace_multiply*/ 0, /*nb_inplace_divide*/ 0, /*nb_inplace_remainder*/ 0, /*nb_inplace_power*/ 0, /*nb_inplace_lshift*/ 0, /*nb_inplace_rshift*/ 0, /*nb_inplace_and*/ 0, /*nb_inplace_xor*/ 0, /*nb_inplace_or*/ 0, /*nb_floor_divide*/ 0, /*nb_true_divide*/ 0, /*nb_inplace_floor_divide*/ 0, /*nb_inplace_true_divide*/ #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX 0, /*nb_index*/ #endif }; static PySequenceMethods __pyx_tp_as_sequence__Linkable = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ 0, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ 0, /*sq_contains*/ 0, /*sq_inplace_concat*/ 0, /*sq_inplace_repeat*/ }; static PyMappingMethods __pyx_tp_as_mapping__Linkable = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; static PyBufferProcs __pyx_tp_as_buffer__Linkable = { 0, /*bf_getreadbuffer*/ 0, /*bf_getwritebuffer*/ 0, /*bf_getsegcount*/ 0, /*bf_getcharbuffer*/ }; PyTypeObject __pyx_type_8pytracer__Linkable = { PyObject_HEAD_INIT(0) 0, /*ob_size*/ "pytracer._Linkable", /*tp_name*/ sizeof(struct __pyx_obj_8pytracer__Linkable), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_8pytracer__Linkable, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ &__pyx_tp_as_number__Linkable, /*tp_as_number*/ &__pyx_tp_as_sequence__Linkable, /*tp_as_sequence*/ &__pyx_tp_as_mapping__Linkable, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer__Linkable, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_8pytracer__Linkable, /*tp_traverse*/ __pyx_tp_clear_8pytracer__Linkable, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_8pytracer__Linkable, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_8pytracer__Linkable, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ }; static struct __pyx_vtabstruct_8pytracer_Tracer __pyx_vtable_8pytracer_Tracer; static PyObject *__pyx_tp_new_8pytracer_Tracer(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_8pytracer_Tracer *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; p = ((struct __pyx_obj_8pytracer_Tracer *)o); *(struct __pyx_vtabstruct_8pytracer_Tracer **)&p->__pyx_vtab = __pyx_vtabptr_8pytracer_Tracer; p->fileobj = Py_None; Py_INCREF(Py_None); p->index_fileobj = Py_None; Py_INCREF(Py_None); p->_prev_os_exit = Py_None; Py_INCREF(Py_None); if (__pyx_f_8pytracer_6Tracer___cinit__(o, a, k) < 0) { Py_DECREF(o); o = 0; } return o; } static void __pyx_tp_dealloc_8pytracer_Tracer(PyObject *o) { struct __pyx_obj_8pytracer_Tracer *p = (struct __pyx_obj_8pytracer_Tracer *)o; { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++o->ob_refcnt; __pyx_f_8pytracer_6Tracer___dealloc__(o); if (PyErr_Occurred()) PyErr_WriteUnraisable(o); --o->ob_refcnt; PyErr_Restore(etype, eval, etb); } Py_XDECREF(p->fileobj); Py_XDECREF(p->index_fileobj); Py_XDECREF(p->_prev_os_exit); (*o->ob_type->tp_free)(o); } static int __pyx_tp_traverse_8pytracer_Tracer(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_8pytracer_Tracer *p = (struct __pyx_obj_8pytracer_Tracer *)o; if (p->fileobj) { e = (*v)(p->fileobj, a); if (e) return e; } if (p->index_fileobj) { e = (*v)(p->index_fileobj, a); if (e) return e; } if (p->_prev_os_exit) { e = (*v)(p->_prev_os_exit, a); if (e) return e; } return 0; } static int __pyx_tp_clear_8pytracer_Tracer(PyObject *o) { struct __pyx_obj_8pytracer_Tracer *p = (struct __pyx_obj_8pytracer_Tracer *)o; Py_XDECREF(p->fileobj); p->fileobj = Py_None; Py_INCREF(Py_None); Py_XDECREF(p->index_fileobj); p->index_fileobj = Py_None; Py_INCREF(Py_None); Py_XDECREF(p->_prev_os_exit); p->_prev_os_exit = Py_None; Py_INCREF(Py_None); return 0; } static struct PyMethodDef __pyx_methods_8pytracer_Tracer[] = { {"_wrap_os_exit", (PyCFunction)__pyx_f_8pytracer_6Tracer__wrap_os_exit, METH_VARARGS|METH_KEYWORDS, 0}, {"trace", (PyCFunction)__pyx_f_8pytracer_6Tracer_trace, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static struct PyMemberDef __pyx_members_8pytracer_Tracer[] = { {"fileobj", T_OBJECT, offsetof(struct __pyx_obj_8pytracer_Tracer, fileobj), READONLY, 0}, {"index_fileobj", T_OBJECT, offsetof(struct __pyx_obj_8pytracer_Tracer, index_fileobj), READONLY, 0}, {0, 0, 0, 0, 0} }; static PyNumberMethods __pyx_tp_as_number_Tracer = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ 0, /*nb_divide*/ 0, /*nb_remainder*/ 0, /*nb_divmod*/ 0, /*nb_power*/ 0, /*nb_negative*/ 0, /*nb_positive*/ 0, /*nb_absolute*/ 0, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ 0, /*nb_coerce*/ 0, /*nb_int*/ 0, /*nb_long*/ 0, /*nb_float*/ 0, /*nb_oct*/ 0, /*nb_hex*/ 0, /*nb_inplace_add*/ 0, /*nb_inplace_subtract*/ 0, /*nb_inplace_multiply*/ 0, /*nb_inplace_divide*/ 0, /*nb_inplace_remainder*/ 0, /*nb_inplace_power*/ 0, /*nb_inplace_lshift*/ 0, /*nb_inplace_rshift*/ 0, /*nb_inplace_and*/ 0, /*nb_inplace_xor*/ 0, /*nb_inplace_or*/ 0, /*nb_floor_divide*/ 0, /*nb_true_divide*/ 0, /*nb_inplace_floor_divide*/ 0, /*nb_inplace_true_divide*/ #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX 0, /*nb_index*/ #endif }; static PySequenceMethods __pyx_tp_as_sequence_Tracer = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ 0, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ 0, /*sq_contains*/ 0, /*sq_inplace_concat*/ 0, /*sq_inplace_repeat*/ }; static PyMappingMethods __pyx_tp_as_mapping_Tracer = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; static PyBufferProcs __pyx_tp_as_buffer_Tracer = { 0, /*bf_getreadbuffer*/ 0, /*bf_getwritebuffer*/ 0, /*bf_getsegcount*/ 0, /*bf_getcharbuffer*/ }; PyTypeObject __pyx_type_8pytracer_Tracer = { PyObject_HEAD_INIT(0) 0, /*ob_size*/ "pytracer.Tracer", /*tp_name*/ sizeof(struct __pyx_obj_8pytracer_Tracer), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_8pytracer_Tracer, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ &__pyx_tp_as_number_Tracer, /*tp_as_number*/ &__pyx_tp_as_sequence_Tracer, /*tp_as_sequence*/ &__pyx_tp_as_mapping_Tracer, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_Tracer, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_8pytracer_Tracer, /*tp_traverse*/ __pyx_tp_clear_8pytracer_Tracer, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_8pytracer_Tracer, /*tp_methods*/ __pyx_members_8pytracer_Tracer, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_8pytracer_Tracer, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ }; static struct PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; static void __pyx_init_filenames(void); /*proto*/ PyMODINIT_FUNC initpytracer(void); /*proto*/ PyMODINIT_FUNC initpytracer(void) { PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; __pyx_init_filenames(); __pyx_m = Py_InitModule4("pytracer", __pyx_methods, 0, 0, PYTHON_API_VERSION); if (!__pyx_m) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 1; goto __pyx_L1;}; Py_INCREF(__pyx_m); __pyx_b = PyImport_AddModule("__builtin__"); if (!__pyx_b) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 1; goto __pyx_L1;}; if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 1; goto __pyx_L1;}; if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 1; goto __pyx_L1;}; if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 1; goto __pyx_L1;}; if (PyType_Ready(&__pyx_type_8pytracer__Linkable) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 53; goto __pyx_L1;} if (PyObject_SetAttrString(__pyx_m, "_Linkable", (PyObject *)&__pyx_type_8pytracer__Linkable) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 53; goto __pyx_L1;} __pyx_ptype_8pytracer__Linkable = &__pyx_type_8pytracer__Linkable; __pyx_vtabptr_8pytracer_Tracer = &__pyx_vtable_8pytracer_Tracer; *(void(**)(void))&__pyx_vtable_8pytracer_Tracer.call_invocation_init = (void(*)(void))__pyx_f_8pytracer_6Tracer_call_invocation_init; *(void(**)(void))&__pyx_vtable_8pytracer_Tracer._trace_event = (void(*)(void))__pyx_f_8pytracer_6Tracer__trace_event; *(void(**)(void))&__pyx_vtable_8pytracer_Tracer._push_call = (void(*)(void))__pyx_f_8pytracer_6Tracer__push_call; *(void(**)(void))&__pyx_vtable_8pytracer_Tracer._pop_call = (void(*)(void))__pyx_f_8pytracer_6Tracer__pop_call; *(void(**)(void))&__pyx_vtable_8pytracer_Tracer._index_of_code = (void(*)(void))__pyx_f_8pytracer_6Tracer__index_of_code; *(void(**)(void))&__pyx_vtable_8pytracer_Tracer._write = (void(*)(void))__pyx_f_8pytracer_6Tracer__write; *(void(**)(void))&__pyx_vtable_8pytracer_Tracer._push_root = (void(*)(void))__pyx_f_8pytracer_6Tracer__push_root; *(void(**)(void))&__pyx_vtable_8pytracer_Tracer._pop_root = (void(*)(void))__pyx_f_8pytracer_6Tracer__pop_root; *(void(**)(void))&__pyx_vtable_8pytracer_Tracer._pop_to_root = (void(*)(void))__pyx_f_8pytracer_6Tracer__pop_to_root; __pyx_type_8pytracer_Tracer.tp_free = _PyObject_GC_Del; if (PyType_Ready(&__pyx_type_8pytracer_Tracer) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 56; goto __pyx_L1;} if (__Pyx_SetVtable(__pyx_type_8pytracer_Tracer.tp_dict, __pyx_vtabptr_8pytracer_Tracer) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 56; goto __pyx_L1;} if (PyObject_SetAttrString(__pyx_m, "Tracer", (PyObject *)&__pyx_type_8pytracer_Tracer) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 56; goto __pyx_L1;} __pyx_ptype_8pytracer_Tracer = &__pyx_type_8pytracer_Tracer; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":10 */ __pyx_1 = __Pyx_Import(__pyx_n_os, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 10; goto __pyx_L1;} if (PyObject_SetAttr(__pyx_m, __pyx_n_os, __pyx_1) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 10; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":11 */ __pyx_1 = __Pyx_Import(__pyx_n_sys, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 11; goto __pyx_L1;} if (PyObject_SetAttr(__pyx_m, __pyx_n_sys, __pyx_1) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 11; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":51 */ __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 51; goto __pyx_L1;} __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_Exception); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 51; goto __pyx_L1;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 51; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); __pyx_2 = 0; __pyx_2 = __Pyx_CreateClass(__pyx_3, __pyx_1, __pyx_n_Error, "pytracer"); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 51; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_Error, __pyx_2) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 51; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; /* "/home/peaker/devel/pythontracer/main/tracer/pytracer.pyx":238 */ return; __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); __Pyx_AddTraceback("pytracer"); } static char *__pyx_filenames[] = { "times.pyx", "memory.pyx", "python.pyx", "darray.pyx", "files.pyx", "pytracer.pyx", }; /* Runtime support code */ static void __pyx_init_filenames(void) { __pyx_f = __pyx_filenames; } static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) { PyObject *__import__ = 0; PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; __import__ = PyObject_GetAttrString(__pyx_b, "__import__"); if (!__import__) goto bad; if (from_list) list = from_list; else { empty_list = PyList_New(0); if (!empty_list) goto bad; list = empty_list; } global_dict = PyModule_GetDict(__pyx_m); if (!global_dict) goto bad; empty_dict = PyDict_New(); if (!empty_dict) goto bad; module = PyObject_CallFunction(__import__, "OOOO", name, global_dict, empty_dict, list); bad: Py_XDECREF(empty_list); Py_XDECREF(__import__); Py_XDECREF(empty_dict); return module; } static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { PyObject *result; result = PyObject_GetAttr(dict, name); if (!result) PyErr_SetObject(PyExc_NameError, name); return result; } static PyObject *__Pyx_CreateClass( PyObject *bases, PyObject *dict, PyObject *name, char *modname) { PyObject *py_modname; PyObject *result = 0; py_modname = PyString_FromString(modname); if (!py_modname) goto bad; if (PyDict_SetItemString(dict, "__module__", py_modname) < 0) goto bad; result = PyClass_New(bases, dict, name); bad: Py_XDECREF(py_modname); return result; } static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { Py_XINCREF(type); Py_XINCREF(value); Py_XINCREF(tb); /* First, check the traceback argument, replacing None with NULL. */ if (tb == Py_None) { Py_DECREF(tb); tb = 0; } else if (tb != NULL && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } /* Next, replace a missing value with None */ if (value == NULL) { value = Py_None; Py_INCREF(value); } #if PY_VERSION_HEX < 0x02050000 if (!PyClass_Check(type)) #else if (!PyType_Check(type)) #endif { /* Raising an instance. The value should be a dummy. */ if (value != Py_None) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } /* Normalize to raise , */ Py_DECREF(value); value = type; #if PY_VERSION_HEX < 0x02050000 if (PyInstance_Check(type)) { type = (PyObject*) ((PyInstanceObject*)type)->in_class; Py_INCREF(type); } else { PyErr_SetString(PyExc_TypeError, "raise: exception must be an old-style class or instance"); goto raise_error; } #else type = (PyObject*) type->ob_type; Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } #endif } PyErr_Restore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } static void __Pyx_WriteUnraisable(char *name) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; PyErr_Fetch(&old_exc, &old_val, &old_tb); ctx = PyString_FromString(name); PyErr_Restore(old_exc, old_val, old_tb); if (!ctx) ctx = Py_None; PyErr_WriteUnraisable(ctx); } static void __Pyx_UnpackError(void) { PyErr_SetString(PyExc_ValueError, "unpack sequence of wrong size"); } static PyObject *__Pyx_UnpackItem(PyObject *iter) { PyObject *item; if (!(item = PyIter_Next(iter))) { if (!PyErr_Occurred()) __Pyx_UnpackError(); } return item; } static int __Pyx_EndUnpack(PyObject *iter) { PyObject *item; if ((item = PyIter_Next(iter))) { Py_DECREF(item); __Pyx_UnpackError(); return -1; } else if (!PyErr_Occurred()) return 0; else return -1; } static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { PyThreadState *tstate = PyThreadState_Get(); PyErr_Fetch(type, value, tb); PyErr_NormalizeException(type, value, tb); if (PyErr_Occurred()) goto bad; Py_INCREF(*type); Py_INCREF(*value); Py_INCREF(*tb); Py_XDECREF(tstate->exc_type); Py_XDECREF(tstate->exc_value); Py_XDECREF(tstate->exc_traceback); tstate->exc_type = *type; tstate->exc_value = *value; tstate->exc_traceback = *tb; return 0; bad: Py_XDECREF(*type); Py_XDECREF(*value); Py_XDECREF(*tb); return -1; } static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) { while (t->p) { *t->p = PyString_InternFromString(t->s); if (!*t->p) return -1; ++t; } return 0; } static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); if (!*t->p) return -1; ++t; } return 0; } static int __Pyx_SetVtable(PyObject *dict, void *vtable) { PyObject *pycobj = 0; int result; pycobj = PyCObject_FromVoidPtr(vtable, 0); if (!pycobj) goto bad; if (PyDict_SetItemString(dict, "__pyx_vtable__", pycobj) < 0) goto bad; result = 0; goto done; bad: result = -1; done: Py_XDECREF(pycobj); return result; } #include "compile.h" #include "frameobject.h" #include "traceback.h" static void __Pyx_AddTraceback(char *funcname) { PyObject *py_srcfile = 0; PyObject *py_funcname = 0; PyObject *py_globals = 0; PyObject *empty_tuple = 0; PyObject *empty_string = 0; PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; py_srcfile = PyString_FromString(__pyx_filename); if (!py_srcfile) goto bad; py_funcname = PyString_FromString(funcname); if (!py_funcname) goto bad; py_globals = PyModule_GetDict(__pyx_m); if (!py_globals) goto bad; empty_tuple = PyTuple_New(0); if (!empty_tuple) goto bad; empty_string = PyString_FromString(""); if (!empty_string) goto bad; py_code = PyCode_New( 0, /*int argcount,*/ 0, /*int nlocals,*/ 0, /*int stacksize,*/ 0, /*int flags,*/ empty_string, /*PyObject *code,*/ empty_tuple, /*PyObject *consts,*/ empty_tuple, /*PyObject *names,*/ empty_tuple, /*PyObject *varnames,*/ empty_tuple, /*PyObject *freevars,*/ empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ __pyx_lineno, /*int firstlineno,*/ empty_string /*PyObject *lnotab*/ ); if (!py_code) goto bad; py_frame = PyFrame_New( PyThreadState_Get(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ py_globals, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = __pyx_lineno; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); Py_XDECREF(empty_tuple); Py_XDECREF(empty_string); Py_XDECREF(py_code); Py_XDECREF(py_frame); } pythontracer-8.10.16/tracer/__init__.py0000644000175000017500000000000011071710600017261 0ustar peakerpeakerpythontracer-8.10.16/TODO0000664000175000017500000000175211075700350014406 0ustar peakerpeaker* Improve command line processing/error reporting. Perhaps allow -view to use the same command to view a profile.out * How to access VERSION in pytracefile.py? * Reorganize to: ? libs/ graphfile* pyrex-libs* tracer/ * Tracer: * When pid is wrong, don't "ignore", kill all remains of tracer? * Profile the profiler. Maybe a C lib (graphfile) is too slow? * Alternate format? * Just append everything immediately, leaving room to fill in forward ptrs and data is better to allow it to die at any stage (Avoid set_root) * Can an alternate format also allow cyclic writes into shared memory? * Are there any advantages to using shared memory? Getting the inter-thread order rights * Add more information about call/ret (params, ret value -- print their types? ids?) * Viewer: * Replace gtk.treeview! :-( * sort? * enable search Not really necessary: * show generator.next() differently to a normal call, maybe show the func_name.next() or something like that pythontracer-8.10.16/graphfile/0000755000175000017500000000000011075677505015667 5ustar peakerpeakerpythontracer-8.10.16/graphfile/TODO0000644000175000017500000000022411066666614016354 0ustar peakerpeaker* Use alignments to save some bits in the relative offsets * Consistent names (no "node", just "linkable" or vice versa) * In python bindings too pythontracer-8.10.16/graphfile/graphfile_internal.h0000644000175000017500000000104411075676651021675 0ustar peakerpeaker#ifndef __graphfile_internal_h_ #define __graphfile_internal_h_ /* TODO: Clean this up into a 64-bit file access abstraction * library */ #include #include #ifdef _LARGEFILE64_SOURCE typedef off64_t graphfile_offset_t; #define graphfile_seek lseek64 #else typedef off_t graphfile_offset_t; #define graphfile_seek lseek #endif struct graphfile_writer { FILE *file; graphfile_offset_t offset; }; struct graphfile_reader { FILE *file; }; struct graphfile_linkable { graphfile_offset_t offset; }; #endif pythontracer-8.10.16/graphfile/graphfile.c0000644000175000017500000001512011075677505017773 0ustar peakerpeaker#include "graphfile.h" #include #include #include #include #include #define IF_ERR_RETURN(result) do { if(-1 == (result)) return -1; } while(0) static int writen(FILE *f, const void *buffer, size_t buffer_size) { /* TODO: Really writen here... */ if(buffer_size != fwrite(buffer, 1, buffer_size, f)) { return -1; } return 0; } static int readn(FILE *f, void *buffer, size_t buffer_size) { /* TODO: Really readn here... */ if(buffer_size != fread(buffer, 1, buffer_size, f)) { return -1; } return 0; } #define GNUMBER_BARKER_SIZE (3) #define GNUMBER_BARKER ((1UL<<(8*GNUMBER_BARKER_SIZE))-1) static unsigned char gnumber_barker[GNUMBER_BARKER_SIZE] = { 0xFF, 0xFF, 0xFF }; static graphfile_size_t write_gnumber(FILE *f, uint64_t number64) { /* Endianness is crap :-( To overcome it, lets do this: */ if(number64 < GNUMBER_BARKER) { unsigned char gnumber[GNUMBER_BARKER_SIZE] = { (uint8_t)(number64 >> 0), (uint8_t)(number64 >> 8), (uint8_t)(number64 >> 16) }; IF_ERR_RETURN(writen(f, gnumber, sizeof gnumber)); return sizeof gnumber; } IF_ERR_RETURN(writen(f, gnumber_barker, sizeof gnumber_barker)); IF_ERR_RETURN(writen(f, &number64, sizeof number64)); return sizeof gnumber_barker + sizeof number64; } static graphfile_size_t read_gnumber(FILE *f, uint64_t *p_number64) { unsigned char gnumber[GNUMBER_BARKER_SIZE]; IF_ERR_RETURN(readn(f, gnumber, sizeof gnumber)); if(0 != memcmp(gnumber, gnumber_barker, GNUMBER_BARKER_SIZE)) { (*p_number64) = ((((uint64_t)gnumber[0]) << 0) + (((uint64_t)gnumber[1]) << 8) + (((uint64_t)gnumber[2]) << 16)); return sizeof gnumber; } IF_ERR_RETURN(readn(f, p_number64, sizeof *p_number64)); return sizeof gnumber + sizeof *p_number64; } static int safe_fileno(FILE *f) { /* Must fflush before messing with the fd of a (FILE*) */ if(0 != fflush(f)) { return -1; } /* May return -1 */ return fileno(f); } static int seek(FILE *f, graphfile_offset_t offset) { int fd = safe_fileno(f); IF_ERR_RETURN(fd); if(((graphfile_offset_t)-1) == graphfile_seek(fd, offset, SEEK_SET)) { return -1; } return 0; } static graphfile_offset_t tell(FILE *f) { int fd = safe_fileno(f); IF_ERR_RETURN(fd); return graphfile_seek(fd, 0, SEEK_CUR); } int graphfile_writer_init(graphfile_writer_t *graphfile_writer, FILE *file) { graphfile_offset_t offset; graphfile_writer->file = file; if(-1 == fseek(file, 0, SEEK_END)) { /* A seekable file must be used */ return -1; } offset = tell(file); if(((graphfile_offset_t)-1 == offset) || (offset > 0)) { /* An empty file must be used */ return -1; } /* POSIX allows seeking to beyond the end of the file */ IF_ERR_RETURN(seek(file, sizeof(graphfile_linkable_t))); graphfile_writer->offset = sizeof(graphfile_linkable_t); return 0; } int graphfile_writer_set_root(graphfile_writer_t *graphfile_writer, graphfile_linkable_t *root) { FILE *file = graphfile_writer->file; IF_ERR_RETURN(seek(file, 0)); IF_ERR_RETURN(writen(file, root, sizeof *root)); if(0 != fseek(file, 0, SEEK_END)) { return -1; } return 0; } void graphfile_writer_fini(graphfile_writer_t *graphfile_writer) { /* Not much to do here */ } int graphfile_writer_write(graphfile_writer_t *graphfile_writer, char *buffer, graphfile_size_t buffer_length, graphfile_linkable_t linkables[], graphfile_size_t linkable_count, graphfile_linkable_t *result_linkable) { graphfile_size_t i; graphfile_size_t size; FILE *file = graphfile_writer->file; graphfile_offset_t offset = graphfile_writer->offset; /* TODO: Clean up all this code duplication */ IF_ERR_RETURN(size = write_gnumber(file, buffer_length)); graphfile_writer->offset += size; IF_ERR_RETURN(writen(file, buffer, buffer_length)); graphfile_writer->offset += buffer_length; IF_ERR_RETURN(size = write_gnumber(file, linkable_count)); graphfile_writer->offset += size; for(i = 0; i < linkable_count; ++i) { IF_ERR_RETURN(size = write_gnumber(file, offset - linkables[i].offset)); graphfile_writer->offset += size; } result_linkable->offset = offset; return 0; } int graphfile_reader_init(graphfile_reader_t *graphfile_reader, FILE *file, graphfile_linkable_t *result_root) { graphfile_reader->file = file; /* A seekable file must be used */ IF_ERR_RETURN(seek(file, 0)); /* A readable, coherent file must be used, so it must have a * readable root. */ IF_ERR_RETURN(readn(file, result_root, sizeof *result_root)); if(0 == result_root->offset) { /* Root cannot be 0. If it is 0, it means that the file was * never set_root'd properly, and is corrupt. */ return -1; } return 0; } void graphfile_reader_fini(graphfile_reader_t *graphfile_reader) { /* Nothing to do here */ } #define UNSAFE_MIN(a, b) (((a) <= (b)) ? (a) : (b)) int graphfile_reader_read(graphfile_reader_t *graphfile_reader, graphfile_linkable_t *node, char *result_buffer, graphfile_size_t max_buffer_length, graphfile_size_t *result_buffer_length, graphfile_linkable_t result_linkables[], graphfile_size_t max_linkable_count, graphfile_size_t *result_linkables_count) { graphfile_size_t i; graphfile_size_t min_linkable_count; uint64_t relative_offset; uint64_t buffer_length; uint64_t linkables_count; graphfile_size_t size; FILE *file = graphfile_reader->file; IF_ERR_RETURN(seek(file, node->offset)); IF_ERR_RETURN(size = read_gnumber(file, &buffer_length)); IF_ERR_RETURN(readn(file, result_buffer, UNSAFE_MIN(max_buffer_length, buffer_length))); IF_ERR_RETURN(seek(file, node->offset + size + buffer_length)); IF_ERR_RETURN(read_gnumber(file, &linkables_count)); min_linkable_count = UNSAFE_MIN(max_linkable_count, linkables_count); for(i = 0; i < min_linkable_count; ++i) { IF_ERR_RETURN(read_gnumber(file, &relative_offset)); result_linkables[i].offset = node->offset - relative_offset; } (*result_linkables_count) = linkables_count; (*result_buffer_length) = buffer_length; return 0; } pythontracer-8.10.16/graphfile/README0000644000175000017500000000105511066666614016547 0ustar peakerpeakerGraphfile is a graph serialization library. It is currently of limited scope and only meant to support write in append-only mode where nodes must consist of a binary blob, and links to other nodes. The serialized file has the following format: The file begins with an absolute 64-bit offset, of the "root" node. The bytes at that offset will contain a Node, of the structure: Type Name gnumber Size of arbitrary data binary Arbitrary data gnumber Number of offsets gnumbers Unsigned numbers representing relative offsets pointing backwards pythontracer-8.10.16/graphfile/graphfile.h0000644000175000017500000000353310766523217020001 0ustar peakerpeaker#ifndef __graphfile_h_ #define __graphfile_h_ #include "graphfile_internal.h" #include typedef struct graphfile_writer graphfile_writer_t; typedef struct graphfile_reader graphfile_reader_t; typedef struct graphfile_linkable graphfile_linkable_t; typedef unsigned long long graphfile_size_t; /* All int return types return zero to indicate success */ /* An empty, seekable and writable file must be referenced by file. * Noone else must move the offset of the file while the writer is active * (until it is finalized). */ int graphfile_writer_init(graphfile_writer_t *graphfile_writer, FILE *); /* This must be called to get a coherent file. */ int graphfile_writer_set_root(graphfile_writer_t *graphfile_writer, graphfile_linkable_t *root); void graphfile_writer_fini(graphfile_writer_t *graphfile_writer); int graphfile_writer_write(graphfile_writer_t *graphfile_writer, char *buffer, graphfile_size_t buffer_length, graphfile_linkable_t linkables[], graphfile_size_t linkable_count, graphfile_linkable_t *result_linkable); /* A coherent, seekable and readable file must be referenced by file. */ int graphfile_reader_init(graphfile_reader_t *graphfile_reader, FILE *, graphfile_linkable_t *result_root); void graphfile_reader_fini(graphfile_reader_t *graphfile_reader); int graphfile_reader_read(graphfile_reader_t *graphfile_reader, graphfile_linkable_t *node, char *result_buffer, graphfile_size_t max_buffer_length, graphfile_size_t *result_buffer_length, graphfile_linkable_t result_linkables[], graphfile_size_t max_linkable_count, graphfile_size_t *result_linkables_count); #endif pythontracer-8.10.16/graphfile/Makefile0000644000175000017500000000007510760205757017325 0ustar peakerpeakerCC=gcc -g -Wall -c graphfile.o: graphfile.c $(CC) -o $@ $< pythontracer-8.10.16/pytracerview.py0000644000175000017500000003230211075703306017011 0ustar peakerpeaker#!/usr/bin/env python import gtk import sys import struct from graphfile import Reader class AddFilterDialog(gtk.Dialog): def __init__(self): gtk.Dialog.__init__(self, "Add filter", buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)) self.connect("response", self.handle_response) realtime_filter_box = gtk.HBox() realtime_filter_label = gtk.Label("Minimum real time shown") realtime_filter_box.add(realtime_filter_label) self.number = gtk.Adjustment(0, 0, 5, 0.001) realtime_filter_number_spinbox = gtk.SpinButton(self.number, climb_rate=0.001, digits=3) realtime_filter_box.add(realtime_filter_number_spinbox) realtime_filter_number_slider = gtk.HScale() realtime_filter_number_slider.set_adjustment(self.number) realtime_filter_number_slider.set_digits(5) realtime_filter_number_slider.set_size_request(300, -1) realtime_filter_box.add(realtime_filter_number_slider) self.vbox.add(realtime_filter_box) def handle_response(self, dialog, response_id): self.hide() class Model(gtk.GenericTreeModel): # rowref <-> path are the same here def on_get_n_columns(self): return len(self.column_types) def on_get_column_type(self, index): return self.column_types[index] def on_get_iter(self, path): return path def on_get_path(self, path): return tuple(path) def on_get_value(self, path, column): return self.column_getters[column](self, path) def on_iter_children(self, path): return self.on_iter_nth_child(path, 0) def on_iter_has_child(self, path): return bool(self.on_iter_n_children(path)) def on_iter_next(self, path): parent = self.on_iter_parent(path) if path[-1]+1 >= self.on_iter_n_children(parent): return None return self.on_iter_nth_child(parent, path[-1]+1) def on_iter_parent(self, path): return path[:-1] class TraceReader(Model): def __init__(self, code_index, graph_reader, root): self.code_index = code_index self.graph_reader = graph_reader self.root = root Model.__init__(self) def on_get_flags(self): return gtk.TREE_MODEL_ITERS_PERSIST def on_iter_n_children(self, path): if path is None: path = () data, children = self.read(path) return len(children) def on_iter_nth_child(self, path, n): if path is None: path = () if n >= self.on_iter_n_children(path): return None return tuple(path) + (n,) _format = struct.Struct('hiddd') def _decode(self, data): if not data: return None code_index, lineno, user_time, sys_time, real_time = self._format.unpack(data) filename, name = self.code_index[code_index] return ((filename, name, lineno), (user_time, sys_time, real_time)) def read_linkable(self, linkable): data, children = self.graph_reader.read(linkable) return self._decode(data), children def iter(self, path): cur = self.root for index in path: data, children = self.graph_reader.read(cur) cur = children[index] return cur def read(self, path): return self.read_linkable(self.iter(path)) def format_time(self, x): return '%.5f' % (x,) def _get_user_time(self, path): (code, (user_time, sys_time, real_time)), children = self.read(path) return self.format_time(user_time) def _get_sys_time(self, path): (code, (user_time, sys_time, real_time)), children = self.read(path) return self.format_time(sys_time) def _get_real_time(self, path): (code, (user_time, sys_time, real_time)), children = self.read(path) return self.format_time(real_time/1000000.) def _get_namestr(self, path): ((module_name, func_name, lineno), times), children = self.read(path) return func_name def _get_filenamestr(self, path): ((module_name, func_name, lineno), times), children = self.read(path) return '%s(%d)' % (module_name, lineno) column_getters = [_get_filenamestr, _get_namestr, _get_user_time, _get_sys_time, _get_real_time] column_types = [str, str, str, str, str] class TraceTree(gtk.ScrolledWindow): def __init__(self, code_index, graph_reader, root): gtk.ScrolledWindow.__init__(self) self._treestore = TraceReader(code_index, graph_reader, root) self.treestore = self._treestore.filter_new() self.treestore.set_visible_func(self._filter_func) self._min_realtime_filter = 0 self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.tree_view = gtk.TreeView() self.tree_view.set_property('enable-search', False) self.tree_view.set_model(self.treestore) self.add(self.tree_view) filename_column = self._create_column('Filename', 0) name_column = self._create_column('Name', 1) user_time_column = self._create_column('User Time', 2) system_time_column = self._create_column('System Time', 3) real_time_column = self._create_column('Real Time', 4) # name_column.set_sort_column_id(0) # self.tree_view.set_search_column(0) def _filter_func(self, model, iter): # TODO: Replace the literal column number real_time = float(model.get_value(iter, 4)) return real_time >= self._min_realtime_filter def set_min_realtime_filter(self, min_real_time): self._min_realtime_filter = min_real_time self.treestore.refilter() def cursor_node(self): path, column = self.tree_view.get_cursor() return self._treestore.iter(path) def cursor(self): path, column = self.tree_view.get_cursor() return self._treestore.read(path), column def watch_cursor(self, callback): def cursor_changed(tree_view): item, column = self.cursor() callback(item, column) self.tree_view.connect("cursor-changed", cursor_changed) def _create_column(self, title, column_id): cell = gtk.CellRendererText() column = gtk.TreeViewColumn(title) column.pack_start(cell, True) # column.set_max_width(400) column.add_attribute(cell, 'text', column_id) column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) self.tree_view.append_column(column) return column def ui_expand_and_jump_to_biggest(self): path, column = self.tree_view.get_cursor() self.tree_view.expand_row(path, False) data, children = self._treestore.read(path) def child_times(index, child): (code, (user_time, sys_time, real_time)), children = self._treestore.read_linkable(child) return (real_time, index) if children: max_real_time, max_index = max(child_times(index, child) for index, child in enumerate(children)) self.tree_view.set_cursor(path + (max_index,)) def handle_response(self, dialog, response): if gtk.RESPONSE_OK == response: value = dialog.number.get_value() self.set_min_realtime_filter(value) dialog.destroy() def ui_set_min_realtime_filter(self): dialog = AddFilterDialog() dialog.connect("response", self.handle_response) dialog.show_all() def ui_collapse(self): path, column = self.tree_view.get_cursor() if self.tree_view.row_expanded(path): self.tree_view.collapse_row(path) elif len(path) >= 2: self.tree_view.set_cursor(path[:-1]) def ui_expand(self): path, column = self.tree_view.get_cursor() if not self.treestore.iter_has_child(self.treestore.get_iter(path)): return self.tree_view.expand_row(path, False) self.tree_view.set_cursor(path + (0,)) class CodePane(gtk.Frame): def __init__(self): gtk.Frame.__init__(self, '') self.scrolled_window = gtk.ScrolledWindow() self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.text_buffer = gtk.TextBuffer() self.text_view = gtk.TextView(self.text_buffer) self.text_view.set_editable(False) self.highlighted_tag = self.text_buffer.create_tag(background="lightblue") self.scrolled_window.add(self.text_view) self.add(self.scrolled_window) self._current_filename = None def watch(self, filename, lineno): if self._current_filename != filename: self._current_filename = filename try: data = open(filename, 'rb').read() except (OSError, IOError): data = "Error: Cannot read %r" % (filename,) self.text_buffer.set_text(data) self.set_label(filename) self.last_tag = None if self.last_tag is not None: before_iter, after_iter = self.last_tag self.text_buffer.remove_tag(self.highlighted_tag, before_iter, after_iter) before_iter = self.text_buffer.get_iter_at_line_index(lineno, 0) after_iter = self.text_buffer.get_iter_at_line_index(lineno+1, 0) self.text_buffer.apply_tag(self.highlighted_tag, before_iter, after_iter) self.last_tag = before_iter, after_iter mark = self.text_buffer.create_mark('', before_iter) self.text_view.scroll_to_mark(mark, 0, use_align=True) class TraceView(gtk.VPaned): def __init__(self, app, code_index, graph_reader, root): gtk.VPaned.__init__(self) self.app = app self.code_index = code_index self.graph_reader = graph_reader self.trace_tree = TraceTree(self.code_index, self.graph_reader, root) self.code_pane = CodePane() self.pack1(self.trace_tree, resize=True) self.pack2(self.code_pane, resize=False) def callback(item, column): data, children = item (filename, funcname, lineno), times = data self.code_pane.watch(filename, lineno-1) self.trace_tree.watch_cursor(callback) def ui_expand_and_jump_to_biggest(self): self.trace_tree.ui_expand_and_jump_to_biggest() def ui_set_min_realtime_filter(self): self.trace_tree.ui_set_min_realtime_filter() def ui_collapse(self): self.trace_tree.ui_collapse() def ui_expand(self): self.trace_tree.ui_expand() def ui_new_window(self): (((filename, funcname, lineno), times), children), column = self.trace_tree.cursor() self.app.new_window(self.graph_reader, self.trace_tree.cursor_node(), ':%s:%s' % (filename, funcname)) class Application(object): def __init__(self, code_index, graph_reader, root): self._window_count = 0 self.new_window(code_index, graph_reader, root, '') def new_window(self, code_index, graph_reader, root, suffix): trace_view = TraceView(self, code_index, graph_reader, root) ag = gtk.AccelGroup() ag.connect_group(gtk.keysyms.q, gtk.gdk.CONTROL_MASK, 0, gtk.main_quit) def drop_args_func(func): def new_func(*args): return func() return new_func def set_shortcut_key(func, key, mod=0): ag.connect_group(key, mod, 0, drop_args_func(func)) set_shortcut_key(trace_view.ui_expand_and_jump_to_biggest, gtk.keysyms.o) set_shortcut_key(trace_view.ui_set_min_realtime_filter, gtk.keysyms.question) set_shortcut_key(trace_view.ui_collapse, gtk.keysyms.bracketleft) set_shortcut_key(trace_view.ui_expand, gtk.keysyms.bracketright) set_shortcut_key(trace_view.ui_new_window, gtk.keysyms.n) # Create a new window window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.add_accel_group(ag) window.set_title("Trace view" + suffix) window.set_size_request(600, 400) window.connect("delete_event", self._window_closed) window.add(trace_view) window.show_all() self._window_count += 1 return window def _window_closed(self, *args): assert self._window_count >= 1 self._window_count -= 1 if self._window_count == 0: gtk.main_quit() def main(self): gtk.main() short_fmt = struct.Struct('H') def read_string(fileobj): data = fileobj.read(short_fmt.size) length, = short_fmt.unpack(data) return fileobj.read(length) def read_code_index(fileobj): code_index = {} while True: data = fileobj.read(short_fmt.size) if not data: break index, = short_fmt.unpack(data) filename = read_string(fileobj) name = read_string(fileobj) code_index[index] = filename, name return code_index def tracerview(filename): code_index = read_code_index(open(filename+'.index', "rb")) graph_reader = Reader(open(filename, "rb")) app = Application(code_index, graph_reader, graph_reader.root) app.main() def main(): filename, = sys.argv[1:] tracerview(filename) if __name__ == "__main__": main() pythontracer-8.10.16/graphfile-python/0000775000175000017500000000000011075676655017215 5ustar peakerpeakerpythontracer-8.10.16/graphfile-python/graphfile.pyx0000644000175000017500000000776311066155433021715 0ustar peakerpeakerinclude "memory.pyx" include "python.pyx" class Error(Exception): pass cdef class _Linkable: cdef graphfile_linkable_t linkable cdef class Writer: cdef graphfile_writer_t writer cdef readonly object fileobj def __cinit__(self, fileobj): if 0 != graphfile_writer_init(&self.writer, file_from_obj(fileobj)): raise Error("graphfile_writer_init") self.fileobj = fileobj def __dealloc__(self): graphfile_writer_fini(&self.writer) def set_root(self, _Linkable root): if 0 != graphfile_writer_set_root(&self.writer, &root.linkable): raise Error("graphfile_writer_set_root") def write(self, data, linkables): cdef _Linkable result_linkable cdef char *buffer cdef Py_ssize_t buffer_length cdef graphfile_linkable_t *c_linkables cdef graphfile_size_t i cdef int result PyString_AsStringAndSize(data, &buffer, &buffer_length) c_linkables = allocate(sizeof(graphfile_linkable_t) * len(linkables)) try: for i, linkable in enumerate(linkables): c_linkables[i] = (<_Linkable>linkable).linkable result_linkable = _Linkable() result = graphfile_writer_write(&self.writer, buffer, buffer_length, c_linkables, len(linkables), &result_linkable.linkable) if result != 0: raise Error("graphfile_writer_write") return result_linkable finally: free(c_linkables) cdef class Reader: cdef graphfile_reader_t reader cdef readonly _Linkable root cdef readonly object fileobj def __cinit__(self, fileobj): self.root = _Linkable() if 0 != graphfile_reader_init(&self.reader, file_from_obj(fileobj), &self.root.linkable): raise Error("graphfile_reader_init") self.fileobj = fileobj def __dealloc__(self): graphfile_reader_fini(&self.reader) def read(self, _Linkable linkable): cdef graphfile_size_t i cdef int result cdef char *result_buffer cdef graphfile_linkable_t *result_linkables cdef graphfile_size_t result_buffer_length, new_result_buffer_length cdef graphfile_size_t result_linkables_count, new_result_linkables_count result = graphfile_reader_read( &self.reader, &linkable.linkable, NULL, 0, &result_buffer_length, NULL, 0, &result_linkables_count) if result != 0: raise Error("graphfile_reader_read") result_buffer = allocate(result_buffer_length) try: result_linkables = allocate(result_linkables_count * sizeof(graphfile_linkable_t)) try: result = graphfile_reader_read( &self.reader, &linkable.linkable, result_buffer, result_buffer_length, &new_result_buffer_length, result_linkables, result_linkables_count, &new_result_linkables_count) if result != 0: raise Error("graphfile_reader_read") if (new_result_buffer_length != result_buffer_length or new_result_linkables_count != result_linkables_count): raise Error("File has changed within a single read") data = PyString_FromStringAndSize(result_buffer, result_buffer_length) linkables = [] for i from 0 <= i < result_linkables_count: # NOTE: Overriding argument linkable linkable = _Linkable() linkable.linkable = result_linkables[i] linkables.append(linkable) return data, linkables finally: free(result_linkables) finally: free(result_buffer) pythontracer-8.10.16/graphfile-python/graphfile.c0000644000175000017500000015527511075676655021337 0ustar peakerpeaker/* Generated by Pyrex 0.9.6.4 on Thu Oct 16 19:45:17 2008 */ #define PY_SSIZE_T_CLEAN #include "Python.h" #include "structmember.h" #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #if PY_VERSION_HEX < 0x02050000 typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX #define PY_SSIZE_T_MIN INT_MIN #define PyInt_FromSsize_t(z) PyInt_FromLong(z) #define PyInt_AsSsize_t(o) PyInt_AsLong(o) #endif #ifndef WIN32 #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #endif #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #include #include "graphfile.h" #include "stdlib.h" #include "string.h" #include "errno.h" #include "sys/types.h" #include "stdio.h" #include "unistd.h" typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ static PyObject *__pyx_m; static PyObject *__pyx_b; static int __pyx_lineno; static char *__pyx_filename; static char **__pyx_f; static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/ static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ static PyObject *__Pyx_UnpackItem(PyObject *); /*proto*/ static int __Pyx_EndUnpack(PyObject *); /*proto*/ static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ static int __Pyx_InternStrings(__Pyx_InternTabEntry *t); /*proto*/ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ static void __Pyx_AddTraceback(char *funcname); /*proto*/ /* Declarations from posix */ /* Declarations from graphfile */ struct __pyx_obj_9graphfile__Linkable { PyObject_HEAD graphfile_linkable_t linkable; }; struct __pyx_obj_9graphfile_Writer { PyObject_HEAD graphfile_writer_t writer; PyObject *fileobj; }; struct __pyx_obj_9graphfile_Reader { PyObject_HEAD graphfile_reader_t reader; struct __pyx_obj_9graphfile__Linkable *root; PyObject *fileobj; }; static PyTypeObject *__pyx_ptype_9graphfile__Linkable = 0; static PyTypeObject *__pyx_ptype_9graphfile_Writer = 0; static PyTypeObject *__pyx_ptype_9graphfile_Reader = 0; static void *__pyx_f_9graphfile_allocate(size_t); /*proto*/ static int __pyx_f_9graphfile_reallocate(void **,size_t); /*proto*/ static FILE *__pyx_f_9graphfile_file_from_obj(PyObject *); /*proto*/ /* Implementation of graphfile */ static PyObject *__pyx_n_Error; static PyObject *__pyx_n_Exception; static PyObject *__pyx_n_MemoryError; static void *__pyx_f_9graphfile_allocate(size_t __pyx_v_size) { void *__pyx_v_ptr; void *__pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; /* "pyrex-lib/memory.pyx":16 */ __pyx_v_ptr = malloc(__pyx_v_size); /* "pyrex-lib/memory.pyx":17 */ __pyx_1 = (__pyx_v_ptr == NULL); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_MemoryError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; goto __pyx_L1;} __Pyx_Raise(__pyx_2, 0, 0); Py_DECREF(__pyx_2); __pyx_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "pyrex-lib/memory.pyx":19 */ __pyx_r = __pyx_v_ptr; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); __Pyx_AddTraceback("graphfile.allocate"); __pyx_r = NULL; __pyx_L0:; return __pyx_r; } static int __pyx_f_9graphfile_reallocate(void **__pyx_v_ptr,size_t __pyx_v_size) { void *__pyx_v_new_ptr; int __pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; /* "pyrex-lib/memory.pyx":23 */ __pyx_1 = (__pyx_v_size == 0); if (__pyx_1) { /* "pyrex-lib/memory.pyx":24 */ free((__pyx_v_ptr[0])); /* "pyrex-lib/memory.pyx":25 */ (__pyx_v_ptr[0]) = NULL; /* "pyrex-lib/memory.pyx":26 */ __pyx_r = 0; goto __pyx_L0; goto __pyx_L2; } __pyx_L2:; /* "pyrex-lib/memory.pyx":27 */ __pyx_v_new_ptr = realloc((__pyx_v_ptr[0]),__pyx_v_size); /* "pyrex-lib/memory.pyx":28 */ __pyx_1 = (__pyx_v_new_ptr == NULL); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_MemoryError); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} __Pyx_Raise(__pyx_2, 0, 0); Py_DECREF(__pyx_2); __pyx_2 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; goto __pyx_L1;} goto __pyx_L3; } __pyx_L3:; /* "pyrex-lib/memory.pyx":30 */ (__pyx_v_ptr[0]) = __pyx_v_new_ptr; /* "pyrex-lib/memory.pyx":31 */ __pyx_r = 0; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); __Pyx_AddTraceback("graphfile.reallocate"); __pyx_r = (-1); __pyx_L0:; return __pyx_r; } static PyObject *__pyx_k2p; static char __pyx_k2[] = "Invalid fileobj"; static FILE *__pyx_f_9graphfile_file_from_obj(PyObject *__pyx_v_fileobj) { FILE *__pyx_v_file; FILE *__pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; Py_INCREF(__pyx_v_fileobj); /* "pyrex-lib/python.pyx":24 */ __pyx_v_file = PyFile_AsFile(__pyx_v_fileobj); /* "pyrex-lib/python.pyx":25 */ __pyx_1 = (NULL == __pyx_v_file); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; goto __pyx_L1;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; goto __pyx_L1;} Py_INCREF(__pyx_k2p); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k2p); __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "pyrex-lib/python.pyx":27 */ __pyx_r = __pyx_v_file; goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("graphfile.file_from_obj"); __pyx_r = NULL; __pyx_L0:; Py_DECREF(__pyx_v_fileobj); return __pyx_r; } static PyObject *__pyx_n_graphfile_writer_init; static int __pyx_f_9graphfile_6Writer___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_f_9graphfile_6Writer___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_fileobj = 0; int __pyx_r; FILE *__pyx_1; int __pyx_2; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"fileobj",0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_fileobj)) return -1; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_fileobj); /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":14 */ __pyx_1 = __pyx_f_9graphfile_file_from_obj(__pyx_v_fileobj); if (__pyx_1 == NULL) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 14; goto __pyx_L1;} __pyx_2 = (0 != graphfile_writer_init((&((struct __pyx_obj_9graphfile_Writer *)__pyx_v_self)->writer),__pyx_1)); if (__pyx_2) { __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_Error); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; goto __pyx_L1;} __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; goto __pyx_L1;} Py_INCREF(__pyx_n_graphfile_writer_init); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_graphfile_writer_init); __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); Py_DECREF(__pyx_5); __pyx_5 = 0; {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":16 */ Py_INCREF(__pyx_v_fileobj); Py_DECREF(((struct __pyx_obj_9graphfile_Writer *)__pyx_v_self)->fileobj); ((struct __pyx_obj_9graphfile_Writer *)__pyx_v_self)->fileobj = __pyx_v_fileobj; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); __Pyx_AddTraceback("graphfile.Writer.__cinit__"); __pyx_r = -1; __pyx_L0:; Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_fileobj); return __pyx_r; } static void __pyx_f_9graphfile_6Writer___dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_f_9graphfile_6Writer___dealloc__(PyObject *__pyx_v_self) { Py_INCREF(__pyx_v_self); graphfile_writer_fini((&((struct __pyx_obj_9graphfile_Writer *)__pyx_v_self)->writer)); Py_DECREF(__pyx_v_self); } static PyObject *__pyx_n_graphfile_writer_set_root; static PyObject *__pyx_f_9graphfile_6Writer_set_root(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_9graphfile_6Writer_set_root(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct __pyx_obj_9graphfile__Linkable *__pyx_v_root = 0; PyObject *__pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; static char *__pyx_argnames[] = {"root",0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_root)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_root); if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_root), __pyx_ptype_9graphfile__Linkable, 1, "root")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; goto __pyx_L1;} __pyx_1 = (0 != graphfile_writer_set_root((&((struct __pyx_obj_9graphfile_Writer *)__pyx_v_self)->writer),(&__pyx_v_root->linkable))); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 22; goto __pyx_L1;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 22; goto __pyx_L1;} Py_INCREF(__pyx_n_graphfile_writer_set_root); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_graphfile_writer_set_root); __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 22; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[2]; __pyx_lineno = 22; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("graphfile.Writer.set_root"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_root); return __pyx_r; } static PyObject *__pyx_n_enumerate; static PyObject *__pyx_n_graphfile_writer_write; static PyObject *__pyx_f_9graphfile_6Writer_write(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_9graphfile_6Writer_write(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_data = 0; PyObject *__pyx_v_linkables = 0; struct __pyx_obj_9graphfile__Linkable *__pyx_v_result_linkable; char *__pyx_v_buffer; Py_ssize_t __pyx_v_buffer_length; graphfile_linkable_t *__pyx_v_c_linkables; graphfile_size_t __pyx_v_i; int __pyx_v_result; PyObject *__pyx_v_linkable; PyObject *__pyx_r; int __pyx_1; Py_ssize_t __pyx_2; void *__pyx_3; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; PyObject *__pyx_6 = 0; graphfile_size_t __pyx_7; static char *__pyx_argnames[] = {"data","linkables",0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_data, &__pyx_v_linkables)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_data); Py_INCREF(__pyx_v_linkables); __pyx_v_result_linkable = ((struct __pyx_obj_9graphfile__Linkable *)Py_None); Py_INCREF(Py_None); __pyx_v_linkable = Py_None; Py_INCREF(Py_None); /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":32 */ __pyx_1 = PyString_AsStringAndSize(__pyx_v_data,(&__pyx_v_buffer),(&__pyx_v_buffer_length)); if (__pyx_1 == (-1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 32; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":33 */ __pyx_2 = PyObject_Length(__pyx_v_linkables); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; goto __pyx_L1;} __pyx_3 = __pyx_f_9graphfile_allocate(((sizeof(graphfile_linkable_t)) * __pyx_2)); if (__pyx_3 == NULL) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; goto __pyx_L1;} __pyx_v_c_linkables = ((graphfile_linkable_t *)__pyx_3); /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":34 */ /*try:*/ { /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":35 */ __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_enumerate); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; goto __pyx_L3;} __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; goto __pyx_L3;} Py_INCREF(__pyx_v_linkables); PyTuple_SET_ITEM(__pyx_5, 0, __pyx_v_linkables); __pyx_6 = PyObject_CallObject(__pyx_4, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; goto __pyx_L3;} Py_DECREF(__pyx_4); __pyx_4 = 0; Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_4 = PyObject_GetIter(__pyx_6); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; goto __pyx_L3;} Py_DECREF(__pyx_6); __pyx_6 = 0; for (;;) { __pyx_5 = PyIter_Next(__pyx_4); if (!__pyx_5) { if (PyErr_Occurred()) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; goto __pyx_L3;} break; } __pyx_6 = PyObject_GetIter(__pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; goto __pyx_L3;} Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_5 = __Pyx_UnpackItem(__pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; goto __pyx_L3;} __pyx_7 = PyInt_AsUnsignedLongLongMask(__pyx_5); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; goto __pyx_L3;} Py_DECREF(__pyx_5); __pyx_5 = 0; __pyx_v_i = __pyx_7; __pyx_5 = __Pyx_UnpackItem(__pyx_6); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; goto __pyx_L3;} Py_DECREF(__pyx_v_linkable); __pyx_v_linkable = __pyx_5; __pyx_5 = 0; if (__Pyx_EndUnpack(__pyx_6) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; goto __pyx_L3;} Py_DECREF(__pyx_6); __pyx_6 = 0; (__pyx_v_c_linkables[__pyx_v_i]) = ((struct __pyx_obj_9graphfile__Linkable *)__pyx_v_linkable)->linkable; } Py_DECREF(__pyx_4); __pyx_4 = 0; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":37 */ __pyx_5 = PyObject_CallObject(((PyObject*)__pyx_ptype_9graphfile__Linkable), 0); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; goto __pyx_L3;} if (!__Pyx_TypeTest(__pyx_5, __pyx_ptype_9graphfile__Linkable)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; goto __pyx_L3;} Py_DECREF(((PyObject *)__pyx_v_result_linkable)); __pyx_v_result_linkable = ((struct __pyx_obj_9graphfile__Linkable *)__pyx_5); __pyx_5 = 0; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":38 */ __pyx_2 = PyObject_Length(__pyx_v_linkables); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 39; goto __pyx_L3;} __pyx_v_result = graphfile_writer_write((&((struct __pyx_obj_9graphfile_Writer *)__pyx_v_self)->writer),__pyx_v_buffer,__pyx_v_buffer_length,__pyx_v_c_linkables,__pyx_2,(&__pyx_v_result_linkable->linkable)); /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":41 */ __pyx_1 = (__pyx_v_result != 0); if (__pyx_1) { __pyx_6 = __Pyx_GetName(__pyx_m, __pyx_n_Error); if (!__pyx_6) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; goto __pyx_L3;} __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; goto __pyx_L3;} Py_INCREF(__pyx_n_graphfile_writer_write); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_graphfile_writer_write); __pyx_5 = PyObject_CallObject(__pyx_6, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; goto __pyx_L3;} Py_DECREF(__pyx_6); __pyx_6 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); Py_DECREF(__pyx_5); __pyx_5 = 0; {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; goto __pyx_L3;} goto __pyx_L7; } __pyx_L7:; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":43 */ Py_INCREF(((PyObject *)__pyx_v_result_linkable)); __pyx_r = ((PyObject *)__pyx_v_result_linkable); goto __pyx_L2; } /*finally:*/ { int __pyx_why; PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; int __pyx_exc_lineno; __pyx_why = 0; goto __pyx_L4; __pyx_L2: __pyx_why = 3; goto __pyx_L4; __pyx_L3: { __pyx_why = 4; Py_XDECREF(__pyx_6); __pyx_6 = 0; Py_XDECREF(__pyx_4); __pyx_4 = 0; Py_XDECREF(__pyx_5); __pyx_5 = 0; PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); __pyx_exc_lineno = __pyx_lineno; goto __pyx_L4; } __pyx_L4:; free(__pyx_v_c_linkables); switch (__pyx_why) { case 3: goto __pyx_L0; case 4: { PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); __pyx_lineno = __pyx_exc_lineno; __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; goto __pyx_L1; } } } __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); Py_XDECREF(__pyx_6); __Pyx_AddTraceback("graphfile.Writer.write"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_result_linkable); Py_DECREF(__pyx_v_linkable); Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_data); Py_DECREF(__pyx_v_linkables); return __pyx_r; } static PyObject *__pyx_n_graphfile_reader_init; static int __pyx_f_9graphfile_6Reader___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_f_9graphfile_6Reader___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_fileobj = 0; int __pyx_r; PyObject *__pyx_1 = 0; FILE *__pyx_2; int __pyx_3; PyObject *__pyx_4 = 0; PyObject *__pyx_5 = 0; static char *__pyx_argnames[] = {"fileobj",0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_fileobj)) return -1; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_fileobj); /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":52 */ __pyx_1 = PyObject_CallObject(((PyObject*)__pyx_ptype_9graphfile__Linkable), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; goto __pyx_L1;} if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_9graphfile__Linkable)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; goto __pyx_L1;} Py_DECREF(((PyObject *)((struct __pyx_obj_9graphfile_Reader *)__pyx_v_self)->root)); ((struct __pyx_obj_9graphfile_Reader *)__pyx_v_self)->root = ((struct __pyx_obj_9graphfile__Linkable *)__pyx_1); __pyx_1 = 0; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":53 */ __pyx_2 = __pyx_f_9graphfile_file_from_obj(__pyx_v_fileobj); if (__pyx_2 == NULL) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; goto __pyx_L1;} __pyx_3 = (0 != graphfile_reader_init((&((struct __pyx_obj_9graphfile_Reader *)__pyx_v_self)->reader),__pyx_2,(&((struct __pyx_obj_9graphfile_Reader *)__pyx_v_self)->root->linkable))); if (__pyx_3) { __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_Error); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; goto __pyx_L1;} __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; goto __pyx_L1;} Py_INCREF(__pyx_n_graphfile_reader_init); PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n_graphfile_reader_init); __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; goto __pyx_L1;} Py_DECREF(__pyx_1); __pyx_1 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; __Pyx_Raise(__pyx_5, 0, 0); Py_DECREF(__pyx_5); __pyx_5 = 0; {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":55 */ Py_INCREF(__pyx_v_fileobj); Py_DECREF(((struct __pyx_obj_9graphfile_Reader *)__pyx_v_self)->fileobj); ((struct __pyx_obj_9graphfile_Reader *)__pyx_v_self)->fileobj = __pyx_v_fileobj; __pyx_r = 0; goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_4); Py_XDECREF(__pyx_5); __Pyx_AddTraceback("graphfile.Reader.__cinit__"); __pyx_r = -1; __pyx_L0:; Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_fileobj); return __pyx_r; } static void __pyx_f_9graphfile_6Reader___dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_f_9graphfile_6Reader___dealloc__(PyObject *__pyx_v_self) { Py_INCREF(__pyx_v_self); graphfile_reader_fini((&((struct __pyx_obj_9graphfile_Reader *)__pyx_v_self)->reader)); Py_DECREF(__pyx_v_self); } static PyObject *__pyx_n_graphfile_reader_read; static PyObject *__pyx_n_append; static PyObject *__pyx_k9p; static char __pyx_k9[] = "File has changed within a single read"; static PyObject *__pyx_f_9graphfile_6Reader_read(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyObject *__pyx_f_9graphfile_6Reader_read(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct __pyx_obj_9graphfile__Linkable *__pyx_v_linkable = 0; graphfile_size_t __pyx_v_i; int __pyx_v_result; char *__pyx_v_result_buffer; graphfile_linkable_t *__pyx_v_result_linkables; graphfile_size_t __pyx_v_result_buffer_length; graphfile_size_t __pyx_v_new_result_buffer_length; graphfile_size_t __pyx_v_result_linkables_count; graphfile_size_t __pyx_v_new_result_linkables_count; PyObject *__pyx_v_data; PyObject *__pyx_v_linkables; PyObject *__pyx_r; int __pyx_1; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; PyObject *__pyx_4 = 0; void *__pyx_5; static char *__pyx_argnames[] = {"linkable",0}; if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_linkable)) return 0; Py_INCREF(__pyx_v_self); Py_INCREF(__pyx_v_linkable); __pyx_v_data = Py_None; Py_INCREF(Py_None); __pyx_v_linkables = Py_None; Py_INCREF(Py_None); if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_linkable), __pyx_ptype_9graphfile__Linkable, 1, "linkable")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; goto __pyx_L1;} /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":67 */ __pyx_v_result = graphfile_reader_read((&((struct __pyx_obj_9graphfile_Reader *)__pyx_v_self)->reader),(&__pyx_v_linkable->linkable),NULL,0,(&__pyx_v_result_buffer_length),NULL,0,(&__pyx_v_result_linkables_count)); /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":76 */ __pyx_1 = (__pyx_v_result != 0); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; goto __pyx_L1;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; goto __pyx_L1;} Py_INCREF(__pyx_n_graphfile_reader_read); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_graphfile_reader_read); __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; goto __pyx_L1;} goto __pyx_L2; } __pyx_L2:; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":79 */ __pyx_5 = __pyx_f_9graphfile_allocate(__pyx_v_result_buffer_length); if (__pyx_5 == NULL) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 79; goto __pyx_L1;} __pyx_v_result_buffer = ((char *)__pyx_5); /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":80 */ /*try:*/ { /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":81 */ __pyx_5 = __pyx_f_9graphfile_allocate((__pyx_v_result_linkables_count * (sizeof(graphfile_linkable_t)))); if (__pyx_5 == NULL) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; goto __pyx_L4;} __pyx_v_result_linkables = ((graphfile_linkable_t *)__pyx_5); /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":82 */ /*try:*/ { /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":83 */ __pyx_v_result = graphfile_reader_read((&((struct __pyx_obj_9graphfile_Reader *)__pyx_v_self)->reader),(&__pyx_v_linkable->linkable),__pyx_v_result_buffer,__pyx_v_result_buffer_length,(&__pyx_v_new_result_buffer_length),__pyx_v_result_linkables,__pyx_v_result_linkables_count,(&__pyx_v_new_result_linkables_count)); /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":92 */ __pyx_1 = (__pyx_v_result != 0); if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; goto __pyx_L7;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; goto __pyx_L7;} Py_INCREF(__pyx_n_graphfile_reader_read); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n_graphfile_reader_read); __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; goto __pyx_L7;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; goto __pyx_L7;} goto __pyx_L9; } __pyx_L9:; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":94 */ __pyx_1 = (__pyx_v_new_result_buffer_length != __pyx_v_result_buffer_length); if (!__pyx_1) { __pyx_1 = (__pyx_v_new_result_linkables_count != __pyx_v_result_linkables_count); } if (__pyx_1) { __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_Error); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 96; goto __pyx_L7;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 96; goto __pyx_L7;} Py_INCREF(__pyx_k9p); PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k9p); __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 96; goto __pyx_L7;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; __Pyx_Raise(__pyx_4, 0, 0); Py_DECREF(__pyx_4); __pyx_4 = 0; {__pyx_filename = __pyx_f[2]; __pyx_lineno = 96; goto __pyx_L7;} goto __pyx_L10; } __pyx_L10:; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":97 */ __pyx_2 = PyString_FromStringAndSize(__pyx_v_result_buffer,__pyx_v_result_buffer_length); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 97; goto __pyx_L7;} Py_DECREF(__pyx_v_data); __pyx_v_data = __pyx_2; __pyx_2 = 0; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":98 */ __pyx_3 = PyList_New(0); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 98; goto __pyx_L7;} Py_DECREF(__pyx_v_linkables); __pyx_v_linkables = __pyx_3; __pyx_3 = 0; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":99 */ for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_result_linkables_count; ++__pyx_v_i) { /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":101 */ __pyx_4 = PyObject_CallObject(((PyObject*)__pyx_ptype_9graphfile__Linkable), 0); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 101; goto __pyx_L7;} if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_9graphfile__Linkable)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 101; goto __pyx_L7;} Py_DECREF(((PyObject *)__pyx_v_linkable)); __pyx_v_linkable = ((struct __pyx_obj_9graphfile__Linkable *)__pyx_4); __pyx_4 = 0; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":102 */ __pyx_v_linkable->linkable = (__pyx_v_result_linkables[__pyx_v_i]); /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":103 */ __pyx_2 = PyObject_GetAttr(__pyx_v_linkables, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; goto __pyx_L7;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; goto __pyx_L7;} Py_INCREF(((PyObject *)__pyx_v_linkable)); PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_linkable)); __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; goto __pyx_L7;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_3); __pyx_3 = 0; Py_DECREF(__pyx_4); __pyx_4 = 0; } /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":104 */ __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 104; goto __pyx_L7;} Py_INCREF(__pyx_v_data); PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_data); Py_INCREF(__pyx_v_linkables); PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_linkables); __pyx_r = __pyx_2; __pyx_2 = 0; goto __pyx_L6; } /*finally:*/ { int __pyx_why; PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; int __pyx_exc_lineno; __pyx_why = 0; goto __pyx_L8; __pyx_L6: __pyx_why = 3; goto __pyx_L8; __pyx_L7: { __pyx_why = 4; Py_XDECREF(__pyx_3); __pyx_3 = 0; Py_XDECREF(__pyx_4); __pyx_4 = 0; Py_XDECREF(__pyx_2); __pyx_2 = 0; PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); __pyx_exc_lineno = __pyx_lineno; goto __pyx_L8; } __pyx_L8:; free(__pyx_v_result_linkables); switch (__pyx_why) { case 3: goto __pyx_L3; case 4: { PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); __pyx_lineno = __pyx_exc_lineno; __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; goto __pyx_L4; } } } } /*finally:*/ { int __pyx_why; PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; int __pyx_exc_lineno; __pyx_why = 0; goto __pyx_L5; __pyx_L3: __pyx_why = 3; goto __pyx_L5; __pyx_L4: { __pyx_why = 4; Py_XDECREF(__pyx_3); __pyx_3 = 0; Py_XDECREF(__pyx_4); __pyx_4 = 0; Py_XDECREF(__pyx_2); __pyx_2 = 0; PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); __pyx_exc_lineno = __pyx_lineno; goto __pyx_L5; } __pyx_L5:; free(__pyx_v_result_buffer); switch (__pyx_why) { case 3: goto __pyx_L0; case 4: { PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); __pyx_lineno = __pyx_exc_lineno; __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; goto __pyx_L1; } } } __pyx_r = Py_None; Py_INCREF(Py_None); goto __pyx_L0; __pyx_L1:; Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); Py_XDECREF(__pyx_4); __Pyx_AddTraceback("graphfile.Reader.read"); __pyx_r = 0; __pyx_L0:; Py_DECREF(__pyx_v_data); Py_DECREF(__pyx_v_linkables); Py_DECREF(__pyx_v_self); Py_DECREF(__pyx_v_linkable); return __pyx_r; } static __Pyx_InternTabEntry __pyx_intern_tab[] = { {&__pyx_n_Error, "Error"}, {&__pyx_n_Exception, "Exception"}, {&__pyx_n_MemoryError, "MemoryError"}, {&__pyx_n_append, "append"}, {&__pyx_n_enumerate, "enumerate"}, {&__pyx_n_graphfile_reader_init, "graphfile_reader_init"}, {&__pyx_n_graphfile_reader_read, "graphfile_reader_read"}, {&__pyx_n_graphfile_writer_init, "graphfile_writer_init"}, {&__pyx_n_graphfile_writer_set_root, "graphfile_writer_set_root"}, {&__pyx_n_graphfile_writer_write, "graphfile_writer_write"}, {0, 0} }; static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_k2p, __pyx_k2, sizeof(__pyx_k2)}, {&__pyx_k9p, __pyx_k9, sizeof(__pyx_k9)}, {0, 0, 0} }; static PyObject *__pyx_tp_new_9graphfile__Linkable(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; return o; } static void __pyx_tp_dealloc_9graphfile__Linkable(PyObject *o) { (*o->ob_type->tp_free)(o); } static int __pyx_tp_traverse_9graphfile__Linkable(PyObject *o, visitproc v, void *a) { return 0; } static int __pyx_tp_clear_9graphfile__Linkable(PyObject *o) { return 0; } static struct PyMethodDef __pyx_methods_9graphfile__Linkable[] = { {0, 0, 0, 0} }; static PyNumberMethods __pyx_tp_as_number__Linkable = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ 0, /*nb_divide*/ 0, /*nb_remainder*/ 0, /*nb_divmod*/ 0, /*nb_power*/ 0, /*nb_negative*/ 0, /*nb_positive*/ 0, /*nb_absolute*/ 0, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ 0, /*nb_coerce*/ 0, /*nb_int*/ 0, /*nb_long*/ 0, /*nb_float*/ 0, /*nb_oct*/ 0, /*nb_hex*/ 0, /*nb_inplace_add*/ 0, /*nb_inplace_subtract*/ 0, /*nb_inplace_multiply*/ 0, /*nb_inplace_divide*/ 0, /*nb_inplace_remainder*/ 0, /*nb_inplace_power*/ 0, /*nb_inplace_lshift*/ 0, /*nb_inplace_rshift*/ 0, /*nb_inplace_and*/ 0, /*nb_inplace_xor*/ 0, /*nb_inplace_or*/ 0, /*nb_floor_divide*/ 0, /*nb_true_divide*/ 0, /*nb_inplace_floor_divide*/ 0, /*nb_inplace_true_divide*/ #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX 0, /*nb_index*/ #endif }; static PySequenceMethods __pyx_tp_as_sequence__Linkable = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ 0, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ 0, /*sq_contains*/ 0, /*sq_inplace_concat*/ 0, /*sq_inplace_repeat*/ }; static PyMappingMethods __pyx_tp_as_mapping__Linkable = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; static PyBufferProcs __pyx_tp_as_buffer__Linkable = { 0, /*bf_getreadbuffer*/ 0, /*bf_getwritebuffer*/ 0, /*bf_getsegcount*/ 0, /*bf_getcharbuffer*/ }; PyTypeObject __pyx_type_9graphfile__Linkable = { PyObject_HEAD_INIT(0) 0, /*ob_size*/ "graphfile._Linkable", /*tp_name*/ sizeof(struct __pyx_obj_9graphfile__Linkable), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_9graphfile__Linkable, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ &__pyx_tp_as_number__Linkable, /*tp_as_number*/ &__pyx_tp_as_sequence__Linkable, /*tp_as_sequence*/ &__pyx_tp_as_mapping__Linkable, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer__Linkable, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_9graphfile__Linkable, /*tp_traverse*/ __pyx_tp_clear_9graphfile__Linkable, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_9graphfile__Linkable, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_9graphfile__Linkable, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ }; static PyObject *__pyx_tp_new_9graphfile_Writer(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_9graphfile_Writer *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; p = ((struct __pyx_obj_9graphfile_Writer *)o); p->fileobj = Py_None; Py_INCREF(Py_None); if (__pyx_f_9graphfile_6Writer___cinit__(o, a, k) < 0) { Py_DECREF(o); o = 0; } return o; } static void __pyx_tp_dealloc_9graphfile_Writer(PyObject *o) { struct __pyx_obj_9graphfile_Writer *p = (struct __pyx_obj_9graphfile_Writer *)o; { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++o->ob_refcnt; __pyx_f_9graphfile_6Writer___dealloc__(o); if (PyErr_Occurred()) PyErr_WriteUnraisable(o); --o->ob_refcnt; PyErr_Restore(etype, eval, etb); } Py_XDECREF(p->fileobj); (*o->ob_type->tp_free)(o); } static int __pyx_tp_traverse_9graphfile_Writer(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_9graphfile_Writer *p = (struct __pyx_obj_9graphfile_Writer *)o; if (p->fileobj) { e = (*v)(p->fileobj, a); if (e) return e; } return 0; } static int __pyx_tp_clear_9graphfile_Writer(PyObject *o) { struct __pyx_obj_9graphfile_Writer *p = (struct __pyx_obj_9graphfile_Writer *)o; Py_XDECREF(p->fileobj); p->fileobj = Py_None; Py_INCREF(Py_None); return 0; } static struct PyMethodDef __pyx_methods_9graphfile_Writer[] = { {"set_root", (PyCFunction)__pyx_f_9graphfile_6Writer_set_root, METH_VARARGS|METH_KEYWORDS, 0}, {"write", (PyCFunction)__pyx_f_9graphfile_6Writer_write, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static struct PyMemberDef __pyx_members_9graphfile_Writer[] = { {"fileobj", T_OBJECT, offsetof(struct __pyx_obj_9graphfile_Writer, fileobj), READONLY, 0}, {0, 0, 0, 0, 0} }; static PyNumberMethods __pyx_tp_as_number_Writer = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ 0, /*nb_divide*/ 0, /*nb_remainder*/ 0, /*nb_divmod*/ 0, /*nb_power*/ 0, /*nb_negative*/ 0, /*nb_positive*/ 0, /*nb_absolute*/ 0, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ 0, /*nb_coerce*/ 0, /*nb_int*/ 0, /*nb_long*/ 0, /*nb_float*/ 0, /*nb_oct*/ 0, /*nb_hex*/ 0, /*nb_inplace_add*/ 0, /*nb_inplace_subtract*/ 0, /*nb_inplace_multiply*/ 0, /*nb_inplace_divide*/ 0, /*nb_inplace_remainder*/ 0, /*nb_inplace_power*/ 0, /*nb_inplace_lshift*/ 0, /*nb_inplace_rshift*/ 0, /*nb_inplace_and*/ 0, /*nb_inplace_xor*/ 0, /*nb_inplace_or*/ 0, /*nb_floor_divide*/ 0, /*nb_true_divide*/ 0, /*nb_inplace_floor_divide*/ 0, /*nb_inplace_true_divide*/ #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX 0, /*nb_index*/ #endif }; static PySequenceMethods __pyx_tp_as_sequence_Writer = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ 0, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ 0, /*sq_contains*/ 0, /*sq_inplace_concat*/ 0, /*sq_inplace_repeat*/ }; static PyMappingMethods __pyx_tp_as_mapping_Writer = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; static PyBufferProcs __pyx_tp_as_buffer_Writer = { 0, /*bf_getreadbuffer*/ 0, /*bf_getwritebuffer*/ 0, /*bf_getsegcount*/ 0, /*bf_getcharbuffer*/ }; PyTypeObject __pyx_type_9graphfile_Writer = { PyObject_HEAD_INIT(0) 0, /*ob_size*/ "graphfile.Writer", /*tp_name*/ sizeof(struct __pyx_obj_9graphfile_Writer), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_9graphfile_Writer, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ &__pyx_tp_as_number_Writer, /*tp_as_number*/ &__pyx_tp_as_sequence_Writer, /*tp_as_sequence*/ &__pyx_tp_as_mapping_Writer, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_Writer, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_9graphfile_Writer, /*tp_traverse*/ __pyx_tp_clear_9graphfile_Writer, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_9graphfile_Writer, /*tp_methods*/ __pyx_members_9graphfile_Writer, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_9graphfile_Writer, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ }; static PyObject *__pyx_tp_new_9graphfile_Reader(PyTypeObject *t, PyObject *a, PyObject *k) { struct __pyx_obj_9graphfile_Reader *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; p = ((struct __pyx_obj_9graphfile_Reader *)o); p->root = ((struct __pyx_obj_9graphfile__Linkable *)Py_None); Py_INCREF(Py_None); p->fileobj = Py_None; Py_INCREF(Py_None); if (__pyx_f_9graphfile_6Reader___cinit__(o, a, k) < 0) { Py_DECREF(o); o = 0; } return o; } static void __pyx_tp_dealloc_9graphfile_Reader(PyObject *o) { struct __pyx_obj_9graphfile_Reader *p = (struct __pyx_obj_9graphfile_Reader *)o; { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++o->ob_refcnt; __pyx_f_9graphfile_6Reader___dealloc__(o); if (PyErr_Occurred()) PyErr_WriteUnraisable(o); --o->ob_refcnt; PyErr_Restore(etype, eval, etb); } Py_XDECREF(((PyObject *)p->root)); Py_XDECREF(p->fileobj); (*o->ob_type->tp_free)(o); } static int __pyx_tp_traverse_9graphfile_Reader(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_9graphfile_Reader *p = (struct __pyx_obj_9graphfile_Reader *)o; if (p->root) { e = (*v)(((PyObject*)p->root), a); if (e) return e; } if (p->fileobj) { e = (*v)(p->fileobj, a); if (e) return e; } return 0; } static int __pyx_tp_clear_9graphfile_Reader(PyObject *o) { struct __pyx_obj_9graphfile_Reader *p = (struct __pyx_obj_9graphfile_Reader *)o; Py_XDECREF(((PyObject *)p->root)); p->root = ((struct __pyx_obj_9graphfile__Linkable *)Py_None); Py_INCREF(Py_None); Py_XDECREF(p->fileobj); p->fileobj = Py_None; Py_INCREF(Py_None); return 0; } static struct PyMethodDef __pyx_methods_9graphfile_Reader[] = { {"read", (PyCFunction)__pyx_f_9graphfile_6Reader_read, METH_VARARGS|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; static struct PyMemberDef __pyx_members_9graphfile_Reader[] = { {"root", T_OBJECT, offsetof(struct __pyx_obj_9graphfile_Reader, root), READONLY, 0}, {"fileobj", T_OBJECT, offsetof(struct __pyx_obj_9graphfile_Reader, fileobj), READONLY, 0}, {0, 0, 0, 0, 0} }; static PyNumberMethods __pyx_tp_as_number_Reader = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ 0, /*nb_divide*/ 0, /*nb_remainder*/ 0, /*nb_divmod*/ 0, /*nb_power*/ 0, /*nb_negative*/ 0, /*nb_positive*/ 0, /*nb_absolute*/ 0, /*nb_nonzero*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ 0, /*nb_coerce*/ 0, /*nb_int*/ 0, /*nb_long*/ 0, /*nb_float*/ 0, /*nb_oct*/ 0, /*nb_hex*/ 0, /*nb_inplace_add*/ 0, /*nb_inplace_subtract*/ 0, /*nb_inplace_multiply*/ 0, /*nb_inplace_divide*/ 0, /*nb_inplace_remainder*/ 0, /*nb_inplace_power*/ 0, /*nb_inplace_lshift*/ 0, /*nb_inplace_rshift*/ 0, /*nb_inplace_and*/ 0, /*nb_inplace_xor*/ 0, /*nb_inplace_or*/ 0, /*nb_floor_divide*/ 0, /*nb_true_divide*/ 0, /*nb_inplace_floor_divide*/ 0, /*nb_inplace_true_divide*/ #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX 0, /*nb_index*/ #endif }; static PySequenceMethods __pyx_tp_as_sequence_Reader = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ 0, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ 0, /*sq_contains*/ 0, /*sq_inplace_concat*/ 0, /*sq_inplace_repeat*/ }; static PyMappingMethods __pyx_tp_as_mapping_Reader = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; static PyBufferProcs __pyx_tp_as_buffer_Reader = { 0, /*bf_getreadbuffer*/ 0, /*bf_getwritebuffer*/ 0, /*bf_getsegcount*/ 0, /*bf_getcharbuffer*/ }; PyTypeObject __pyx_type_9graphfile_Reader = { PyObject_HEAD_INIT(0) 0, /*ob_size*/ "graphfile.Reader", /*tp_name*/ sizeof(struct __pyx_obj_9graphfile_Reader), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_9graphfile_Reader, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ &__pyx_tp_as_number_Reader, /*tp_as_number*/ &__pyx_tp_as_sequence_Reader, /*tp_as_sequence*/ &__pyx_tp_as_mapping_Reader, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_Reader, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_9graphfile_Reader, /*tp_traverse*/ __pyx_tp_clear_9graphfile_Reader, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_9graphfile_Reader, /*tp_methods*/ __pyx_members_9graphfile_Reader, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_9graphfile_Reader, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ }; static struct PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; static void __pyx_init_filenames(void); /*proto*/ PyMODINIT_FUNC initgraphfile(void); /*proto*/ PyMODINIT_FUNC initgraphfile(void) { PyObject *__pyx_1 = 0; PyObject *__pyx_2 = 0; PyObject *__pyx_3 = 0; __pyx_init_filenames(); __pyx_m = Py_InitModule4("graphfile", __pyx_methods, 0, 0, PYTHON_API_VERSION); if (!__pyx_m) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; goto __pyx_L1;}; Py_INCREF(__pyx_m); __pyx_b = PyImport_AddModule("__builtin__"); if (!__pyx_b) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; goto __pyx_L1;}; if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; goto __pyx_L1;}; if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; goto __pyx_L1;}; if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; goto __pyx_L1;}; if (PyType_Ready(&__pyx_type_9graphfile__Linkable) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; goto __pyx_L1;} if (PyObject_SetAttrString(__pyx_m, "_Linkable", (PyObject *)&__pyx_type_9graphfile__Linkable) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; goto __pyx_L1;} __pyx_ptype_9graphfile__Linkable = &__pyx_type_9graphfile__Linkable; __pyx_type_9graphfile_Writer.tp_free = _PyObject_GC_Del; if (PyType_Ready(&__pyx_type_9graphfile_Writer) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; goto __pyx_L1;} if (PyObject_SetAttrString(__pyx_m, "Writer", (PyObject *)&__pyx_type_9graphfile_Writer) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; goto __pyx_L1;} __pyx_ptype_9graphfile_Writer = &__pyx_type_9graphfile_Writer; __pyx_type_9graphfile_Reader.tp_free = _PyObject_GC_Del; if (PyType_Ready(&__pyx_type_9graphfile_Reader) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; goto __pyx_L1;} if (PyObject_SetAttrString(__pyx_m, "Reader", (PyObject *)&__pyx_type_9graphfile_Reader) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; goto __pyx_L1;} __pyx_ptype_9graphfile_Reader = &__pyx_type_9graphfile_Reader; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":4 */ __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; goto __pyx_L1;} __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_Exception); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; goto __pyx_L1;} __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; goto __pyx_L1;} PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); __pyx_2 = 0; __pyx_2 = __Pyx_CreateClass(__pyx_3, __pyx_1, __pyx_n_Error, "graphfile"); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; goto __pyx_L1;} Py_DECREF(__pyx_3); __pyx_3 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_Error, __pyx_2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 4; goto __pyx_L1;} Py_DECREF(__pyx_2); __pyx_2 = 0; Py_DECREF(__pyx_1); __pyx_1 = 0; /* "/home/peaker/devel/pythontracer/main/graphfile-python/graphfile.pyx":58 */ return; __pyx_L1:; Py_XDECREF(__pyx_1); Py_XDECREF(__pyx_2); Py_XDECREF(__pyx_3); __Pyx_AddTraceback("graphfile"); } static char *__pyx_filenames[] = { "memory.pyx", "python.pyx", "graphfile.pyx", }; /* Runtime support code */ static void __pyx_init_filenames(void) { __pyx_f = __pyx_filenames; } static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name) { if (!type) { PyErr_Format(PyExc_SystemError, "Missing type object"); return 0; } if ((none_allowed && obj == Py_None) || PyObject_TypeCheck(obj, type)) return 1; PyErr_Format(PyExc_TypeError, "Argument '%s' has incorrect type (expected %s, got %s)", name, type->tp_name, obj->ob_type->tp_name); return 0; } static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { PyObject *result; result = PyObject_GetAttr(dict, name); if (!result) PyErr_SetObject(PyExc_NameError, name); return result; } static PyObject *__Pyx_CreateClass( PyObject *bases, PyObject *dict, PyObject *name, char *modname) { PyObject *py_modname; PyObject *result = 0; py_modname = PyString_FromString(modname); if (!py_modname) goto bad; if (PyDict_SetItemString(dict, "__module__", py_modname) < 0) goto bad; result = PyClass_New(bases, dict, name); bad: Py_XDECREF(py_modname); return result; } static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { Py_XINCREF(type); Py_XINCREF(value); Py_XINCREF(tb); /* First, check the traceback argument, replacing None with NULL. */ if (tb == Py_None) { Py_DECREF(tb); tb = 0; } else if (tb != NULL && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } /* Next, replace a missing value with None */ if (value == NULL) { value = Py_None; Py_INCREF(value); } #if PY_VERSION_HEX < 0x02050000 if (!PyClass_Check(type)) #else if (!PyType_Check(type)) #endif { /* Raising an instance. The value should be a dummy. */ if (value != Py_None) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } /* Normalize to raise , */ Py_DECREF(value); value = type; #if PY_VERSION_HEX < 0x02050000 if (PyInstance_Check(type)) { type = (PyObject*) ((PyInstanceObject*)type)->in_class; Py_INCREF(type); } else { PyErr_SetString(PyExc_TypeError, "raise: exception must be an old-style class or instance"); goto raise_error; } #else type = (PyObject*) type->ob_type; Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } #endif } PyErr_Restore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } static void __Pyx_UnpackError(void) { PyErr_SetString(PyExc_ValueError, "unpack sequence of wrong size"); } static PyObject *__Pyx_UnpackItem(PyObject *iter) { PyObject *item; if (!(item = PyIter_Next(iter))) { if (!PyErr_Occurred()) __Pyx_UnpackError(); } return item; } static int __Pyx_EndUnpack(PyObject *iter) { PyObject *item; if ((item = PyIter_Next(iter))) { Py_DECREF(item); __Pyx_UnpackError(); return -1; } else if (!PyErr_Occurred()) return 0; else return -1; } static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { if (!type) { PyErr_Format(PyExc_SystemError, "Missing type object"); return 0; } if (obj == Py_None || PyObject_TypeCheck(obj, type)) return 1; PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s", obj->ob_type->tp_name, type->tp_name); return 0; } static int __Pyx_InternStrings(__Pyx_InternTabEntry *t) { while (t->p) { *t->p = PyString_InternFromString(t->s); if (!*t->p) return -1; ++t; } return 0; } static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); if (!*t->p) return -1; ++t; } return 0; } #include "compile.h" #include "frameobject.h" #include "traceback.h" static void __Pyx_AddTraceback(char *funcname) { PyObject *py_srcfile = 0; PyObject *py_funcname = 0; PyObject *py_globals = 0; PyObject *empty_tuple = 0; PyObject *empty_string = 0; PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; py_srcfile = PyString_FromString(__pyx_filename); if (!py_srcfile) goto bad; py_funcname = PyString_FromString(funcname); if (!py_funcname) goto bad; py_globals = PyModule_GetDict(__pyx_m); if (!py_globals) goto bad; empty_tuple = PyTuple_New(0); if (!empty_tuple) goto bad; empty_string = PyString_FromString(""); if (!empty_string) goto bad; py_code = PyCode_New( 0, /*int argcount,*/ 0, /*int nlocals,*/ 0, /*int stacksize,*/ 0, /*int flags,*/ empty_string, /*PyObject *code,*/ empty_tuple, /*PyObject *consts,*/ empty_tuple, /*PyObject *names,*/ empty_tuple, /*PyObject *varnames,*/ empty_tuple, /*PyObject *freevars,*/ empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ __pyx_lineno, /*int firstlineno,*/ empty_string /*PyObject *lnotab*/ ); if (!py_code) goto bad; py_frame = PyFrame_New( PyThreadState_Get(), /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ py_globals, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; py_frame->f_lineno = __pyx_lineno; PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_srcfile); Py_XDECREF(py_funcname); Py_XDECREF(empty_tuple); Py_XDECREF(empty_string); Py_XDECREF(py_code); Py_XDECREF(py_frame); } pythontracer-8.10.16/graphfile-python/graphfile.pxd0000664000175000017500000000263211064542361021656 0ustar peakerpeakerfrom posix cimport FILE cdef extern from "graphfile.h": ctypedef unsigned long long graphfile_size_t ctypedef struct graphfile_writer_t: pass ctypedef struct graphfile_reader_t: pass ctypedef struct graphfile_linkable_t: pass int graphfile_writer_init(graphfile_writer_t *, FILE *file) int graphfile_writer_set_root(graphfile_writer_t *, graphfile_linkable_t *root) void graphfile_writer_fini(graphfile_writer_t *) int graphfile_writer_write(graphfile_writer_t *, char *buffer, graphfile_size_t buffer_length, graphfile_linkable_t linkables[], graphfile_size_t linkable_count, graphfile_linkable_t *result_linkable) int graphfile_reader_init(graphfile_reader_t *, FILE *file, graphfile_linkable_t *result_root) void graphfile_reader_fini(graphfile_reader_t *) int graphfile_reader_read(graphfile_reader_t *, graphfile_linkable_t *node, char *result_buffer, graphfile_size_t max_buffer_length, graphfile_size_t *result_buffer_length, graphfile_linkable_t result_linkables[], graphfile_size_t max_linkable_count, graphfile_size_t *result_linkables_count) pythontracer-8.10.16/graphfile-python/setup.py0000664000175000017500000000107111066155433020710 0ustar peakerpeakerfrom distutils.core import setup from distutils.extension import Extension try: from Pyrex.Distutils import build_ext except ImportError: cmdclass = dict() def fixpyx(x): return x.replace('.pyx', '.c') else: cmdclass = dict(build_ext=build_ext) def fixpyx(x): return x setup(name = "graphfile-python", version = "1.4", ext_modules = [ Extension("graphfile", ["../graphfile/graphfile.c", fixpyx("graphfile.pyx")], include_dirs=["../graphfile", "../pyrex-lib"]), ], cmdclass = cmdclass) pythontracer-8.10.16/gpl-3.0.txt0000644000175000017500000010451311071710064015533 0ustar peakerpeaker GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . pythontracer-8.10.16/setup.py0000644000175000017500000000171011075705304015424 0ustar peakerpeakerfrom distutils.core import setup from distutils.extension import Extension VERSION = "8.10.16" try: from Pyrex.Distutils import build_ext except ImportError: cmdclass = dict() def fixpyx(x): return x.replace('.pyx', '.c') else: cmdclass = dict(build_ext=build_ext) def fixpyx(x): return x def make_extension(name, filenames): return Extension(name, ["graphfile/graphfile.c"] + map(fixpyx, filenames), include_dirs=["graphfile", "graphfile-python", "pyrex-lib"], define_macros=[("PYREX_WITHOUT_ASSERTIONS", "")]) setup(name = "pythontracer", version = VERSION, ext_modules = [ make_extension("graphfile", ["graphfile-python/graphfile.pyx"]), make_extension("pytracer", ["tracer/pytracer.pyx", "tracer/rotatingtree.c"], ), ], py_modules = ["pytracerview"], scripts = ["tracer/pytracefile.py"], cmdclass = cmdclass) pythontracer-8.10.16/pyrex-lib/0000775000175000017500000000000011075675307015641 5ustar peakerpeakerpythontracer-8.10.16/pyrex-lib/python.pyx0000664000175000017500000000150711066155433017720 0ustar peakerpeakerfrom posix cimport FILE cdef extern from "Python.h": object PyString_FromStringAndSize(char *, Py_ssize_t) int PyString_AsStringAndSize(object, char **s, Py_ssize_t *len) except -1 enum PyTraceEvent: PyTrace_CALL PyTrace_EXCEPTION PyTrace_LINE PyTrace_RETURN PyTrace_C_CALL PyTrace_C_EXCEPTION PyTrace_C_RETURN FILE *PyFile_AsFile(fileobj) ctypedef void *Py_tracefunc void PyEval_SetProfile(Py_tracefunc func, object arg) # PyEval_SetTrace is the same as PyEval_SetProfile, except it also # gets line number events void PyEval_SetTrace(Py_tracefunc func, object arg) cdef FILE *file_from_obj(fileobj) except NULL: cdef FILE *file file = PyFile_AsFile(fileobj) if NULL == file: raise Error("Invalid fileobj") return file pythontracer-8.10.16/pyrex-lib/files.pyx0000664000175000017500000000107311066155433017477 0ustar peakerpeakercimport posix cdef int safe_fflush(FILE *stream) except -1: if -1 == posix.fflush(stream): raise OSError(posix.errno, "fflush") return 0 cdef size_t safe_fread(void *ptr, size_t size, FILE *stream) except -1: cdef int rc rc = posix.fread(ptr, 1, size, stream) if rc == -1: raise OSError(posix.errno, "fread") return rc cdef size_t safe_fwrite(void *ptr, size_t size, FILE *stream) except -1: cdef int rc rc = posix.fwrite(ptr, 1, size, stream) if rc == -1: raise OSError(posix.errno, "fwrite") return rc pythontracer-8.10.16/pyrex-lib/memory.pyx0000664000175000017500000000143311066155433017705 0ustar peakerpeakerfrom posix cimport size_t cdef extern from "stdlib.h": void *malloc(size_t size) void *realloc(void *ptr, size_t size) void free(void *ptr) cdef extern from "string.h": void *memcpy(void *dest, void *src, size_t n) void *memset(void *s, int c, size_t n) char *strcpy(char *dest, char *src) char *strncpy(char *dest, char *src, size_t n) cdef void *allocate(size_t size) except NULL: cdef void *ptr ptr = malloc(size) if ptr == NULL: raise MemoryError return ptr cdef int reallocate(void **ptr, size_t size) except -1: cdef void *new_ptr if size == 0: free(ptr[0]) ptr[0] = NULL return 0 new_ptr = realloc(ptr[0], size) if new_ptr == NULL: raise MemoryError ptr[0] = new_ptr return 0 pythontracer-8.10.16/pyrex-lib/times.pyx0000664000175000017500000000243611075675307017531 0ustar peakerpeakerfrom posix cimport errno cdef extern from "sys/time.h": ctypedef long time_t ctypedef long suseconds_t struct timeval: time_t tv_sec suseconds_t tv_usec struct timezone: int tz_minuteswest int tz_dsttime cdef extern from "time.h": int gettimeofday(timeval *tv, timezone *tz) cdef extern from "sys/resource.h": struct rusage: timeval ru_utime timeval ru_stime int RUSAGE_SELF int getrusage(int who, rusage *usage) cdef extern from "sys/param.h": int HZ cdef double double_of_tv(timeval *tv): return (1000000 * tv.tv_sec) + tv.tv_usec cdef int get_user_sys_times(double *user_time, double *sys_time) except -1: cdef int getrusage_return cdef rusage getrusage_result # Get user/sys times errno = 0 getrusage_return = getrusage(RUSAGE_SELF, &getrusage_result) if getrusage_return == -1: raise OSError(errno, "getrusage") user_time[0] = double_of_tv(&getrusage_result.ru_utime) sys_time[0] = double_of_tv(&getrusage_result.ru_stime) return 0 cdef int get_real_time(double *real_time) except -1: cdef timeval tv # Get real time if 0 != gettimeofday(&tv, NULL): raise Error("gettimeofday") real_time[0] = double_of_tv(&tv) return 0 pythontracer-8.10.16/pyrex-lib/rotatingtree.pxd0000664000175000017500000000077011066666614021072 0ustar peakerpeakercdef extern from "rotatingtree.h": ctypedef struct rotating_node_t: void *key rotating_node_t *left rotating_node_t *right rotating_node_t *EMPTY_ROTATING_TREE ctypedef int (*rotating_tree_enum_fn)(rotating_node_t *node, void *arg) void RotatingTree_Add(rotating_node_t **root, rotating_node_t *node) rotating_node_t* RotatingTree_Get(rotating_node_t **root, void *key) int RotatingTree_Enum(rotating_node_t *root, rotating_tree_enum_fn enumfn, void *arg) pythontracer-8.10.16/pyrex-lib/posix.pxd0000664000175000017500000000062311066155433017512 0ustar peakerpeakercdef extern from "errno.h": int errno cdef extern from "sys/types.h": ctypedef unsigned long size_t ctypedef int pid_t cdef extern from "stdio.h": ctypedef struct FILE int fflush(FILE *stream) size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) size_t fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream) cdef extern from "unistd.h": pid_t getpid() pythontracer-8.10.16/pyrex-lib/darray.pyx0000664000175000017500000000361111066155433017657 0ustar peakerpeakerfrom posix cimport size_t ctypedef struct darray: void *array size_t item_size unsigned int used_count unsigned int allocated_count cdef int darray_init(darray *darray, size_t item_size) except -1: darray.array = NULL darray.item_size = item_size darray.used_count = 0 darray.allocated_count = 8 reallocate(&darray.array, darray.allocated_count * darray.item_size) return 0 cdef void *darray_add(darray *darray) except NULL: cdef void *result cdef unsigned int new_used_count, new_allocated_count new_used_count = darray.used_count + 1 if new_used_count > darray.allocated_count: new_allocated_count = max(1, darray.allocated_count) * 2 assert new_allocated_count >= new_used_count reallocate(&darray.array, new_allocated_count * darray.item_size) darray.allocated_count = new_allocated_count result = &(darray.array)[darray.used_count * darray.item_size] darray.used_count = new_used_count return result cdef void *darray_last(darray *darray) except NULL: return &(darray.array)[(darray.used_count - 1) * darray.item_size] cdef void darray_fini(darray *darray): free(darray.array) darray.array = NULL darray.used_count = -1 # Keep the item_size for debuggability cdef int darray_fast_remove_last(darray *darray) except -1: cdef unsigned int new_used_count, new_allocated_count assert darray.used_count > 0 new_used_count = darray.used_count - 1 darray.used_count = new_used_count return 0 # TODO: remove_last (non-fast) # if darray.allocated_count>8 and new_used_count < darray.allocated_count/4: # new_allocated_count = darray.allocated_count/2 # reallocate(&darray.array, # new_allocated_count * darray.item_size) # darray.allocated_count = new_allocated_count pythontracer-8.10.16/COPYING0000777000175000017500000000000011071710102016550 2gpl-3.0.txtustar peakerpeaker