yazoox
V2EX  ›  C++

大型代码库的浏览,学习,查找引用,符号跳转等等,用什么工具比较好? visual studio 顶不住啊......

  •  
  •   yazoox · Apr 6, 2021 · 8668 views
    This topic created in 2046 days ago, the information mentioned may be changed or developed.

    有一款老产品,c++写的代码,有十几二十年了吧。.vcproj 估计有几百个,代码行数没有上千万,几百万还是有的。源代码库拉下来,有几十 GB 吧......

    有时候,需要查看一下老代码,了解学习一下,某功能当初是怎么设计实现的(毕竟这么多年,当初写的人,不在公司了),现在的功能,需要按照或者参考以前的设计和实现。

    尝试过,建立一个 visual studio 的 solution,把所有的 projects 都添加进来,等 vs 的索引完毕,就能够跳转了,比如,go to definition or references,etc.。可是,这个时候,通常,vs (vs2019) 就“死机了”。

    目前做的是前端项目,也很大。查看代码,用 vscode,还行,顶得住。如果在远程的机器上,我就安装 neovim + coc + leaderF + ripgrep,也是可以正常使用的。

    但是,这个 c++的项目,不知道这个方法行不行。

    所以,来问问大家,有没有碰到过这样的情况,需要查看 /学习老的项目代码,该项目代码库又很庞大。怎么索引,代码跳转呢?谢谢。

    p.s. 现在在内部的 gitlab 上面直接搜索,效率太低了......

    p.s. 我的机器是至强的 32 核心,64G 内存, ssd 硬盘

    38 replies  •  2021-06-21 14:33:01 +08:00
    feelapi
    feelapi
    Apr 6, 2021
    1
    sourceinsight, 唯一选择。几千万行的代码库都没问题。
    borisz
    borisz
    Apr 6, 2021
    2
    sourceinsight + 1
    bfdh
    bfdh
    Apr 6, 2021
    3
    sourceinsight + 1
    zzz0xxx
    zzz0xxx
    Apr 6, 2021
    4
    opengork
    flgn88
    flgn88
    Apr 6, 2021 via iPhone
    5
    GitHub 网页版的索引能满足吗
    yazoox
    yazoox
    OP
    Apr 6, 2021
    6
    @feelapi
    @borisz
    @bfdh
    还别说,你们一提,我想起来了。多年以前,我做 c++项目的时候,还用过 source insight 。
    刚才去看了一眼,这么多年过去了,这产品,咋没有啥变化啊......
    zhongrs232
    zhongrs232
    Apr 6, 2021
    7
    @yazoox 更新到 source insight4.0 了,支持 utf-8 和 GBK 编码,对中文的支持更友好一些
    shylockhg
    shylockhg
    Apr 6, 2021
    8
    挺好奇全量编译一次要多久
    scinart
    scinart
    Apr 6, 2021
    9
    opengrok + 1
    yazoox
    yazoox
    OP
    Apr 6, 2021
    10
    @shylockhg
    一个半小时左右
    minami
    minami
    Apr 6, 2021❤️2
    11
    都说 sourceinsight,我说个 understand 吧,跨平台版的 sourceinsight
    justforlook44444
    justforlook44444
    Apr 6, 2021
    12
    source insight mac 上能用吗
    typetraits
    typetraits
    Apr 6, 2021
    13
    我看 Chromium 源码,git repo 35G 左右吧,代码 15G,我用 VSCode + vscode-clangd 扩展,利用 Chromium 里面提供的脚本生成 compile_commands.txt ,直接打开项目目录就可以,clangd 索引完成前每打开一个新文件需要等待几秒,索引完成之后跳转、查找关键字速度就都很快了
    elmagnificogg
    elmagnificogg
    Apr 6, 2021 via Android
    14
    source insight
    786375312123
    786375312123
    Apr 6, 2021
    15
    @yazoox 那这个项目也不大啊,我这里有三个编译时间都在一个半小时左右的项目。用 vs 基本都可以正常打开,调试。不过是工作站级别的机器
    xuanbg
    xuanbg
    Apr 6, 2021
    16
    从不抱着学习的目的去看大型代码库。屎山代码有什么好看的
    FrankHB
    FrankHB
    Apr 6, 2021
    17
    C 艹屎山还指望啥查找引用,记明白标识符直接开个 cmd rg 一把梭基本上都比 clangd 靠谱,更别说什么 VS 了……
    comi
    comi
    Apr 6, 2021
    18
    sourceinsight
    ch2
    ch2
    Apr 6, 2021 via iPhone
    19
    还是放弃那些功能比较实在
    domodomo
    domodomo
    Apr 7, 2021
    21
    source-insight+1,几年前常用
    很多 C 艹商业大型代码库里面的编码水平都不咋地,可以说又丑又烂,有些能运行起来都是奇迹
    seesky
    seesky
    Apr 7, 2021
    22
    要不考虑下 scitools understand,
    LANB0
    LANB0
    Apr 7, 2021
    23
    sourceinsight + 1
    pythonee
    pythonee
    Apr 7, 2021 via Android
    24
    source insights
    Mithril
    Mithril
    Apr 7, 2021
    25
    Visual Studio 这东西除非你是 SSD,不然就它那个 32bit 的 devenv,装几个插件打开个大型工程就直接炸了。一般项目太大就直接拆 sln 了,或者只加载必要的项目。
    如果只看代码的话其实不需要真的语义分析建立索引,只需要 token 能查到就行了。跳转不那么精准也能忍。opengrok 或者 sourcegraph 这种基本也就够了。
    52coder
    52coder
    Apr 7, 2021
    26
    sourceinsight + 1,转到 mac 后唯一不习惯的地方,渐渐开始用 clion
    52coder
    52coder
    Apr 7, 2021
    27
    想要一款跨平台的,目前感觉还是 sourceinsight 顺手
    ByteRan
    ByteRan
    Apr 7, 2021
    28
    @Mithril #25 LZ 的是至强的 32 核心,64G 内存, ssd 硬盘
    HangoX
    HangoX
    Apr 7, 2021
    29
    https://sourcegraph.com/github.com/square/okhttp 简单浏览都是用这个,网页版直接看
    JJFJJ
    JJFJJ
    Apr 7, 2021
    30
    曾经开发 VNDK,开发编译都是 ubuntu,虽然可以 wine 下安装 source insight 但是使用不是很好。最后的解决办法是:ubuntu 安装 samba,把工程目录共享给 windows 电脑使用,在 windows 上进行代码阅读编辑
    gxm44
    gxm44
    Apr 7, 2021
    31
    sourceinsight + 1
    zhusimaji
    zhusimaji
    Apr 7, 2021
    32
    sourceinsight 当年写固件的时候用的神器
    mxi1
    mxi1
    Apr 7, 2021 via Android
    33
    根据编译过程,生成 compdb,一般叫 compile_commnads.json
    mxi1
    mxi1
    Apr 7, 2021 via Android
    34
    不小心按到回车了,compdb 是很多 IDe 都支持的,比如 vs code,你可以上网搜搜怎么生成和使用
    binux
    binux
    Apr 7, 2021 via Android
    35
    @typetraits 直接 https://source.chromium.org/ 搜索它不香吗?
    macha
    macha
    Apr 7, 2021
    36
    只有 sourceinsight 一条路可走了。别的要么扛不住,要么不好用。
    sunbreak
    sunbreak
    Apr 8, 2021
    37
    @JJFJJ WSL 2 挺好用的
    asuraa
    asuraa
    Jun 21, 2021
    38
    只能 sourceinsight 了 别的都够呛
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4950 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 188ms · UTC 02:08 · PVG 10:08 · LAX 18:08 · JFK 21:08
    ♥ Do have faith in what you're doing.