File: py_custom_pyeval_settrace_common.hpp

package info (click to toggle)
pydevd 2.9.5%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,880 kB
  • sloc: python: 75,138; cpp: 1,851; sh: 310; makefile: 40; ansic: 4
file content (62 lines) | stat: -rw-r--r-- 1,870 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef _PY_CUSTOM_PYEVAL_SETTRACE_COMMON_HPP_
#define _PY_CUSTOM_PYEVAL_SETTRACE_COMMON_HPP_

#include "python.h"
#include "py_utils.hpp"

struct InternalInitializeCustomPyEvalSetTrace {
    PyObject* pyNone;
    PyTuple_New* pyTuple_New;
    _PyObject_FastCallDict* pyObject_FastCallDict;
    PyEval_CallObjectWithKeywords* pyEval_CallObjectWithKeywords;
    PyUnicode_InternFromString* pyUnicode_InternFromString;  // Note: in Py2 will be PyString_InternFromString.
    PyTraceBack_Here* pyTraceBack_Here;
    PyEval_SetTrace* pyEval_SetTrace;
    bool isDebug;
    PyUnicode_AsUTF8* pyUnicode_AsUTF8;
    PyObject_Repr* pyObject_Repr;
};

/**
 * Helper information to access CPython internals.
 */
static InternalInitializeCustomPyEvalSetTrace *internalInitializeCustomPyEvalSetTrace = NULL;

/*
 * Cached interned string objects used for calling the profile and
 * trace functions.  Initialized by InternalTraceInit().
 */
static PyObject *InternalWhatstrings_37[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};


static int
InternalIsTraceInitialized()
{
    return internalInitializeCustomPyEvalSetTrace != NULL;
}



static int
InternalTraceInit(InternalInitializeCustomPyEvalSetTrace *p_internalInitializeSettrace_37)
{
    internalInitializeCustomPyEvalSetTrace = p_internalInitializeSettrace_37;
    static const char * const whatnames[8] = {
        "call", "exception", "line", "return",
        "c_call", "c_exception", "c_return",
        "opcode"
    };
    PyObject *name;
    int i;
    for (i = 0; i < 8; ++i) {
        if (InternalWhatstrings_37[i] == NULL) {
            name = internalInitializeCustomPyEvalSetTrace->pyUnicode_InternFromString(whatnames[i]);
            if (name == NULL)
                return -1;
            InternalWhatstrings_37[i] = name;
        }
    }
    return 0;
}

#endif //_PY_CUSTOM_PYEVAL_SETTRACE_COMMON_HPP_