This seems to be a limitation of LXR, the engine behind lxr.free-electrons.com: it doesn't differentiate forward declarations (struct task_struct;
) from full definitions.
My method of choice is always by looking at file names, since it's usually obvious where a given structure definition should be (e.g., in your case, it's related to scheduling, so sched.h
in the file list should have it). However, I understand that one might be unfamiliar with the Linux kernel source code, and thus have no idea where to go.
The best way to find a structure definition in the Linux source tree is by searching for literally:
struct struct_name {
Since a strict coding style is followed by Linux contributors, the structure definitions should always take this form.
LXR has a freetext search to cope with its limitations. Unfortunately, it uses Google Search, which ignores most punctuations. GitHub seems to ignore them too, as well as Google Code.
My advice is to clone the mainline Linux Git repository:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
and then grep
(or, better, ag
) what you're looking for in the include
directory:
grep -rin 'struct task_struct {' include
or, using ag
:
ag 'struct task_struct {' include
You will see the files that define this structure (usually only one) in the results, and then you may go to the appropriate file on LXR and continue your research.
Here's a shell function to go to the appropriate LXR page using the first result:
lxr() {
chromium "http://lxr.free-electrons.com/source/$(grep -rl "$1" include | head -1)"
}
or, using ag
:
lxr() {
chromium "http://lxr.free-electrons.com/source/$(ag -l "$1" include | head -1)"
}
Replace chromium
with whatever your favorite browser command is. Use it like this:
lxr 'struct task_struct {'
Hope it helps.