Optimize ctags calls
It's expensive to call ctags once per source file identified in the DWARF data. This patch: - Calls ctags on all the source files from a single ELF at once. '-L -' is used to avoid risk of hitting OS limits with a huge command line. - Similarly, reads the output a line at a time to avoid holding a huge amount of ctags output at once in memory. - Recovers the file paths from the lines output by ctags, which it always prints in '-x' mode, even for a single input file. (Note that this will break on paths with embedded spaces. This limitation was present in the original through the use of shell=True, so it is assumed to be acceptable here - consider json output if it becomes a problem). - Renames 'workspace' to 'local_workspace' in FunctionLineNumbers for consistency with the rest of the program. (For programming convenience, the cache of results is changed to key by local file name - i.e. with local_workspace prepended - rather than the caller's file name, but is otherwise unchanged). Note the apparent loss of specificity in the error message for ctags failure, which no longer outputs each file name. This was probably intended to report problems with particular missing, corrupted, or unreadable files. In practice, Exuberant ctags returns success in these cases, even for a single file on the command line. The only way I found to provoke a nonzero exit code was to pass a bad command line argument. The point is that ctags will either fail for every file or none of them, so testing each exit code is not effective. If file-specific errors need to be reported, consider capturing and logging lines of stderr. Change-Id: I89c80a8ac181d6bc01351c0f4922941829a1ed5c
Loading
Please register or sign in to comment