Replies: 10 comments 54 replies
-
Clangd wasn't really designed with this use case in mind, but one way of achieving this that seems relatively low effort is to write a script that talks to clangd over the Language Server Protocol to query some information and then presents it in whatever way you want (e.g. printing the results to the command line). For an example of this written in python, have a look at https://github.com/simark/ls-interact/blob/master/test_clangd.py. (This file exercises the "go to definition" request, but there's no reason you couldn't do something similar for other requests like "find references" or "call hierarchy".) |
Beta Was this translation helpful? Give feedback.
-
@HighCommander4 Thanks! Where can I find a list of all possible requests available? |
Beta Was this translation helpful? Give feedback.
-
@HighCommander4 Thanks! I will look into this. I am planning to use |
Beta Was this translation helpful? Give feedback.
-
@HighCommander4 I ended up reusing the code that you pointed me to. I have been able to get the setup working for my project (Linux kernel). So I have added
Let me know if you have any thoughts on this. |
Beta Was this translation helpful? Give feedback.
-
@HighCommander4 I have a clarifying question about
Let me know if I am missing anything in making these calls. Currently, I use a combination of ctags and cscope to get the lock and unlock calls for this lock which is one of the goals for the analysis but since I have decided to move to clangd which seems more accurate I want to port this feature as well. |
Beta Was this translation helpful? Give feedback.
-
@HighCommander4 This is happening for
I have implemented the same way I did outgoingCalls. Will checking out this PR fix it? |
Beta Was this translation helpful? Give feedback.
-
Incoming calls is similar to outgoing calls in that it depends on clangd's index for results in other files, so the hypothesis from the previous comment (that clangd does not have the time to index the project) applies here as well.
No, this fix only affects the issue of |
Beta Was this translation helpful? Give feedback.
-
@HighCommander4 I need some suggestion on something I am thinking of implementing and wanted to check if its even possible. So I want to generate a mapping of all the locks in the linux kernel with the data structure they are associated with. For example: https://elixir.bootlin.com/linux/v6.1/source/include/net/af_unix.h#L55, in this I want to get to point where I know However, there are times when the lock name is generic like the one in example I have given. So I was hoping to get the data structure by statically analyzing the function body that acquires the lock from the traces I have like this one: https://elixir.bootlin.com/linux/v6.1/source/net/unix/af_unix.c#L472. I was hoping to get a similar children structure for functions as well but it is not generated in the |
Beta Was this translation helpful? Give feedback.
-
@HighCommander4 I will try it. Thanks! |
Beta Was this translation helpful? Give feedback.
-
@HighCommander4 Can you please confirm if the For context, I made a call to
And I was hoping to use the location returned in |
Beta Was this translation helpful? Give feedback.
-
Hi,
Can I invoke clangd from the command line? I am working on a static analyzer and was wondering if I can use it like cscope from the command line. I have been using cscope but it has some limitations. For example, for making a function call graph from a start symbol cscope fails to work for certain functions with complex definitions such as (https://elixir.bootlin.com/linux/v6.1/source/drivers/tty/tty_io.c#L957 ) and (https://elixir.bootlin.com/linux/v6.1/source/kernel/cgroup/cgroup.c#L6565). I have looking for a capability similar to
cscope -dL2 <function symbol>
that lists all the function calls made from the passed function symbol.Any help/insight into this will be appreciated. Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions