weixin_39859988
weixin_39859988
2021-01-03 09:31

Target Debugging

This issue is used to collect feedback on the experimental Target Debugging feature.

If you have tried out target debugging and find that it works and is useful for your project, add a 👍 reaction to let me know.

Any feedback would be highly appreciated.

Learn more about this feature in these docs for Target Debugging.

该提问来源于开源项目:microsoft/vscode-cmake-tools

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

27条回答

  • weixin_39859988 weixin_39859988 4月前

    Yes, just add a keybinding for the cmake.debugTarget command

    点赞 评论 复制链接分享
  • weixin_39517868 weixin_39517868 4月前

    For some reason, whenever I add the include(CMakeToolsHelpers OPTIONAL) call, I will often see errors from CMake when generating build files through vscode:

    
    CMake Error in CMakeLists.txt:
    Evaluation file to be written multiple times for different configurations
    or languages with different content:
    
      <full path omitted>/build/CMakeToolsMeta.txt
    </full>

    The error tends to repeat a dozen or so times in the output. Running the build again works fine and I can pick debug targets and debug with impunity, so it's not clear what exactly is wrong here. This happens on a couple of different trees, so it doesn't sound like something specific to one particular build.

    FWIW, I'm running CMake 3.6.1 on Windows, target compiler is MSVC 19 (VS 2015), using the Visual Studio 2015 generator.

    点赞 评论 复制链接分享
  • weixin_39859988 weixin_39859988 4月前

    , I know what causes that. It's because the Visual Studio generators are multi-config generators. I didn't think about the interaction here. Thanks for the heads up, I'll put in a fix!

    点赞 评论 复制链接分享
  • weixin_39671631 weixin_39671631 4月前

    It works for me, on OS X 10.9.5 / VSCode 1.5.3 / CMake 2.8.3 / CMake Tools 0.6.0

    Thanks for this, it's very handy ! Somehow the native launch.jsonmethod did not work initially, but this worked like a charm.

    点赞 评论 复制链接分享
  • weixin_39859988 weixin_39859988 4月前

    Thanks for the notice. I have a good idea of how to fix that.

    点赞 评论 复制链接分享
  • weixin_39719127 weixin_39719127 4月前

    Indeed, just taking a quick peek at the module, it seems to be missing the imported check for executables right?

    点赞 评论 复制链接分享
  • weixin_39859988 weixin_39859988 4月前

    That's correct. I've noticed it doing this before, but it's never actually caused an error... I'll have to add the check to make sure this error doesn't happen. Usually people aren't interested in debugging an imported executable.

    点赞 评论 复制链接分享
  • weixin_39757212 weixin_39757212 4月前

    This works great! MacOS 10.12.1, VSCode 1.6.1, Cmake 3.6.2

    点赞 评论 复制链接分享
  • weixin_39757212 weixin_39757212 4月前

    it was working but something happened and now there arent any any available targets for debugging. ive tried everything.

    点赞 评论 复制链接分享
  • weixin_39859988 weixin_39859988 4月前

    That's no good. Can you find a CMakeToolsMeta.txt file? What is inside it? What have you tried?

    点赞 评论 复制链接分享
  • weixin_39757212 weixin_39757212 4月前

    i found a CMakeToolsMeta.in.txt with

     interface-library;Boost::diagnostic_definitions
    system;Darwin;x86_64;Clang
    interface-library;Boost::disable_autolinking
    interface-library;Boost::dynamic_linking
    interface-library;Boost::boost
    executable;rosebud;$<rosebud>
    </rosebud>

    ive tried reconfiguring the project, messing around with the order of the cmakelists file, uninstalling and reinstalling cmaketools, completely uninstalling all of my extensions and clearing whatever caches i could find. nothing.

    点赞 评论 复制链接分享
  • weixin_39757212 weixin_39757212 4月前

    i just changed the CMakeToolsMeta.in.txt file to CMakeToolsMeta.txt and now my target shows up. but CMakeToolsMeta.in.txt was autogenerated so i dont know why its called that

    点赞 评论 复制链接分享
  • weixin_39859988 weixin_39859988 4月前

    Just looked at the code, and it seems this is a bug relating to the project configuration. I'm guessing you are building in Release mode, or some other non-Debug mode. Is that correct? A bug is causing it to only generate the metadata in Debug mode. I'll do a release soon with a few bugfixes and tweaks.

    点赞 评论 复制链接分享
  • weixin_39757212 weixin_39757212 4月前

    no ive only been building in debug and release with deb info mode. i can still build my project, i just cant run/debug it, unless i change the CMakeToolsMeta.in.txt file to CMakeToolsMeta.txt

    点赞 评论 复制链接分享
  • weixin_39859988 weixin_39859988 4月前

    Hmm... Could you open a separate issue for this? I don't want to keep spamming all past participants of this thread. Could you include details about you CMake version, CMake generator, workflow, platform, etc.?

    点赞 评论 复制链接分享
  • weixin_39757212 weixin_39757212 4月前

    sure thing https://github.com/vector-of-bool/vscode-cmake-tools/issues/67

    点赞 评论 复制链接分享
  • weixin_39614011 weixin_39614011 4月前

    Hi! Last update broke environment variables: system ($HOME) and user-defined.

    点赞 评论 复制链接分享
  • weixin_39859988 weixin_39859988 4月前

    , could you open a new issue and put in some more details? I'm going to close this ticket and start tracking target debugging features in individual issues. Thanks!

    点赞 评论 复制链接分享
  • weixin_39614011 weixin_39614011 4月前

    This line makes it possible to make tools working:

    include(${CMAKE_BINARY_DIR}/CMakeTools/CMakeToolsHelpers.cmake)

    点赞 评论 复制链接分享
  • weixin_39614011 weixin_39614011 4月前

    Launching of application is working but launch.json provide possibility to pass environment variables but CMakeTools are not.

    点赞 评论 复制链接分享
  • weixin_39859988 weixin_39859988 4月前

    CMake Tools sets up the module path such that you only need to

     cmake
    include(CMakeToolsHelpers OPTIONAL)
    

    and it will be fine. No need to specify the full path to the file. Actually: please do not specify the full path, because it may be moved in the future. See the docs on how to configure the debugger, which should let you specify environment variables, program arguments, etc.

    Thanks for trying it out! Any feedback is welcome!

    点赞 评论 复制链接分享
  • weixin_39614011 weixin_39614011 4月前

    include(CMakeToolsHelpers OPTIONAL)

    It doesn't work for me (OSX cmake version 3.6.1).

    点赞 评论 复制链接分享
  • weixin_39614011 weixin_39614011 4月前

    CMake Tools generates a debugging configuration object on-the-fly, when debugging is requested. To set some additional parameters to this debug configuration, use the cmake.debugConfig

    How environment variables should be passed to cmake.debugConfig? Thanks!

    点赞 评论 复制链接分享
  • weixin_39859988 weixin_39859988 4月前

    Hmm... do you set(CMAKE_MODULE_PATH ...) at any point in your CMakeLists.txt? Does it fail with any error/warning messages?

    For configuring, set the same values in the all section of the cmake.debugConfig that you would in a launch.json file. For example:

     json
    "cmake.debugConfig": {
        "all": {
            "request": "launch",
            "cwd": "${workspaceRoot}",
            "environment": [{
                "foo": "bar"
            }],
            "linux": {
                "MIMode": "gdb"
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb"
            }
        }
    }
    

    I'll update the docs to talk more about this.

    点赞 评论 复制链接分享
  • weixin_39614011 weixin_39614011 4月前

    Yep, I have set CMAKE_MODULE_PATH var before. It's clear now how to set environment variables. Thanks!

    点赞 评论 复制链接分享
  • weixin_39859988 weixin_39859988 4月前

    Ah, ok. Instead of using set to add things to CMAKE_MODULE_PATH, use this:

     cmake
    list(APPEND CMAKE_MODULE_PATH "SomeDirectoryHere")
    

    Replacing SomeDirectoryHere with what you want to add to the path.

    I'll add a note to the docs about this.

    点赞 评论 复制链接分享
  • weixin_39614011 weixin_39614011 4月前

    I have successfully launched app! Thanks! Is it possible to associate keys for launching debugger?

    点赞 评论 复制链接分享

相关推荐