如何在大型代码库中找到特定的功能?

发布于 2024-10-07 04:00:14 字数 1431 浏览 0 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

谁的年少不轻狂 2024-10-14 04:00:14

对于此类问题,没有一种万能的方法。但对于这个,我会尝试这些:

  • 如果有任何与该操作相关的唯一消息,则 grep 该字符串的所有源文件。这种技术的一个常见陷阱是消息可能是由应用程序内的各个部分组装而成的,因此 grep 查找唯一的短语(甚至单个单词)来识别消息的来源通常很有帮助。找到文本后,查找引用通常需要更多文本搜索。

  • 从易于查找的点跟踪执行情况,例如命令处理和调度循环。我会寻找 Tab 键情况并跟踪它的引导位置。

  • 查看源代码目录和文件名以获取提示。软件通常是合理构建的,优秀的工程师以合理的方式进行划分和征服。

There is no one size fits all approach to this sort of problem. But for this one I would try these:

  • If there are any unique messages associated with the operation, grep all the source files for that string. A common pitfall of this technique is that messages might be assembled from pieces within the application, so it is often helpful to grep for a unique short phrase—or even a single word—to identify the source of the message. Once the text is found, then finding what references it often requires more text searches.

  • Trace execution from an easy-to-find point, like the command processing and dispatch loop. I'd look for a Tab key case and follow where it leads.

  • Look at source code directory and filenames for hints. Software is often constructed rationally, with good engineers dividing and conquering in a sensible way.

单调的奢华 2024-10-14 04:00:14

测试覆盖率工具是实现此目的的好方法。他们告诉您应用程序的哪一部分
通过测试进行练习。

检测应用程序以收集测试覆盖率。执行您关心的功能。记录执行的内容。执行类似的操作,但与您想要的功能不同。记录下来。取覆盖范围的设定差值。 diff 选择涉及感兴趣功能的代码,排除类似功能所共有的代码。

A test coverage tool is a good way to do this. They tell you what part of an application
is exercised by a test.

Instrument the application to collect test coverage. Execute the functionality you care about. Record what is executed. Execute something similar, but not the same as the functionality you want. Record this. Take the set difference over the coverage. The diff selects code involved in the functionality of interest, excluding code which is common to similar functionality.

誰ツ都不明白 2024-10-14 04:00:14

询问 Chromium 团队。他们不会给出分数或青铜像素,但他们绝对是提出此类问题的权威和正确的人。

Ask the Chromium team. They don't give points or bronze pixels but they're definitely the authority and right people to ask this sort of questions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文