Debugging ceval.c file on windows with debug build skipping line by line debugging

Not able debug line by line ceval.c file on windows with debug build. debug step over skipping lines.
Any suggestions.


Seems like you hav optimised C code with debug support.
Did you build python yourself?
Did you make sure compiler optimisations are turned off?

Thanks for quick response. I build python source on windows. I run this command “PCbuild\build.bat -e -d -p x64” to generate debug build that would generate .pdb,dll etc… When I try to run python application on visual studio with debug symbols loaded from generated .pdb I could put break points in ceval.c but step over skip lines.

You don’t say which Python version you’re building. If you’re building 3.10, at the top there’s this:


which in turn triggers this code block in pyport.h:

#if defined(_MSC_VER)
#  if defined(PY_LOCAL_AGGRESSIVE)
   /* enable more aggressive optimization for MSVC */
   /* active in both release and debug builds - see bpo-43271 */
#  pragma optimize("gt", on)

That in turn forces the compiler to enable optimizations even when building in debug mode. This is done because the unoptimized code triggers a stack overflow error when running the full test suite.

Depending on what you’re trying to accomplish, you could try commenting out the #define PY_LOCAL_AGGRESSIVE line and you may have better luck.

It looks like in 3.11 this behavior is changed. It’s possible that it was done slightly differently before 3.10.

Thanks, I am building 3.9.13 version.

Thanks @guido this seems to resolve my issue.