OpenSfM icon indicating copy to clipboard operation
OpenSfM copied to clipboard

Visual Studio Code can't debug

Open MikhailMashukov opened this issue 2 years ago • 1 comments

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).

MikhailMashukov avatar Apr 06 '23 07:04 MikhailMashukov

@MikhailMashukov , do you have the same problem if you set the build type to Debug?

oaa3wf avatar Nov 13 '23 17:11 oaa3wf