1 /* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */
2 /* For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt */
3 
4 #ifndef _COVERAGE_TRACER_H
5 #define _COVERAGE_TRACER_H
6 
7 #include "util.h"
8 #include "structmember.h"
9 #include "frameobject.h"
10 #include "opcode.h"
11 
12 #include "datastack.h"
13 
14 /* The CTracer type. */
15 
16 typedef struct CTracer {
17     PyObject_HEAD
18 
19     /* Python objects manipulated directly by the Collector class. */
20     PyObject * should_trace;
21     PyObject * check_include;
22     PyObject * warn;
23     PyObject * concur_id_func;
24     PyObject * data;
25     PyObject * file_tracers;
26     PyObject * should_trace_cache;
27     PyObject * trace_arcs;
28 
29     /* Has the tracer been started? */
30     int started;
31     /* Are we tracing arcs, or just lines? */
32     int tracing_arcs;
33 
34     /*
35         The data stack is a stack of dictionaries.  Each dictionary collects
36         data for a single source file.  The data stack parallels the call stack:
37         each call pushes the new frame's file data onto the data stack, and each
38         return pops file data off.
39 
40         The file data is a dictionary whose form depends on the tracing options.
41         If tracing arcs, the keys are line number pairs.  If not tracing arcs,
42         the keys are line numbers.  In both cases, the value is irrelevant
43         (None).
44     */
45 
46     DataStack data_stack;           /* Used if we aren't doing concurrency. */
47 
48     PyObject * data_stack_index;    /* Used if we are doing concurrency. */
49     DataStack * data_stacks;
50     int data_stacks_alloc;
51     int data_stacks_used;
52     DataStack * pdata_stack;
53 
54     /* The current file's data stack entry, copied from the stack. */
55     DataStackEntry cur_entry;
56 
57     /* The parent frame for the last exception event, to fix missing returns. */
58     PyFrameObject * last_exc_back;
59     int last_exc_firstlineno;
60 
61     Stats stats;
62 } CTracer;
63 
64 int CTracer_intern_strings(void);
65 
66 extern PyTypeObject CTracerType;
67 
68 #endif /* _COVERAGE_TRACER_H */
69