Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call graph tree is not shown where there is just one called function #1868

Open
vt-alt opened this issue Dec 27, 2023 · 4 comments
Open

Call graph tree is not shown where there is just one called function #1868

vt-alt opened this issue Dec 27, 2023 · 4 comments

Comments

@vt-alt
Copy link

vt-alt commented Dec 27, 2023

I hope I don't misunderstand usage, but call graph tree is not shown where there is just one called function, for example:

$ cat a.c
void foo() { }
void bar() { }
int main(int argc, char **argv)
{
        foo();
        foo();
        return 0;
}
$ gcc -g -o a a.c -pg && uftrace record ./a && uftrace graph
# Function Call Graph for 'a' (session: 7fc700108cc002f9)
========== FUNCTION CALL GRAPH ==========
# TOTAL TIME   FUNCTION
    0.507 us : (1) a
    0.507 us : (1) main
    0.093 us : (2) foo

But it's shown when there is 2 functions:

$ cat a.c
void foo() { }
void bar() { }
int main(int argc, char **argv)
{
        foo();
        bar();
        return 0;
}
$ gcc -g -o a a.c -pg && uftrace record ./a && uftrace graph
# Function Call Graph for 'a' (session: 5b92669dad7f9545)
========== FUNCTION CALL GRAPH ==========
# TOTAL TIME   FUNCTION
    0.965 us : (1) a
    0.965 us : (1) main
    0.126 us :  +-(1) foo
             :  |
    0.042 us :  +-(1) bar

@namhyung
Copy link
Owner

(2) foo means the function "foo" was called twice (from the same call path).

@vt-alt
Copy link
Author

vt-alt commented Dec 29, 2023

What I report is — it does not draw a line showing that it is called from the main and this is unlike of the graph where two different functions. What I would expect to see is:

# TOTAL TIME   FUNCTION
    0.965 us : (1) a
    0.965 us : (1) main
    0.126 us :  +-(2) foo

In current output it looks like foo is called after main not from main.

@vt-alt
Copy link
Author

vt-alt commented Dec 29, 2023

Thanks for explanation though. Now (I think) I understand that tailing branch is just not indented to the right side. And it's meant that there is one branch going downwards.

But that's a bit confusing (because there is no line downward). And looked like foo is called after main. But because we know that in our universe main cannot have following functions we can deduce this is a call from main.

Same logic does not work inside of main -- as foo and bar (in example 2) have different branches and not just drawn sequentially with implicit downward branch.

So while current representation is correct it's still harder to interpret because we cannot see downward lines (or their absence).

On every occurrence of branching now user should think "is this following function call or nested function call with downward branch?" Perhaps this is not what user should be additionally thinking when they already try to understand logic of inspected binary

@namhyung
Copy link
Owner

I know it can be confusing. But I decided to do it that way to reduce the indention level for the simple, single call cases. Otherwise it would become hard to read after some depth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants