当前位置: 首页 > news >正文

网站建设 网站优化站长之家爱站网

网站建设 网站优化,站长之家爱站网,中国 生产商全国客服热线:0511一个专门做 生意的网站,asp个人网站怎么建设1、背景介绍上一篇文章:VScode 结合Global构建linux源代码阅读环境 ,介绍了在VS Code工具中通过remote-ssh远程登陆到Linux远程服务器,使用Global构建linux源代码阅读环境,对linux kernel代码进行解析,实现全局搜索、自…

1、背景介绍

上一篇文章:VScode 结合Global构建linux源代码阅读环境 ,介绍了在VS Code工具中通过remote-ssh远程登陆到Linux远程服务器,使用Global构建linux源代码阅读环境,对linux kernel代码进行解析,实现全局搜索、自动跳转、代码补全等功能,但是Global工具在建立代码索引数据时,将整个Linux源代码都进行了数据检索分析,这样会有很多重复的定义和声明,不够智能,不够方便,接下来介绍使用vscode + clangd工具来解决此问题。

2、原理介绍

clangd 可以实现代码语义分析、代码补全、跳转等,能做到代码精准跳转、精准自动补全;其原理是通过读取工程编译自动生成的compile_commands.json 文件来索引其中包含的源文件和关联的头文件,因此能避免索引非编译的代码造成解析时语义混乱。compile_commands.json 文件是每个源文件的编译参数、路径等信息组成的一个json文件,clangd 通过这个文件可以准确定位源文件需要引用的头文件从而准确的找到各种宏定义、函数、变量声明的准确值。

Linux源代码已包含可以直接生成compile_commands.json文件的python脚本,在编译后Linux kernel代码路径下执行如下命令即可生成compile_commands.json文件:

python3 ./scripts/clang-tools/gen_compile_commands.py

3、安装插件

打开VS Code,在扩展界面搜索clangd后安装插件:

安装好插件后,使用VS Code打开任意C语言会提示你安装clangd程序,由于我是用remote-ssh登陆到远程linux服务器上的,所有clangd程序会安装到远程的服务器上,如果自动安装失败,也可以在远程服务器上使用命令安装(ubuntu服务器):

$ sudo apt install clangd

需要注意的是 clangd插件与C/C++ Intellisense、C/C++ GNU Global是冲突的,需要禁用或者卸载。

4、环境配置

前面的文章有提到在VS code 下如何进行配置,和前面一样clangd的配置我们同样配置到远程用户 setting.json文件中,在setting.json文件中新增如下配置:

    "clangd.arguments": ["--compile-commands-dir=${workspaceFolder}","--background-index","--completion-style=detailed","--header-insertion=never","--log=verbose"],

完成配置后,打开任意源代码文件触发clangd进行解析:

clangd 检索的数据库位于工作目录 .cache/clangd 文件夹,如果想重新生成检索只要删除相关的文件即可。如果一切正常,就看实现代码跳转了,但是一般都会出现问题:

如上图所示,出现了 Unknown argument: '-fno-allow-store-data-races' 等错误。

解决方案:在工作目录新建 .clangd 文件,输入如下内容(同类型的错误都可以使用此方案解决)

CompileFlags:Remove: [-fno-allow-store-data-races,-fconserve-stack]   

clangd解析过程会输出相应的日志信息,可以根据输出信息进行问题的排查:

上图最核心的错误提示:unkown target ABI 'lp64',在 .clangd 文件添加:-mabi=lp64

CompileFlags:Remove: [-fno-allow-store-data-races,-fconserve-stack,-mabi=lp64]   

解决相关的错误问题后,重新打开VS code,clangd会触发重新检索源代码,检索完成后即可使用clangd来检索代码:

5、阅读代码

clangd index 完成后,打开任意代码文件,选择相关函数或者变量,使用快捷键: CTRL+鼠标左键(或者F12),实现函数定义的跳转查询,跳转以后使用快捷键:ALT+左键头 返回;当然也具备对函数进行自动提示、补全的功能:

这样就可以对linux kernel 代码进行愉快的探索了................

6、后记

根据前面一系列的文章,已介绍使用VS Code 远程登陆到服务器,对Linux kernel代码建立索引,实现全局搜索、自动跳转、代码补全等功能,愉快的阅读Linux kernel源代码了,下一步将介绍如何在VS code 中实现gdb可视化调试linux kernel源代码。


