https://github.com/python/cpython/commit/fbaa6c8ff06cf885d9b8c8ea6cf25bab3781a2bd
commit: fbaa6c8ff06cf885d9b8c8ea6cf25bab3781a2bd
branch: main
author: Brandt Bucher <[email protected]>
committer: brandtbucher <[email protected]>
date: 2025-02-07T08:49:51-08:00
summary:

GH-129763: Remove the LLTRACE macro (GH-129764)

files:
A 
Misc/NEWS.d/next/Core_and_Builtins/2025-02-06-17-05-09.gh-issue-129763.6ZxQ8W.rst
M Misc/SpecialBuilds.txt
M Python/bytecodes.c
M Python/ceval.c
M Python/ceval_macros.h
M Python/generated_cases.c.h
M Tools/c-analyzer/TODO
M Tools/cases_generator/analyzer.py
M Tools/jit/template.c

diff --git 
a/Misc/NEWS.d/next/Core_and_Builtins/2025-02-06-17-05-09.gh-issue-129763.6ZxQ8W.rst
 
b/Misc/NEWS.d/next/Core_and_Builtins/2025-02-06-17-05-09.gh-issue-129763.6ZxQ8W.rst
new file mode 100644
index 00000000000000..ffb96c20fcad7e
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2025-02-06-17-05-09.gh-issue-129763.6ZxQ8W.rst
@@ -0,0 +1 @@
+Remove the internal ``LLTRACE`` macro (use :c:macro:`Py_DEBUG` instead).
diff --git a/Misc/SpecialBuilds.txt b/Misc/SpecialBuilds.txt
index 78201bfbd6741d..23fa36af78cc52 100644
--- a/Misc/SpecialBuilds.txt
+++ b/Misc/SpecialBuilds.txt
@@ -78,22 +78,16 @@ Py_DEBUG
 
 This is what is generally meant by "a debug build" of Python.
 
-Py_DEBUG implies LLTRACE and Py_REF_DEBUG. In addition, C assert()s are enabled
+Py_DEBUG implies Py_REF_DEBUG. In addition, C assert()s are enabled
 (via the C way: by not defining NDEBUG), and some routines do additional sanity
 checks inside "#ifdef Py_DEBUG" blocks.
 
-
-LLTRACE
--------
-
-Compile in support for Low Level TRACE-ing of the main interpreter loop.
-
-When this preprocessor symbol is defined, before PyEval_EvalFrame executes a
-frame's code it checks the frame's global namespace for a variable
-"__lltrace__".  If such a variable is found, mounds of information about what
-the interpreter is doing are sprayed to stdout, such as every opcode and opcode
-argument and values pushed onto and popped off the value stack.
-
-Not useful very often, but very useful when needed.
-
-Py_DEBUG implies LLTRACE.
+Also, compile in support for "lltrace" (Low Level TRACE-ing) of the main
+interpreter loop. Before _PyEval_EvalFrameDefault executes a frame's code, it
+checks the frame's global namespace for a variable "__lltrace__" (as well as 
for
+the environment variable PYTHON_LLTRACE"). If such a variable is found, mounds
+of information about what the interpreter is doing are sprayed to stdout, such
+as every opcode and opcode argument and values pushed onto and popped off the
+value stack. Higher integer values for the environment variable result in more
+and more detail being printed (the global __lltrace__ always enables the 
maximum
+output). Not useful very often, but *very* useful when needed.
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index c3024f7f98f28c..07022e9932d203 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -5301,7 +5301,7 @@ dummy_func(
                 goto exception_unwind;
             }
             /* Resume normal execution */
-#ifdef LLTRACE
+#ifdef Py_DEBUG
             if (frame->lltrace >= 5) {
                 lltrace_resume_frame(frame);
             }
@@ -5340,15 +5340,7 @@ dummy_func(
             }
             next_instr = frame->instr_ptr;
 
-        #ifdef LLTRACE
-            {
-                int lltrace = maybe_lltrace_resume_frame(frame, GLOBALS());
-                frame->lltrace = lltrace;
-                if (lltrace < 0) {
-                    goto exit_unwind;
-                }
-            }
-        #endif
+            LLTRACE_RESUME_FRAME();
 
         #ifdef Py_DEBUG
             /* _PyEval_EvalFrameDefault() must not be called with an exception 
set,
diff --git a/Python/ceval.c b/Python/ceval.c
index 5e834883f355e1..b2e2b540783880 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -43,11 +43,6 @@
 
 #include <stdbool.h>              // bool
 
-#ifdef Py_DEBUG
-   /* For debugging the interpreter: */
-#  define LLTRACE  1      /* Low-level trace feature */
-#endif
-
 #if !defined(Py_BUILD_CORE)
 #  error "ceval.c must be build with Py_BUILD_CORE define for best performance"
 #endif
@@ -136,7 +131,7 @@
 #endif
 
 
