o3de / o3de

Open 3D Engine (O3DE) is an Apache 2.0-licensed multi-platform 3D engine that enables developers and content creators to build AAA games, cinema-quality 3D worlds, and high-fidelity simulations without any fees or commercial obligations.
https://o3de.org
Other
7.84k stars 2.21k forks source link

Python Debugging: Breakpoints are no longer hit in mixed C++/Python debugging in Visual Studio #14170

Open jckand opened 1 year ago

jckand commented 1 year ago

Describe the bug Breakpoints are no longer hit in mixed C++/Python debugging in Visual Studio. As soon as the Editor is started via Visual Studio, any breakpoints set in Python files report that no symbols are loaded for the document.

Assets required

  1. Python native development tools installed for Visual Studio.
  2. Microsoft Child Process Debugging Power Tool extension installed and enabled for Visual Studio.

Steps to reproduce

  1. Open any Python test file in Automated Testing and add a breakpoint.
  2. Set the Editor to the startup project.
  3. Enable the Python/Native Debugger.
  4. Start the Editor.
  5. Once loaded into the Editor, open the Python Console and run:
    azlmbr.legacy.general.run_file("[Full//path//to//python_test_file.py]")

    e.g.

    azlmbr.legacy.general.run_file("D:\\GitHub\\o3de\\AutomatedTesting\\Gem\\PythonTests\\Prefab\\tests\\spawnables\\Lua_Spawnables_SimpleSpawnAndDespawn.py")

Expected behavior Breakpoint is hit in Visual Studio when the Python file is executed.

Actual behavior Test script runs as normal with no breakpoints hit.

Screenshots/Video image

Found in Branch development

Commit ID from o3de/o3de Repository c3fa0d4a8b199f60a01473b21ba77510c368ae27

Kadino commented 1 year ago

Both @jckand-amzn and @FuzzyCarterAWS can be reached out to for more information.

Kadino commented 1 year ago

Older issue which appears related: https://github.com/o3de/o3de/issues/7381

Kadino commented 1 year ago

Investigating by also following MSVS guide Mixed-mode debugging

Kadino commented 1 year ago

Reproduced this behavior on MSVS 2022 v17.5.0 in development at 9a99b1a388 Even manually attaching the python debugger did not hit breakpoints, despite the debugger stating it attached.

Kadino commented 1 year ago

Visual Studio is not automatically attaching the Python debugger, and the Editor project properties do not display an option for Python debugging. This may be related to MSVS project settings.

However launching and attempting to manually attach to the application shows it exposes Python debugger hooks: attach

The debugger does attach to something, though is unable to pause any executing code.

Kadino commented 1 year ago

Nothing I've tried made the "Python/Native Debugging" option enabled in the MSVS project settings. There was also no effect from setting the python environment in View > Other Windows > Python Environments nor from explicitly pointing MSVS at the python pdb's.

Interestingly, breakpoints set in the C++ function PyRunFile are not hit when invoking azlmbr.legacy.general.run_file. Instead the first C++ method seen is the call to PyIdleEnable invoked by the script. This suggests another method to execute scripts is being used, or that the symbols aren't available in profile builds. Regardless, the hunt for mixed-mode python debugging continues. Likely culprit remains the lack of "Python/Native Debugging" option.