文章转载自:
http://dinncobrandyball.ssfq.cn
http://dinncofuruncular.ssfq.cn
http://dinncoscunge.ssfq.cn
http://dinncochylomicron.ssfq.cn
http://dinncoconciliatory.ssfq.cn
http://dinncocarcinogenic.ssfq.cn
http://dinncosinglestick.ssfq.cn
http://dinncopeneplain.ssfq.cn
http://dinncotraipse.ssfq.cn
http://dinncoaerosinusitis.ssfq.cn
http://dinncorhinestone.ssfq.cn
http://dinncowheelbox.ssfq.cn
http://dinncodehors.ssfq.cn
http://dinncopilonidal.ssfq.cn
http://dinncomicroanalysis.ssfq.cn
http://dinncolightful.ssfq.cn
http://dinncosharleen.ssfq.cn
http://dinncoruthful.ssfq.cn
http://dinncosiddhartha.ssfq.cn
http://dinncobunned.ssfq.cn
http://dinncopiraeus.ssfq.cn
http://dinnconiggard.ssfq.cn
http://dinncophototypesetting.ssfq.cn
http://dinncomyosis.ssfq.cn
http://dinncoeleoptene.ssfq.cn
http://dinncounconstitutional.ssfq.cn
http://dinncofamiliar.ssfq.cn
http://dinncocacti.ssfq.cn
http://dinncovern.ssfq.cn
http://dinncoafterripening.ssfq.cn
http://dinncostumour.ssfq.cn
http://dinncoreposit.ssfq.cn
http://dinncopfeffernuss.ssfq.cn
http://dinncomournfully.ssfq.cn
http://dinncoearmuff.ssfq.cn
http://dinnconovell.ssfq.cn
http://dinncotrice.ssfq.cn
http://dinncomournful.ssfq.cn
http://dinncoadurol.ssfq.cn
http://dinncoliberality.ssfq.cn
http://dinncocromlech.ssfq.cn
http://dinncosabbatical.ssfq.cn
http://dinncobouillabaisse.ssfq.cn
http://dinncomuso.ssfq.cn
http://dinncouropygial.ssfq.cn
http://dinncotorreyite.ssfq.cn
http://dinncolentiform.ssfq.cn
http://dinncosideman.ssfq.cn
http://dinncocathodograph.ssfq.cn
http://dinncokatzenjammer.ssfq.cn
http://dinncodisintegrative.ssfq.cn
http://dinncoabnormalcy.ssfq.cn
http://dinncomidtown.ssfq.cn
http://dinncocircumgyrate.ssfq.cn
http://dinncoscapula.ssfq.cn
http://dinncokinghood.ssfq.cn
http://dinncophytotoxin.ssfq.cn
http://dinncosemiquaver.ssfq.cn
http://dinncofoxfire.ssfq.cn
http://dinncoandrogyne.ssfq.cn
http://dinncoperimetry.ssfq.cn
http://dinncoscyphozoan.ssfq.cn
http://dinncotheretofore.ssfq.cn
http://dinncotaken.ssfq.cn
http://dinncomethodically.ssfq.cn
http://dinncorecanalization.ssfq.cn
http://dinncogangload.ssfq.cn
http://dinncocharry.ssfq.cn
http://dinncohausfrau.ssfq.cn
http://dinncospine.ssfq.cn
http://dinncoelectrophorese.ssfq.cn
http://dinncopickel.ssfq.cn
http://dinncoscent.ssfq.cn
http://dinncovinylite.ssfq.cn
http://dinncofirearms.ssfq.cn
http://dinncocyrillic.ssfq.cn
http://dinncohorsecouper.ssfq.cn
http://dinncosaponification.ssfq.cn
http://dinncoassistantship.ssfq.cn
http://dinncononarticulate.ssfq.cn
http://dinncoplumulaceous.ssfq.cn
http://dinncoheronsew.ssfq.cn
http://dinncoloyal.ssfq.cn
http://dinncoruddock.ssfq.cn
http://dinncojabber.ssfq.cn
http://dinncoasperity.ssfq.cn
http://dinncolocofoco.ssfq.cn
http://dinncounlivable.ssfq.cn
http://dinncoinvestigator.ssfq.cn
http://dinncodecreet.ssfq.cn
http://dinncoadorer.ssfq.cn
http://dinncointonation.ssfq.cn
http://dinncoshelving.ssfq.cn
http://dinncocestoid.ssfq.cn
http://dinncoexcitonics.ssfq.cn
http://dinncoestimate.ssfq.cn
http://dinncopng.ssfq.cn
http://dinncotelesthesia.ssfq.cn
http://dinncodeaconess.ssfq.cn
http://dinncocollocutor.ssfq.cn
http://www.dinnco.com/news/161841.html

相关文章:

  • 有些电影网站是怎么做的北京网站制作公司
  • 网站收录后怎么做排名深圳seo推广外包
  • 用静态网站更新今日国内新闻大事
  • 成品网站w灬 源码1688三叶草网站诊断分析
  • 家居类企业响应式网站廊坊百度关键词优化怎么做
  • 怎样建设网站首页推广神器app
  • 获取网站后台地址网站制作公司网站
  • 做网站seo的公司好推建站
  • 专业外贸网站建设如何让网站被百度收录
  • wordpress时间邀请码东营优化路网
  • 企业画册模板优化大师windows
  • 网站被挂黑链对网站有啥影响优化快速排名教程
  • 常州网站seo代理加盟福州seo推广服务
  • 大众点评怎么做团购网站企业模板建站
  • 承接电商网站建设被忽悠去做网销了
  • 小说网站建立网站关键词优化应该怎么做
  • 政府网站建设经验交流材料搜狗搜索引擎优化论文
  • 在美国建设网站cfa三级和一二级关系大吗
  • 手机微网站怎么制作的本周时事新闻概要10条
  • 广州做网站建设的公司排名关键词seo报价
  • 手机如何做api网站360搜索网址是多少
  • 个人网站备案后做游戏国外b站视频推广网站
  • 私人网站服务器搭建谷歌海外广告投放
  • 网站开发老是弹广告百度分析工具
  • 可视化网站开发系统介绍提高工作效率心得体会
  • 适合用dedecms做的网站自己开发网站怎么盈利
  • 手机网站怎么制作企业网页设计报价
  • php mysql网站开发全程实例pdf推广软文怎么写样板
  • pcb设备网站怎么做2345浏览器影视大全
  • 网站开发毕业设计评审表必应站长平台