Callgrind parser: Fixed associating file names with symbols and detection of root nodes#466
Open
glatosinski wants to merge 1 commit intojlfwong:mainfrom
Open
Conversation
…th functions When called function is within an inlined code block, it should use file names provided by 'fi' or 'fe' commands. Also, when 'fn' command is called, it sets the current file name to the value provided in the previous 'fl' call. Also, the file associated with 'fn' should be stored separately so that it is not overwritten by new 'fl' calls (Callgrind does not tell whether there can be multiple 'fl' calls without following 'fn' calls, and this should guard the parser from associating the wrong new file name with the previous 'fn' function). This modification fixes detached call stacks, which were created when one function has been called from inline block without the file source update, which led to duplicated entries, which were later not removed when determining root functions. Signed-off-by: Grzegorz Latosinski <glatosinski@antmicro.com>
20072c5 to
20bc6ce
Compare
Owner
|
Hi @glatosinski! Thanks for contributing this, and sorry for the long response time. Can you please add a minimal test that demonstrates the failure mode this PR fixes? Thanks! |
Author
|
Hi, ok, I will prepare a minimal test |
Contributor
|
Is this ever going to be merged, its very useful - happy to pull it into my fork in the meantime; cheers! |
Owner
|
Hi @alexmk92 This is just blocked on adding minimal test cases that demonstrate why this change is necessary |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 byfiorfekeys.fnkey is present, the parser should set the current file name to the value provided in the previousflkey (such reset is also applied in KCacheGrind: link to code.fnshould be stored separately so that it is not overwritten later by newflcalls.Those small modifications improve detection of root nodes. Before the PR, the same function could have several files associated with it - when
fi/feare not taken into account, the file name for the current callee is taken from the lastflorcficall, which is later added tochildMapinthis.childrenTotalWeightsinstead 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:

After:

Example 3
This fixes #465