您使用什么工具在 Linux 上开发 C++ 应用程序?

2022-01-20 00:00:00 linux gdb c++ eclipse valgrind

我在 Linux 环境中开发 C++ 应用程序.我每天使用的工具包括带有 CDT 插件的 Eclipse、gdb 和 valgrind.
其他人使用什么工具?Linux 上是否有任何东西可以与 Microsoft Visual Studio 的流畅性相媲美?

I develop C++ applications in a Linux environment. The tools I use every day include Eclipse with the CDT plugin, gdb and valgrind.
What tools do other people use? Is there anything out there for Linux that rivals the slickness of Microsoft Visual Studio?

推荐答案

我用了一堆终端窗口.我在有趣的源文件上运行 vim,在另一个文件上运行 make 和 g++ 以用于编译器错误或用于运行时错误的 gdb 会话.如果我需要帮助查找定义,我会运行 cscope 并使用 vim 的 cscope 支持来跳转.

I use a bunch of terminal windows. I have vim running on interesting source files, make and g++ output on another for compiler errors or a gdb session for runtime errors. If I need help finding definitions I run cscope and use vim's cscope support to jump around.

Eclipse CDT 是我的第二选择.与 vim 相比,它很好,但体积庞大、笨拙且缓慢.

Eclipse CDT is my second choice. It's nice but huge, ungainly and slow compared to vim.

使用终端窗口和 vim 非常灵活,因为我不需要随身携带 400 MB 的 Java,我可以在任何地方使用 SSH 会话.

Using terminal windows and vim is very flexible because I do not need to carry 400 MB of Java around with me I can use SSH sessions from anywhere.

当我需要查找内存问题时,我会使用 valgrind.

I use valgrind when I need to find a memory issue.

我使用 strace 来观察我的软件在系统调用级别上执行的操作.这让我可以清理连续四次调用 time(0) 或对 poll() 或非阻塞 read 进行太多调用的非常愚蠢的代码() 或诸如在套接字上调用 read() 以一次读取 1 个字节.(那就是超级低效又懒惰!)

I use strace to watch what my software is doing on a system call level. This lets me clean up really stupid code that calls time(0) four times in a row or makes too many calls to poll() or non-blocking read() or things like calling read() on a socket to read 1 byte at a time. (That is super inefficient and lazy!)

我使用 objdump -d 来检查机器代码,尤其是对性能敏感的内部循环.这就是我发现字符串上的数组索引运算符与使用迭代器相比速度慢的原因.

I use objdump -d to inspect the machine code, especially for performance sensitive inner loops. That is how I find things like the slowness of the array index operator on strings compared to using iterators.

我使用 oprofile 尝试在优化的代码中查找热点,我发现它通常比 gprof 工作得更好一些,它可以执行诸如查找数据和指令缓存未命中之类的事情.这可以告诉您使用 GCC 的 __builtin_prefetch 在哪里删除一些有用的预取提示.我也尝试使用它来查找错误预测的热门分支,但无法让它为我工作.

I use oprofile to try to find hot spots in optimized code, I find that it often works a little better than gprof, and it can do things like look for data and instruction cache misses. That can show you where to drop some helpful prefetch hints using GCC's __builtin_prefetch. I tried to use it to find hot mis-predicted branches as well, but couldn't get that to work for me.

更新:我发现 perf 比 oprofile 更有效.至少在 Linux 上.学习使用 perf 并像我一样热爱它.

Update: I've found that perf works way better than oprofile. At least on Linux. Learn to use perf and love it as I do.

相关文章