tracer.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #ifndef _COVERAGE_TRACER_H
  4. #define _COVERAGE_TRACER_H
  5. #include "util.h"
  6. #include "structmember.h"
  7. #include "frameobject.h"
  8. #include "opcode.h"
  9. #include "datastack.h"
  10. /* The CTracer type. */
  11. typedef struct CTracer {
  12. PyObject_HEAD
  13. /* Python objects manipulated directly by the Collector class. */
  14. PyObject * should_trace;
  15. PyObject * check_include;
  16. PyObject * warn;
  17. PyObject * concur_id_func;
  18. PyObject * data;
  19. PyObject * file_tracers;
  20. PyObject * should_trace_cache;
  21. PyObject * trace_arcs;
  22. PyObject * should_start_context;
  23. PyObject * switch_context;
  24. PyObject * context;
  25. /* Has the tracer been started? */
  26. BOOL started;
  27. /* Are we tracing arcs, or just lines? */
  28. BOOL tracing_arcs;
  29. /*
  30. The data stack is a stack of dictionaries. Each dictionary collects
  31. data for a single source file. The data stack parallels the call stack:
  32. each call pushes the new frame's file data onto the data stack, and each
  33. return pops file data off.
  34. The file data is a dictionary whose form depends on the tracing options.
  35. If tracing arcs, the keys are line number pairs. If not tracing arcs,
  36. the keys are line numbers. In both cases, the value is irrelevant
  37. (None).
  38. */
  39. DataStack data_stack; /* Used if we aren't doing concurrency. */
  40. PyObject * data_stack_index; /* Used if we are doing concurrency. */
  41. DataStack * data_stacks;
  42. int data_stacks_alloc;
  43. int data_stacks_used;
  44. DataStack * pdata_stack;
  45. /* The current file's data stack entry, copied from the stack. */
  46. DataStackEntry cur_entry;
  47. /* The parent frame for the last exception event, to fix missing returns. */
  48. PyFrameObject * last_exc_back;
  49. int last_exc_firstlineno;
  50. Stats stats;
  51. } CTracer;
  52. int CTracer_intern_strings(void);
  53. extern PyTypeObject CTracerType;
  54. #endif /* _COVERAGE_TRACER_H */