1 /* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */
2 /* For details: https://github.com/nedbat/coveragepy/blob/master/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     PyObject * should_start_context;
29     PyObject * switch_context;
30 
31     /* Has the tracer been started? */
32     BOOL started;
33     /* Are we tracing arcs, or just lines? */
34     BOOL tracing_arcs;
35     /* Have we had any activity? */
36     BOOL activity;
37     /* The current dynamic context. */
38     PyObject * context;
39 
40     /*
41         The data stack is a stack of dictionaries.  Each dictionary collects
42         data for a single source file.  The data stack parallels the call stack:
43         each call pushes the new frame's file data onto the data stack, and each
44         return pops file data off.
45 
46         The file data is a dictionary whose form depends on the tracing options.
47         If tracing arcs, the keys are line number pairs.  If not tracing arcs,
48         the keys are line numbers.  In both cases, the value is irrelevant
49         (None).
50     */
51 
52     DataStack data_stack;           /* Used if we aren't doing concurrency. */
53 
54     PyObject * data_stack_index;    /* Used if we are doing concurrency. */
55     DataStack * data_stacks;
56     int data_stacks_alloc;
57     int data_stacks_used;
58     DataStack * pdata_stack;
59 
60     /* The current file's data stack entry. */
61     DataStackEntry * pcur_entry;
62 
63     /* The parent frame for the last exception event, to fix missing returns. */
64     PyFrameObject * last_exc_back;
65     int last_exc_firstlineno;
66 
67     Stats stats;
68 } CTracer;
69 
70 int CTracer_intern_strings(void);
71 
72 extern PyTypeObject CTracerType;
73 
74 #endif /* _COVERAGE_TRACER_H */
75