-#ifdef LLTRACE
+#ifdef Py_DEBUG
 static void
 dump_stack(_PyInterpreterFrame *frame, _PyStackRef *stack_pointer)
 {
@@ -818,7 +813,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, 
_PyInterpreterFrame *frame, int
     entry_frame.owner = FRAME_OWNED_BY_INTERPRETER;
     entry_frame.visited = 0;
     entry_frame.return_offset = 0;
-#ifdef LLTRACE
+#ifdef Py_DEBUG
     entry_frame.lltrace = 0;
 #endif
     /* Push frame */
diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h
index 44bb52a09aab5f..fde8e5efa983b2 100644
--- a/Python/ceval_macros.h
+++ b/Python/ceval_macros.h
@@ -108,21 +108,21 @@
 #endif
 
 /* PRE_DISPATCH_GOTO() does lltrace if enabled. Normally a no-op */
-#ifdef LLTRACE
+#ifdef Py_DEBUG
 #define PRE_DISPATCH_GOTO() if (frame->lltrace >= 5) { \
     lltrace_instruction(frame, stack_pointer, next_instr, opcode, oparg); }
 #else
 #define PRE_DISPATCH_GOTO() ((void)0)
 #endif
 
-#if LLTRACE
+#ifdef Py_DEBUG
 #define LLTRACE_RESUME_FRAME() \
 do { \
     int lltrace = maybe_lltrace_resume_frame(frame, GLOBALS()); \
-    frame->lltrace = lltrace; \
     if (lltrace < 0) { \
         JUMP_TO_LABEL(exit_unwind); \
     } \
+    frame->lltrace = lltrace; \
 } while (0)
 #else
 #define LLTRACE_RESUME_FRAME() ((void)0)
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index facdf2f78d28ea..ec9b287541f016 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -11416,7 +11416,7 @@ JUMP_TO_LABEL(error);
                 JUMP_TO_LABEL(exception_unwind);
             }
             /* Resume normal execution */
-            #ifdef LLTRACE
+            #ifdef Py_DEBUG
             if (frame->lltrace >= 5) {
                 lltrace_resume_frame(frame);
             }
@@ -11458,16 +11458,7 @@ JUMP_TO_LABEL(error);
                 JUMP_TO_LABEL(exit_unwind);
             }
             next_instr = frame->instr_ptr;
-            #ifdef LLTRACE
-            {
-                int lltrace = maybe_lltrace_resume_frame(frame, GLOBALS());
-                frame->lltrace = lltrace;
-                if (lltrace < 0) {
-                    JUMP_TO_LABEL(exit_unwind);
-                }
-            }
-            #endif
-
+            LLTRACE_RESUME_FRAME();
             #ifdef Py_DEBUG
             /* _PyEval_EvalFrameDefault() must not be called with an exception 
set,
                because it can clear it (directly or indirectly) and so the
diff --git a/Tools/c-analyzer/TODO b/Tools/c-analyzer/TODO
index e81ceb29c64bf0..edd0c4bc7fdaa6 100644
--- a/Tools/c-analyzer/TODO
+++ b/Tools/c-analyzer/TODO
@@ -69,7 +69,6 @@ Objects/tupleobject.c:_Py_tuple_zero_allocs                   
   Py_ssize_t _Py_
 Objects/typeobject.c:next_version_tag                            static 
unsigned int next_version_tag
 Python/Python-ast.c:init_types():initialized                     static int 
initialized
 Python/bootstrap_hash.c:urandom_cache                            static struct 
{ int fd; dev_t st_dev; ino_t st_ino; } urandom_cache
-Python/ceval.c:lltrace                                           static int 
lltrace
 Python/ceval.c:make_pending_calls():busy                         static int 
busy
 Python/dynload_shlib.c:handles                                   static struct 
{ dev_t dev; ino_t ino; void *handle; } handles[128]
 Python/dynload_shlib.c:nhandles                                  static int 
nhandles
diff --git a/Tools/cases_generator/analyzer.py 
b/Tools/cases_generator/analyzer.py
index aa88608168c1be..57cc587428c2b9 100644
--- a/Tools/cases_generator/analyzer.py
+++ b/Tools/cases_generator/analyzer.py
@@ -676,7 +676,6 @@ def has_error_without_pop(op: parser.CodeDef) -> bool:
     "backoff_counter_triggers",
     "initial_temperature_backoff_counter",
     "JUMP_TO_LABEL",
-    "maybe_lltrace_resume_frame",
     "restart_backoff_counter",
 )
 
diff --git a/Tools/jit/template.c b/Tools/jit/template.c
index 929f37d2dddea1..6ea04f5640ef05 100644
--- a/Tools/jit/template.c
+++ b/Tools/jit/template.c
@@ -81,6 +81,11 @@ do {                                                         
\
 #undef WITHIN_STACK_BOUNDS
 #define WITHIN_STACK_BOUNDS() 1
 
+#undef LLTRACE_RESUME_FRAME
+#define LLTRACE_RESUME_FRAME() \
+    do {                       \
+    } while (0)
+
 #define TIER_TWO 2
 
 __attribute__((preserve_none)) _Py_CODEUNIT *

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to