chanhx / crabviz

🦀 A LSP-based interative call graph generator
Apache License 2.0
674 stars 22 forks source link

bug: doesn't work for some function #26

Closed lucky9-cyou closed 6 months ago

lucky9-cyou commented 6 months ago

The crabviz doesn't work for some function, like finish_task in following image: image

chanhx commented 6 months ago

Please check about incoming calls of Task::update_task_status_result and Resource::finish_task to see if finish_task is there. (right click on the function name, select “Show Call Hierarchy” on the context menu, and then switch to show incoming calls.)

lucky9-cyou commented 6 months ago

when i open finish_task call graph, it will show following result: image The call graph is right, but why didn't it appear in previous image?

chanhx commented 6 months ago

Crabviz fetches just incoming calls when generating call graphs for selected files. While generating call graphs for selected functions, Crabviz fetches both incoming calls and outgoing calls.

I guess maybe those two calls are returned in outgoing calls, but not in incoming calls.

So, please help check about call hierarchies of these functions, show incoming calls of Task::update_task_status_result and Resource::finish_task, and outgoing calls of finish_task.

image
lucky9-cyou commented 6 months ago

The outgoing calls of finish_task are as follows: image The incomming calls of Task::update_task_status_result is as follows: image The incoming calls of Resource::finish_task is as follows: image

lucky9-cyou commented 6 months ago

Crabviz fetches just incoming calls when generating call graphs for selected files. While generating call graphs for selected functions, Crabviz fetches both incoming calls and outgoing calls.

I guess maybe those two calls are returned in outgoing calls, but not in incoming calls.

So, please help check about call hierarchies of these functions, show incoming calls of Task::update_task_status_result and Resource::finish_task, and outgoing calls of finish_task.

image

It might be possible to add some options, so that when generating a call graph for selected files, it fetches both incoming calls and outgoing calls.

chanhx commented 6 months ago

Thank you so much! The language server does return the calling relationships which were not drawn on the graph. Is this bug reproducible? If yes, then is the code open source? Or could you provide a minimal reproducible sample? Many thanks!

It might be possible to add some options, so that when generating a call graph for selected files, it fetches both incoming calls and outgoing calls.

There are cases that calls are returned in incoming calls but not in outgoing calls, and not vice-versa. So just fetching incoming calls should be enough.

lucky9-cyou commented 6 months ago

I try to generate a minimal reproducible sample, but it doesn't work. The call graph of finish_task will show. And when I delete other function in my project, the call graph of finish_task will also show. CleanShot 2024-02-26 at 23 59 57@2x CleanShot 2024-02-27 at 00 02 17@2x My code repo is private, but I can invite you as collaborators temporarily. CleanShot 2024-02-27 at 00 01 23@2x Thanks for your help very much.

chanhx commented 6 months ago

I greatly appreciate all your help!

chanhx commented 6 months ago

I just tested crabviz on your project, and I think it worked as expected. Here is the output graph.

service

All information is from the language server, so you should wait till the language server is ready before generating a call graph.

image
lucky9-cyou commented 6 months ago

This is very strange, my language server is already prepared. Could this possibly be related to the version of the toolchain or rust-analyzer? My toolchain version is 1.77.0 nightly, my rust-analyzer version is v0.3.1860.

lucky9-cyou commented 6 months ago

when i try it in another computer with 1.78.0 nightly, it still doesn't show call graph of finish_task: CleanShot 2024-02-27 at 14 01 29@2x

chanhx commented 6 months ago

Same RA version here, and toolchain version is 1.78.0-nightly (fc3800f65 2024-02-26), no issues.

Please check the call hierarchies again, if the results are as expected, then run crabviz again to generate a new call graph.

lucky9-cyou commented 6 months ago

I still get the wrong results, and I'm not quite sure why that is. Anyway, thank you for your patient help and the outstanding project.