Skip to content

Commit d4cf192

Browse files
smontanaroeryksun
andauthored
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>
1 parent 22d91c1 commit d4cf192

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Always define ``TARGET_*`` labels in ``Python/ceval.c``, even if
2+
``USE_COMPUTED_GOTOS`` is disabled. This allows breakpoints to be
3+
set at those labels in (for instance) ``gdb``.

Python/ceval.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,11 +678,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
678678
#endif
679679

680680
#if USE_COMPUTED_GOTOS
681-
#define TARGET(op) TARGET_##op: INSTRUCTION_START(op);
682-
#define DISPATCH_GOTO() goto *opcode_targets[opcode]
681+
# define TARGET(op) TARGET_##op: INSTRUCTION_START(op);
682+
# define DISPATCH_GOTO() goto *opcode_targets[opcode]
683683
#else
684-
#define TARGET(op) case op: INSTRUCTION_START(op);
685-
#define DISPATCH_GOTO() goto dispatch_opcode
684+
# define TARGET(op) case op: TARGET_##op: INSTRUCTION_START(op);
685+
# define DISPATCH_GOTO() goto dispatch_opcode
686686
#endif
687687

688688
/* PRE_DISPATCH_GOTO() does lltrace if enabled. Normally a no-op */
@@ -1056,6 +1056,18 @@ static inline void _Py_LeaveRecursiveCallPy(PyThreadState *tstate) {
10561056
#define KWNAMES_LEN() \
10571057
(kwnames == NULL ? 0 : ((int)PyTuple_GET_SIZE(kwnames)))
10581058

1059+
/* Disable unused label warnings. They are handy for debugging, even
1060+
if computed gotos aren't used. */
1061+
1062+
/* TBD - what about other compilers? */
1063+
#if defined(__GNUC__)
1064+
# pragma GCC diagnostic push
1065+
# pragma GCC diagnostic ignored "-Wunused-label"
1066+
#elif defined(_MSC_VER) /* MS_WINDOWS */
1067+
# pragma warning(push)
1068+
# pragma warning(disable:4102)
1069+
#endif
1070+
10591071
PyObject* _Py_HOT_FUNCTION
10601072
_PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag)
10611073
{
@@ -1435,6 +1447,11 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
14351447
goto error;
14361448

14371449
}
1450+
#if defined(__GNUC__)
1451+
# pragma GCC diagnostic pop
1452+
#elif defined(_MSC_VER) /* MS_WINDOWS */
1453+
# pragma warning(pop)
1454+
#endif
14381455

14391456
static void
14401457
format_missing(PyThreadState *tstate, const char *kind,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy