mapillary / mapillary/OpenSfM

Visual Studio Code can't debug

Open
#991 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.8k
Forks
899
PR merge metrics
No merged PRs in 30d

Description

I am trying to get call stack and variables' state inside OpenSfM (in particular in bundle_adjuster.cc / BundleAdjuster::Run) with VS Code debugger. So I added

def configure_c_extension():
"""Configure cmake project to C extension."""
...
if sys.platform == "win32":
cmake_command += [
"-DVCPKG_TARGET_TRIPLET=x64-windows",
"-DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake",
]
else:
cmake_command += ["-DCMAKE_BUILD_TYPE=RelWithDebInfo"]

subprocess.check_call(cmake_command, cwd=targetDirName)

into setup.py and rebuilt. Produced opensfm/py* are very big, e.g. pybundle.cpython-38-x86_64-linux-gnu.so is 120 MB now, while before it was 1.3 MB. I setted up debugging in VS Code with

   {
      "name": "Python C++ Debug",
      "type": "pythoncpp",
      "request": "launch",
      "pythonLaunchName": "Python: reconstruct",
      "cppAttachName": "(gdb) Attach",
      "stopAtEntry": false,
      "externalConsole": false,      
      "logging": {
        "moduleLoad": true,
        "engineLogging": true,
        "trace": true
      },      
    },
    {
      "name": "(gdb) Attach",
      "type": "cppdbg",
      "request": "attach",
      "args": [],
      "processId": "${command:pickProcess}",
      "externalConsole": false,
      "MIMode": "gdb",
      "miDebuggerPath": "/usr/bin/gdb",
      "symbolLoadInfo": {
        "loadAll": true,
        "exceptionList": ""
      },
      "setupCommands": [
          {
             "description": "Enable pretty-printing for gdb",
             "text": "-enable-pretty-printing",
             "ignoreFailures": true
          },
          {
             "text": "set print elements 0"
          }
      ],
      "logging": {
        "moduleLoad": true,
        "engineLogging": true,
        "trace": true
      },
    },
      {
        "name": "Python: reconstruct",
        "type": "python",
        "request": "launch",
        "program": "bin/opensfm_main.py",
        "cwd": "${workspaceFolder}/OpenSfM",
        "args": "reconstruct data/lund",
        "console": "integratedTerminal",
        "justMyCode": false
      },

configurations in launch.json, I can debug Python code and can stop C++ code. But when it should show OpenSfM's call stack, I only see one line, [Unknown/Just-In-Time compiled code].

Tried debugging inside Docker through SSH and directly inside miniconda, result is the same.

Ubuntu 20.04, fresh VS Code, fresh OpenSfM main branch (commit b760b21f).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with configure_c_extension in setup.py and BundleAdjuster::Run in bundle_adjuster.cc, then reproduce the issue using the launch.json configurations on Ubuntu 20.04. Check how the generated extension and debugger load symbols; the issue is done when VS Code shows the OpenSfM C++ call stack and variables instead of only unknown compiled code.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, python, vscode
Domain
build-system, developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.