在代码中定位静态变量的最简单方法?
我的盘子里有一个错误,用于在我们的库之一中查找和重写静态变量,该变量占用了我们应用程序的启动时间。我不熟悉库代码库,并要求良好的启发式/技术/grep 命令/等。这会减轻我识别所述静态变量位置的任务吗?
(PS,我已经在代码库中搜索static
;不用说,这是一个冗长的结果。)
更新:错误报告只是指出“库 XYZ 在静态初始化时需要 N 毫秒”;我没有关于静态变量的更多信息。我没有分析日志,但我会看看是否可以从错误报告者那里获取它们。
I have a bug on my plate to locate and rewrite a static variable in one of our libraries that is taking up launch time in our application. I am not familiar with the library code base and am asking for good heuristics/techniques/grep commands/etc. that would ease my task in identifying the location of said static variable?
(P.S. I'm already searching the code base for static
; needless to say it's a verbose result.)
Update: The bug report simply states "library XYZ takes N ms at static initialization"; I do not have any more information about the static variable than that. I don't have the profiling logs but I'll see if I can get them from the bug reporter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试首先执行 nm -aC并通过静态和全局变量 grep (IIRC 它们应该以 B/b 或 T/t 为前缀),然后查找源代码中的那些变量。它可能会缩小干草堆的范围。
You could try to do a
nm -aC <libname>
first and grep by the static and global vars (IIRC they should be prefixed with a B/b or a T/t), then look for those vars in the source code. It may narrow down the haystack a little.