zoukankan      html  css  js  c++  java
  • visual gdb Diagnosing IntelliSense problems for Advanced Projects

    from:https://visualgdb.com/tutorials/IntelliSense/

    This tutorial shows how to diagnose IntelliSense problems for advanced VisualGDB projects (e.g. Advanced CMake, Arduino, Mbed or ESP-IDF). We will create a basic Linux project using the Advanced CMake project subsystem and will show how VisualGDB computes the header search files and other IntelliSense parameters and how to diagnose situations where the headers are not located properly or some other settings are missing.

      1. First, we will create a regular Advanced CMake project. Open the VisualGDB Linux Project Wizard:
      2. Proceed with the default settings:
      3. In this tutorial we will explain how VisualGDB caches remote header directories, so select “Build the project under Linux over network”:
      4. On the next page select “Store source files on the Windows computer”:
      5. Click “Finish” to generate the project. Once it is created, right-click on the “Source files” folder for the main target and select “Add->New Item”:
      6. Select “C/C++ Header File” and place the new file into a subdirectory (e.g. subdir):
      7. Include the header file from the main source file and let VisualGDB automatically suggest adding “subdir” to the header search directories, then proceed with updating the settings:
      8. Now we have a simple project that includes both system headers (e.g. <iostream>) from the system directories and custom headers (e.g. Header.h) from header directories specified in the settings. We will now show how exactly VisualGDB queries those directories and how to check that they are handled correctly. Open the View -> Clang IntelliSense Diagnotsics Console window and switch it to the Projects view:The Projects view displays the project structure exactly as seen by IntelliSense. The “X” symbol near the “Header.h” file means that it is not compiled directly, but is expected to be included from other files. The gear symbol near the ClangIntelliSenseDemo.cpp file means that the file has different set of IntelliSense parameters than the project defaults.
      9. If Clang IntelliSense cannot locate some headers, the first step to diagnose it would be to locate the corresponding source file in the Clang IntelliSense Diagnostics Console and check its build flags. The relevant flags would be -I<directory>-isystem <directory> -include <file> and -D<macro>. E.g. in this example, the ClangIntelliSenseDemo.cpp file has the following include directories defined:

        Note how the system directories point to a location under %LOCALAPPDATA% where VisualGDB caches the header files from the Linux machine.
      10. We will now show how VisualGDB computes the include directories. Locate the CodeModel.json file in the build directory for your project (e.g. C:projects empClangIntelliSenseDemoVisualGDBDebugCodeModel.json) and locate the “fileGroups” element in it:

        It will list all source files reported by CMake along with the preprocessor macros and include directories defined through CMakeLists.txt files. Note that since CMake runs on Linux, the paths will reflect the file locations on the remote Linux machine. VisualGDB will use the following logic to map them:
        • If the path is inside the remote project directory, it will automatically get mapped inside the project directory on the Windows machine.
        • If the path is inside one of the directories listed via VisualGDB Project Properties -> Path Mapping or Synchronized Directories, it will get mapped accordingly.
        • If it is not covered by any other mapping rule, but is a part of the include directories reported by CMake, VisualGDB will automatically cache it under %LOCALAPPDATA%.

        For other advanced project types (e.g. Arduino or ESP-IDF), the name and the format of the Code Model file will be different. You can find the exact file name via the View->Output->Advanced VisualGDB Project Output.

      11. The directories for common system headers (e.g. <iostream>) are not reported via CodeModel.json and are handled separately. VisualGDB will automatically query the GCC specified on the Build Settings page of VisualGDB Project Properties for common include directories and macros and will merge them with the information from CodeModel.json. The flags will get cached in the ImplicitCompilerFlags.xml file inside the VisualGDBCache directory (e.g. C:projects empClangIntelliSenseDemoVisualGDBCacheClangIntelliSenseDemo-Debug-VisualGDBImplicitCompilerFlags.xml):

        You can see the details of the built-in directory and macro extraction by opening View->Other Windows->VisualGDB Diagnostics Console, deleting the ImplicitCompilerFlags.xml file and reopening the solution.
      12. If the directories in all the cached files and in Clang IntelliSense Diagnostics Console appear correct, but some headers are still not found, the header cache might be out of date. You can reload it via the IntelliSense Directories page of VisualGDB Project Properties:
  • 相关阅读:
    GIT SSH免登录密码实现更新(git pull)、推送(git push)操作
    Gulp新手入门教程
    常见的反爬虫的方式
    retrying模块的使用
    通过pyppeteer来爬取今日头条
    Selenium详解
    scrapy框架来爬取壁纸网站并将图片下载到本地文件中
    Elasticsearch简介
    使用scrapy框架来进行抓取的原因
    python(三):面向对象--类和实例
  • 原文地址:https://www.cnblogs.com/lidabo/p/14793028.html
Copyright © 2011-2022 走看看