mirror of https://github.com/python/cpython
gh-88226: Emit TARGET labels in Python/ceval.c when debugging, even if computed gotos aren't enabled (GH-98265)
Keep target labels when debugging, but don't warn about lack of use. Co-authored-by: Eryk Sun <eryksun@gmail.com>
This commit is contained in:
parent
22d91c16bb
commit
d4cf192826
|
@ -0,0 +1,3 @@
|
|||
Always define ``TARGET_*`` labels in ``Python/ceval.c``, even if
|
||||
``USE_COMPUTED_GOTOS`` is disabled. This allows breakpoints to be
|
||||
set at those labels in (for instance) ``gdb``.
|
|
@ -678,11 +678,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
|
|||
#endif
|
||||
|
||||
#if USE_COMPUTED_GOTOS
|
||||
#define TARGET(op) TARGET_##op: INSTRUCTION_START(op);
|
||||
#define DISPATCH_GOTO() goto *opcode_targets[opcode]
|
||||
# define TARGET(op) TARGET_##op: INSTRUCTION_START(op);
|
||||
# define DISPATCH_GOTO() goto *opcode_targets[opcode]
|
||||
#else
|
||||
#define TARGET(op) case op: INSTRUCTION_START(op);
|
||||
#define DISPATCH_GOTO() goto dispatch_opcode
|
||||
# define TARGET(op) case op: TARGET_##op: INSTRUCTION_START(op);
|
||||
# define DISPATCH_GOTO() goto dispatch_opcode
|
||||
#endif
|
||||
|
||||
/* PRE_DISPATCH_GOTO() does lltrace if enabled. Normally a no-op */
|
||||
|
@ -1056,6 +1056,18 @@ static inline void _Py_LeaveRecursiveCallPy(PyThreadState *tstate) {
|
|||
#define KWNAMES_LEN() \
|
||||
(kwnames == NULL ? 0 : ((int)PyTuple_GET_SIZE(kwnames)))
|
||||
|
||||
/* Disable unused label warnings. They are handy for debugging, even
|
||||
if computed gotos aren't used. */
|
||||
|
||||
/* TBD - what about other compilers? */
|
||||
#if defined(__GNUC__)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wunused-label"
|
||||
#elif defined(_MSC_VER) /* MS_WINDOWS */
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4102)
|
||||
#endif
|
||||
|
||||
PyObject* _Py_HOT_FUNCTION
|
||||
_PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag)
|
||||
{
|
||||
|
@ -1435,6 +1447,11 @@ resume_with_error:
|
|||
goto error;
|
||||
|
||||
}
|
||||
#if defined(__GNUC__)
|
||||
# pragma GCC diagnostic pop
|
||||
#elif defined(_MSC_VER) /* MS_WINDOWS */
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
static void
|
||||
format_missing(PyThreadState *tstate, const char *kind,
|
||||
|
|
Loading…
Reference in New Issue