mirror of https://github.com/python/cpython.git
gh-91428: Add _PyOpcode_OpName to opcode.h of debug builds (GH-91430)
This commit is contained in:
parent
3869a839d5
commit
8a35ce3796
|
@ -446,6 +446,121 @@ const uint8_t _PyOpcode_Deopt[256] = {
|
|||
#define NB_INPLACE_TRUE_DIVIDE 24
|
||||
#define NB_INPLACE_XOR 25
|
||||
|
||||
#ifdef Py_DEBUG
|
||||
static const char *const _PyOpcode_OpName[256] = {
|
||||
[CACHE] = "CACHE",
|
||||
[POP_TOP] = "POP_TOP",
|
||||
[PUSH_NULL] = "PUSH_NULL",
|
||||
[NOP] = "NOP",
|
||||
[UNARY_POSITIVE] = "UNARY_POSITIVE",
|
||||
[UNARY_NEGATIVE] = "UNARY_NEGATIVE",
|
||||
[UNARY_NOT] = "UNARY_NOT",
|
||||
[UNARY_INVERT] = "UNARY_INVERT",
|
||||
[BINARY_SUBSCR] = "BINARY_SUBSCR",
|
||||
[GET_LEN] = "GET_LEN",
|
||||
[MATCH_MAPPING] = "MATCH_MAPPING",
|
||||
[MATCH_SEQUENCE] = "MATCH_SEQUENCE",
|
||||
[MATCH_KEYS] = "MATCH_KEYS",
|
||||
[PUSH_EXC_INFO] = "PUSH_EXC_INFO",
|
||||
[CHECK_EXC_MATCH] = "CHECK_EXC_MATCH",
|
||||
[CHECK_EG_MATCH] = "CHECK_EG_MATCH",
|
||||
[WITH_EXCEPT_START] = "WITH_EXCEPT_START",
|
||||
[GET_AITER] = "GET_AITER",
|
||||
[GET_ANEXT] = "GET_ANEXT",
|
||||
[BEFORE_ASYNC_WITH] = "BEFORE_ASYNC_WITH",
|
||||
[BEFORE_WITH] = "BEFORE_WITH",
|
||||
[END_ASYNC_FOR] = "END_ASYNC_FOR",
|
||||
[STORE_SUBSCR] = "STORE_SUBSCR",
|
||||
[DELETE_SUBSCR] = "DELETE_SUBSCR",
|
||||
[GET_ITER] = "GET_ITER",
|
||||
[GET_YIELD_FROM_ITER] = "GET_YIELD_FROM_ITER",
|
||||
[PRINT_EXPR] = "PRINT_EXPR",
|
||||
[LOAD_BUILD_CLASS] = "LOAD_BUILD_CLASS",
|
||||
[LOAD_ASSERTION_ERROR] = "LOAD_ASSERTION_ERROR",
|
||||
[RETURN_GENERATOR] = "RETURN_GENERATOR",
|
||||
[LIST_TO_TUPLE] = "LIST_TO_TUPLE",
|
||||
[RETURN_VALUE] = "RETURN_VALUE",
|
||||
[IMPORT_STAR] = "IMPORT_STAR",
|
||||
[SETUP_ANNOTATIONS] = "SETUP_ANNOTATIONS",
|
||||
[YIELD_VALUE] = "YIELD_VALUE",
|
||||
[ASYNC_GEN_WRAP] = "ASYNC_GEN_WRAP",
|
||||
[PREP_RERAISE_STAR] = "PREP_RERAISE_STAR",
|
||||
[POP_EXCEPT] = "POP_EXCEPT",
|
||||
[STORE_NAME] = "STORE_NAME",
|
||||
[DELETE_NAME] = "DELETE_NAME",
|
||||
[UNPACK_SEQUENCE] = "UNPACK_SEQUENCE",
|
||||
[FOR_ITER] = "FOR_ITER",
|
||||
[UNPACK_EX] = "UNPACK_EX",
|
||||
[STORE_ATTR] = "STORE_ATTR",
|
||||
[DELETE_ATTR] = "DELETE_ATTR",
|
||||
[STORE_GLOBAL] = "STORE_GLOBAL",
|
||||
[DELETE_GLOBAL] = "DELETE_GLOBAL",
|
||||
[SWAP] = "SWAP",
|
||||
[LOAD_CONST] = "LOAD_CONST",
|
||||
[LOAD_NAME] = "LOAD_NAME",
|
||||
[BUILD_TUPLE] = "BUILD_TUPLE",
|
||||
[BUILD_LIST] = "BUILD_LIST",
|
||||
[BUILD_SET] = "BUILD_SET",
|
||||
[BUILD_MAP] = "BUILD_MAP",
|
||||
[LOAD_ATTR] = "LOAD_ATTR",
|
||||
[COMPARE_OP] = "COMPARE_OP",
|
||||
[IMPORT_NAME] = "IMPORT_NAME",
|
||||
[IMPORT_FROM] = "IMPORT_FROM",
|
||||
[JUMP_FORWARD] = "JUMP_FORWARD",
|
||||
[JUMP_IF_FALSE_OR_POP] = "JUMP_IF_FALSE_OR_POP",
|
||||
[JUMP_IF_TRUE_OR_POP] = "JUMP_IF_TRUE_OR_POP",
|
||||
[POP_JUMP_FORWARD_IF_FALSE] = "POP_JUMP_FORWARD_IF_FALSE",
|
||||
[POP_JUMP_FORWARD_IF_TRUE] = "POP_JUMP_FORWARD_IF_TRUE",
|
||||
[LOAD_GLOBAL] = "LOAD_GLOBAL",
|
||||
[IS_OP] = "IS_OP",
|
||||
[CONTAINS_OP] = "CONTAINS_OP",
|
||||
[RERAISE] = "RERAISE",
|
||||
[COPY] = "COPY",
|
||||
[BINARY_OP] = "BINARY_OP",
|
||||
[SEND] = "SEND",
|
||||
[LOAD_FAST] = "LOAD_FAST",
|
||||
[STORE_FAST] = "STORE_FAST",
|
||||
[DELETE_FAST] = "DELETE_FAST",
|
||||
[POP_JUMP_FORWARD_IF_NOT_NONE] = "POP_JUMP_FORWARD_IF_NOT_NONE",
|
||||
[POP_JUMP_FORWARD_IF_NONE] = "POP_JUMP_FORWARD_IF_NONE",
|
||||
[RAISE_VARARGS] = "RAISE_VARARGS",
|
||||
[GET_AWAITABLE] = "GET_AWAITABLE",
|
||||
[MAKE_FUNCTION] = "MAKE_FUNCTION",
|
||||
[BUILD_SLICE] = "BUILD_SLICE",
|
||||
[JUMP_BACKWARD_NO_INTERRUPT] = "JUMP_BACKWARD_NO_INTERRUPT",
|
||||
[MAKE_CELL] = "MAKE_CELL",
|
||||
[LOAD_CLOSURE] = "LOAD_CLOSURE",
|
||||
[LOAD_DEREF] = "LOAD_DEREF",
|
||||
[STORE_DEREF] = "STORE_DEREF",
|
||||
[DELETE_DEREF] = "DELETE_DEREF",
|
||||
[JUMP_BACKWARD] = "JUMP_BACKWARD",
|
||||
[CALL_FUNCTION_EX] = "CALL_FUNCTION_EX",
|
||||
[EXTENDED_ARG] = "EXTENDED_ARG",
|
||||
[LIST_APPEND] = "LIST_APPEND",
|
||||
[SET_ADD] = "SET_ADD",
|
||||
[MAP_ADD] = "MAP_ADD",
|
||||
[LOAD_CLASSDEREF] = "LOAD_CLASSDEREF",
|
||||
[COPY_FREE_VARS] = "COPY_FREE_VARS",
|
||||
[RESUME] = "RESUME",
|
||||
[MATCH_CLASS] = "MATCH_CLASS",
|
||||
[FORMAT_VALUE] = "FORMAT_VALUE",
|
||||
[BUILD_CONST_KEY_MAP] = "BUILD_CONST_KEY_MAP",
|
||||
[BUILD_STRING] = "BUILD_STRING",
|
||||
[LOAD_METHOD] = "LOAD_METHOD",
|
||||
[LIST_EXTEND] = "LIST_EXTEND",
|
||||
[SET_UPDATE] = "SET_UPDATE",
|
||||
[DICT_MERGE] = "DICT_MERGE",
|
||||
[DICT_UPDATE] = "DICT_UPDATE",
|
||||
[PRECALL] = "PRECALL",
|
||||
[CALL] = "CALL",
|
||||
[KW_NAMES] = "KW_NAMES",
|
||||
[POP_JUMP_BACKWARD_IF_NOT_NONE] = "POP_JUMP_BACKWARD_IF_NOT_NONE",
|
||||
[POP_JUMP_BACKWARD_IF_NONE] = "POP_JUMP_BACKWARD_IF_NONE",
|
||||
[POP_JUMP_BACKWARD_IF_FALSE] = "POP_JUMP_BACKWARD_IF_FALSE",
|
||||
[POP_JUMP_BACKWARD_IF_TRUE] = "POP_JUMP_BACKWARD_IF_TRUE",
|
||||
};
|
||||
#endif
|
||||
|
||||
#define HAS_ARG(op) ((op) >= HAVE_ARGUMENT)
|
||||
|
||||
/* Reserve some bytecodes for internal use in the compiler.
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
Add ``static const char *const _PyOpcode_OpName[256] = {...};`` to
|
||||
``opcode.h`` for debug builds to assist in debugging the Python interpreter.
|
||||
It is now more convenient to make various forms of debugging output more
|
||||
human-readable by including opcode names rather than just the corresponding
|
||||
decimal digits.
|
|
@ -108,6 +108,14 @@ def main(opcode_py, outfile='Include/opcode.h'):
|
|||
for i, (op, _) in enumerate(opcode["_nb_ops"]):
|
||||
fobj.write(DEFINE.format(op, i))
|
||||
|
||||
fobj.write("\n")
|
||||
fobj.write("#ifdef Py_DEBUG\n")
|
||||
fobj.write("static const char *const _PyOpcode_OpName[256] = {\n")
|
||||
for name in opmap:
|
||||
fobj.write(f''' [{name}] = "{name}",\n''')
|
||||
fobj.write("};\n")
|
||||
fobj.write("#endif\n")
|
||||
|
||||
fobj.write(footer)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue