Callgrind parser: Fixed associating file names with symbols and detection of root nodes #466
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces several small improvements to updating the current file name for the Callgrind parser:
cfn
) is within an inlined code block, it should use file names provided byfi
orfe
keys.fn
key is present, the parser should set the current file name to the value provided in the previousfl
key (such reset is also applied in KCacheGrind: link to code.fn
should be stored separately so that it is not overwritten later by newfl
calls.Those small modifications improve detection of root nodes. Before the PR, the same function could have several files associated with it - when
fi
/fe
are not taken into account, the file name for the current callee is taken from the lastfl
orcfi
call, which is later added tochildMap
inthis.childrenTotalWeights
instead of the actual function with its file name. After this, only one of the two representations of the same symbol get deleted fromrootNodes
.Without the improvement, we can observe detached call stacks for such "orphaned" functions. With the improvement, the functions have properly provided names, which leads to better generation of the call graph.
Some examples before and after applying the commit from the PR (the marked calls are for the same function):
Example 1 (callgrind file)
Example 2
Before:
![second-before-fix](https://private-user-images.githubusercontent.com/46489721/309109791-090968b5-af6a-4279-9e7e-2c6fa78b46c0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU5NjYyODcsIm5iZiI6MTcyNTk2NTk4NywicGF0aCI6Ii80NjQ4OTcyMS8zMDkxMDk3OTEtMDkwOTY4YjUtYWY2YS00Mjc5LTllN2UtMmM2ZmE3OGI0NmMwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEwVDEwNTk0N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYxNTc2YjVlOTc4YWZiOTllMDEwMGEyMmNlMWVmYjYyZmJjNGJkZTIwZDdlNmViNDEyZTEzYTE2MTAwOTc0YTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.jcVG9qjwmKdXKokICvNIxUZ16j8bBXAGFEaUyaqoBGU)
After:
![second-after-fix](https://private-user-images.githubusercontent.com/46489721/309109832-61c3abf3-6f77-4bb5-a879-67a61a7e3d60.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU5NjYyODcsIm5iZiI6MTcyNTk2NTk4NywicGF0aCI6Ii80NjQ4OTcyMS8zMDkxMDk4MzItNjFjM2FiZjMtNmY3Ny00YmI1LWE4NzktNjdhNjFhN2UzZDYwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEwVDEwNTk0N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI4NmM4ODUzNmIwZGZjNjRlYjUzMTVhYmZhNGIyNTYzOTRiYWEzZDk5YzkzYTk5NTM4NDg2M2IwZmJhMWVjMzgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.SX4A0QDdEvBXKqBNOzHGrteksCjm7V8dNKn0GZoXzDo)
Example 3
This fixes #465