All of lore.kernel.org
 help / color / mirror / Atom feed
* How to browse the code
@ 2017-04-11 19:17 Code Soldier1
  2017-04-11 20:13 ` Mandeep Sandhu
  2017-04-13  2:23 ` Aruna Hewapathirane
  0 siblings, 2 replies; 10+ messages in thread
From: Code Soldier1 @ 2017-04-11 19:17 UTC (permalink / raw)
  To: kernelnewbies

Folks,

Can you tell me how to effectively browse linux kernel code. I am
familiar with lxr etc but they do not do what I want or atleast I do
not know how to.

I am looking for something that can list all the places that a certain
field of a certain structure is used. For example, sk_buff has a field
called destructor, but so do many other data structures. How do I
search for places where just the destructor field of sk_buff.

Thanks a lot.

-- 
CS1

^ permalink raw reply	[flat|nested] 10+ messages in thread

* How to browse the code
  2017-04-11 19:17 How to browse the code Code Soldier1
@ 2017-04-11 20:13 ` Mandeep Sandhu
  2017-04-11 23:56   ` manty kuma
       [not found]   ` <CABGNeczyadNCKYjLwWoK8N3o9dJdseUrAYCwFPx16DFr2Je7ng@mail.gmail.com>
  2017-04-13  2:23 ` Aruna Hewapathirane
  1 sibling, 2 replies; 10+ messages in thread
From: Mandeep Sandhu @ 2017-04-11 20:13 UTC (permalink / raw)
  To: kernelnewbies

>
>
> I am looking for something that can list all the places that a certain
> field of a certain structure is used. For example, sk_buff has a field
> called destructor, but so do many other data structures. How do I
> search for places where just the destructor field of sk_buff.
>

I think lxr has an identifier & free-text search (powered by google). If
that doesn't do it for you, you can go "old school" and try cscope maybe?

HTH,
-mandeep



>
> Thanks a lot.
>
> --
> CS1
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170411/f2dfe79f/attachment.html 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* How to browse the code
  2017-04-11 20:13 ` Mandeep Sandhu
@ 2017-04-11 23:56   ` manty kuma
       [not found]     ` <CABGNecz-3SU=yfPQEJKM_uLd3-7Opn01S30ymOidpGF3cJY23Q@mail.gmail.com>
       [not found]   ` <CABGNeczyadNCKYjLwWoK8N3o9dJdseUrAYCwFPx16DFr2Je7ng@mail.gmail.com>
  1 sibling, 1 reply; 10+ messages in thread
From: manty kuma @ 2017-04-11 23:56 UTC (permalink / raw)
  To: kernelnewbies

I like Opengrok. It is insanely fast in giving search results. However it
takes sometime to setup and you need to index it before the first use.

If you are ok with browsing someold kernels, then you can use this link
http://androidxref.com/kernel_3.18/ which is maintained privately.

If you want to use opengrok on more recent linux releases, you may have to
set it up yourself.

On Wed, Apr 12, 2017 at 5:13 AM, Mandeep Sandhu <mandeepsandhu.chd@gmail.com
> wrote:

>
>> I am looking for something that can list all the places that a certain
>> field of a certain structure is used. For example, sk_buff has a field
>> called destructor, but so do many other data structures. How do I
>> search for places where just the destructor field of sk_buff.
>>
>
> I think lxr has an identifier & free-text search (powered by google). If
> that doesn't do it for you, you can go "old school" and try cscope maybe?
>
> HTH,
> -mandeep
>
>
>
>>
>> Thanks a lot.
>>
>> --
>> CS1
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170412/b3fc54eb/attachment.html 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* How to browse the code
       [not found]   ` <CABGNeczyadNCKYjLwWoK8N3o9dJdseUrAYCwFPx16DFr2Je7ng@mail.gmail.com>
@ 2017-04-12 21:28     ` Mandeep Sandhu
       [not found]       ` <CABGNecxf3RnZH-kJ2VbC5JPuj=0Ka-1GPBA2x5R_tYyHLLm5EQ@mail.gmail.com>
  0 siblings, 1 reply; 10+ messages in thread
From: Mandeep Sandhu @ 2017-04-12 21:28 UTC (permalink / raw)
  To: kernelnewbies

On Wed, Apr 12, 2017 at 2:25 PM, Code Soldier1 <codesoldier1@gmail.com>
wrote:

> Thanks. This does not completely solve my issue. I am looking for
> something that can associate a field name with the structure.
>

Well, you can search for a field's use using free-text search, then looks
at the line of code to figure out what struct it's part of, no? :)

-mandeep



>
> On Tue, Apr 11, 2017 at 1:13 PM, Mandeep Sandhu
> <mandeepsandhu.chd@gmail.com> wrote:
> >>
> >> I am looking for something that can list all the places that a certain
> >> field of a certain structure is used. For example, sk_buff has a field
> >> called destructor, but so do many other data structures. How do I
> >> search for places where just the destructor field of sk_buff.
> >
> >
> > I think lxr has an identifier & free-text search (powered by google). If
> > that doesn't do it for you, you can go "old school" and try cscope maybe?
> >
> > HTH,
> > -mandeep
> >
> >
> >>
> >>
> >> Thanks a lot.
> >>
> >> --
> >> CS1
> >>
> >> _______________________________________________
> >> Kernelnewbies mailing list
> >> Kernelnewbies at kernelnewbies.org
> >> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >
> >
>
>
>
> --
> CS1
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170412/cc01bc89/attachment.html 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* How to browse the code
       [not found]         ` <CAC+QLdTbDM9kTxE96ErcrHNMCoEhNbV1LKU+xcWaxj+j_DP1aA@mail.gmail.com>
@ 2017-04-12 21:47           ` Mandeep Sandhu
  0 siblings, 0 replies; 10+ messages in thread
From: Mandeep Sandhu @ 2017-04-12 21:47 UTC (permalink / raw)
  To: kernelnewbies

On Wed, Apr 12, 2017 at 2:46 PM, Mandeep Sandhu <mandeepsandhu.chd@gmail.com
> wrote:

> On Wed, Apr 12, 2017 at 2:41 PM, Code Soldier1 <codesoldier1@gmail.com>
> wrote:
>
>> Yes that is possible but it is very time consuming. Let's say I get
>> 500 hits ? Try searching for destructor in linux kernel code. I am
>> only interested in the one that is defined in sk_buff.
>>
>
> Look at cscope & ctags for such queries. Both tools will list all
> instances where the said identifier is declared. If a field is defined in
> multiple structs, you will get multiple results from which you have to sift
> through (it will still be less than free-text search that you'd do on lxr
> though).
>
> Also, please reply to the list (and not to me directly). Others on this
> list might have better suggestions.
>

(and I myself forgot to CC the list! :P)

-mandeep


> HTH,
> -mandeep
>
>
>
>>
>> On Wed, Apr 12, 2017 at 2:28 PM, Mandeep Sandhu
>> <mandeepsandhu.chd@gmail.com> wrote:
>> > On Wed, Apr 12, 2017 at 2:25 PM, Code Soldier1 <codesoldier1@gmail.com>
>> > wrote:
>> >>
>> >> Thanks. This does not completely solve my issue. I am looking for
>> >> something that can associate a field name with the structure.
>> >
>> >
>> > Well, you can search for a field's use using free-text search, then
>> looks at
>> > the line of code to figure out what struct it's part of, no? :)
>> >
>> > -mandeep
>> >
>> >
>> >>
>> >>
>> >> On Tue, Apr 11, 2017 at 1:13 PM, Mandeep Sandhu
>> >> <mandeepsandhu.chd@gmail.com> wrote:
>> >> >>
>> >> >> I am looking for something that can list all the places that a
>> certain
>> >> >> field of a certain structure is used. For example, sk_buff has a
>> field
>> >> >> called destructor, but so do many other data structures. How do I
>> >> >> search for places where just the destructor field of sk_buff.
>> >> >
>> >> >
>> >> > I think lxr has an identifier & free-text search (powered by
>> google). If
>> >> > that doesn't do it for you, you can go "old school" and try cscope
>> >> > maybe?
>> >> >
>> >> > HTH,
>> >> > -mandeep
>> >> >
>> >> >
>> >> >>
>> >> >>
>> >> >> Thanks a lot.
>> >> >>
>> >> >> --
>> >> >> CS1
>> >> >>
>> >> >> _______________________________________________
>> >> >> Kernelnewbies mailing list
>> >> >> Kernelnewbies at kernelnewbies.org
>> >> >> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> CS1
>> >
>> >
>>
>>
>>
>> --
>> CS1
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170412/33340fc1/attachment-0001.html 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* How to browse the code
  2017-04-11 19:17 How to browse the code Code Soldier1
  2017-04-11 20:13 ` Mandeep Sandhu
@ 2017-04-13  2:23 ` Aruna Hewapathirane
  1 sibling, 0 replies; 10+ messages in thread
From: Aruna Hewapathirane @ 2017-04-13  2:23 UTC (permalink / raw)
  To: kernelnewbies

> On Tue, Apr 11, 2017 at 3:17 PM, Code Soldier1 <codesoldier1@gmail.com>
wrote:
> Folks,

> Can you tell me how to effectively browse linux kernel code. I am
> familiar with lxr etc but they do not do what I want or atleast I do
> not know how to.

> I am looking for something that can list all the places that a certain
> field of a certain structure is used. For example, sk_buff has a field
> called destructor, but so do many other data structures. How do I
> search for places where just the destructor field of sk_buff.

> Thanks a lot.

Ask yourself *how* is the destructor invoked ? You can find *how* here: SKB
socket accounting <http://vger.kernel.org/%7Edavem/skb_sk.html>

So now if you run:
find . -name '*.c' | xargs grep -r -F "skb->destructor"

you will have what you are looking for :)

Hope this helps and this will help: http://vger.kernel.org/~davem/skb.html

<http://vger.kernel.org/%7Edavem/skb_sk.html>
Aruna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170412/b27e9de9/attachment.html 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* How to browse the code
       [not found]     ` <CABGNecz-3SU=yfPQEJKM_uLd3-7Opn01S30ymOidpGF3cJY23Q@mail.gmail.com>
@ 2017-04-13 10:39       ` manty kuma
  2017-04-13 11:41         ` Daniel.
  0 siblings, 1 reply; 10+ messages in thread
From: manty kuma @ 2017-04-13 10:39 UTC (permalink / raw)
  To: kernelnewbies

Here you can see where sk_buff structure is delared.
http://androidxref.com/kernel_3.18/xref/include/linux/skbuff.h#506

May be you want to get familiar on how to use opengroks interface by seeing
some youtube video or some online documents...

Whatever you want to do wrt to source code browsing, this can do it for you
very quickly.

On Thu, Apr 13, 2017 at 6:24 AM, Code Soldier1 <codesoldier1@gmail.com>
wrote:

> Thanks a lot. I am still not able to lookup structures, such as
> sk_buff and where does it's fields get set/used.
>
> On Tue, Apr 11, 2017 at 4:56 PM, manty kuma <mantykuma@gmail.com> wrote:
> > I like Opengrok. It is insanely fast in giving search results. However it
> > takes sometime to setup and you need to index it before the first use.
> >
> > If you are ok with browsing someold kernels, then you can use this link
> > http://androidxref.com/kernel_3.18/ which is maintained privately.
> >
> > If you want to use opengrok on more recent linux releases, you may have
> to
> > set it up yourself.
> >
> > On Wed, Apr 12, 2017 at 5:13 AM, Mandeep Sandhu
> > <mandeepsandhu.chd@gmail.com> wrote:
> >>>
> >>>
> >>> I am looking for something that can list all the places that a certain
> >>> field of a certain structure is used. For example, sk_buff has a field
> >>> called destructor, but so do many other data structures. How do I
> >>> search for places where just the destructor field of sk_buff.
> >>
> >>
> >> I think lxr has an identifier & free-text search (powered by google). If
> >> that doesn't do it for you, you can go "old school" and try cscope
> maybe?
> >>
> >> HTH,
> >> -mandeep
> >>
> >>
> >>>
> >>>
> >>> Thanks a lot.
> >>>
> >>> --
> >>> CS1
> >>>
> >>> _______________________________________________
> >>> Kernelnewbies mailing list
> >>> Kernelnewbies at kernelnewbies.org
> >>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >>
> >>
> >>
> >> _______________________________________________
> >> Kernelnewbies mailing list
> >> Kernelnewbies at kernelnewbies.org
> >> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
> >>
> >
>
>
>
> --
> CS1
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170413/b49782ab/attachment.html 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* How to browse the code
  2017-04-13 10:39       ` manty kuma
@ 2017-04-13 11:41         ` Daniel.
  2017-04-13 11:50           ` Quentin Lambert
  2017-04-13 14:22           ` valdis.kletnieks at vt.edu
  0 siblings, 2 replies; 10+ messages in thread
From: Daniel. @ 2017-04-13 11:41 UTC (permalink / raw)
  To: kernelnewbies

ctags + cscope + vim

The Makefile has targets for indexing the kernel.. Sometimes "find -exec
grep" helps... I will take a look in opengrok

Em 13/04/2017 7:40 AM, "manty kuma" <mantykuma@gmail.com> escreveu:

> Here you can see where sk_buff structure is delared.
> http://androidxref.com/kernel_3.18/xref/include/linux/skbuff.h#506
>
> May be you want to get familiar on how to use opengroks interface by
> seeing some youtube video or some online documents...
>
> Whatever you want to do wrt to source code browsing, this can do it for
> you very quickly.
>
> On Thu, Apr 13, 2017 at 6:24 AM, Code Soldier1 <codesoldier1@gmail.com>
> wrote:
>
>> Thanks a lot. I am still not able to lookup structures, such as
>> sk_buff and where does it's fields get set/used.
>>
>> On Tue, Apr 11, 2017 at 4:56 PM, manty kuma <mantykuma@gmail.com> wrote:
>> > I like Opengrok. It is insanely fast in giving search results. However
>> it
>> > takes sometime to setup and you need to index it before the first use.
>> >
>> > If you are ok with browsing someold kernels, then you can use this link
>> > http://androidxref.com/kernel_3.18/ which is maintained privately.
>> >
>> > If you want to use opengrok on more recent linux releases, you may have
>> to
>> > set it up yourself.
>> >
>> > On Wed, Apr 12, 2017 at 5:13 AM, Mandeep Sandhu
>> > <mandeepsandhu.chd@gmail.com> wrote:
>> >>>
>> >>>
>> >>> I am looking for something that can list all the places that a certain
>> >>> field of a certain structure is used. For example, sk_buff has a field
>> >>> called destructor, but so do many other data structures. How do I
>> >>> search for places where just the destructor field of sk_buff.
>> >>
>> >>
>> >> I think lxr has an identifier & free-text search (powered by google).
>> If
>> >> that doesn't do it for you, you can go "old school" and try cscope
>> maybe?
>> >>
>> >> HTH,
>> >> -mandeep
>> >>
>> >>
>> >>>
>> >>>
>> >>> Thanks a lot.
>> >>>
>> >>> --
>> >>> CS1
>> >>>
>> >>> _______________________________________________
>> >>> Kernelnewbies mailing list
>> >>> Kernelnewbies at kernelnewbies.org
>> >>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >> Kernelnewbies mailing list
>> >> Kernelnewbies at kernelnewbies.org
>> >> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>> >>
>> >
>>
>>
>>
>> --
>> CS1
>>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170413/e37fe8b3/attachment-0001.html 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* How to browse the code
  2017-04-13 11:41         ` Daniel.
@ 2017-04-13 11:50           ` Quentin Lambert
  2017-04-13 14:22           ` valdis.kletnieks at vt.edu
  1 sibling, 0 replies; 10+ messages in thread
From: Quentin Lambert @ 2017-04-13 11:50 UTC (permalink / raw)
  To: kernelnewbies

Something else you could look at is Coccinelle.
http://coccinelle.lip6.fr/

The tool can be used to find very specific pattern in
the code. For instance specific structure field that are
used without initialization.

It takes some learning but the tool is very powerful.
You can also check here for the basics:
https://kernelnewbies.org/JuliaLawall
http://btrlinux.inria.fr/coccinelle/

If you have any questions Julia(the main developer) is
very active on the mailling list:

cocci at systeme.lip6.fr

Quentin

^ permalink raw reply	[flat|nested] 10+ messages in thread

* How to browse the code
  2017-04-13 11:41         ` Daniel.
  2017-04-13 11:50           ` Quentin Lambert
@ 2017-04-13 14:22           ` valdis.kletnieks at vt.edu
  1 sibling, 0 replies; 10+ messages in thread
From: valdis.kletnieks at vt.edu @ 2017-04-13 14:22 UTC (permalink / raw)
  To: kernelnewbies

On Thu, 13 Apr 2017 08:41:18 -0300, "Daniel." said:

> The Makefile has targets for indexing the kernel.. Sometimes "find -exec
> grep" helps... I will take a look in opengrok

find |xargs grep.   Will run a lot faster because it runs one grep for several
hundred files, rather than one per file.  For bonus points, if you have
a git tree, 'find *' at the top level will run faster than 'find .', because
* will glob into something that doesn't incude .git so no traversal into
that section of the source tree.

git grep   works too, if you have a git tree like any serious kernel hacker.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 484 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170413/cca42aa0/attachment.bin 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-04-13 14:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11 19:17 How to browse the code Code Soldier1
2017-04-11 20:13 ` Mandeep Sandhu
2017-04-11 23:56   ` manty kuma
     [not found]     ` <CABGNecz-3SU=yfPQEJKM_uLd3-7Opn01S30ymOidpGF3cJY23Q@mail.gmail.com>
2017-04-13 10:39       ` manty kuma
2017-04-13 11:41         ` Daniel.
2017-04-13 11:50           ` Quentin Lambert
2017-04-13 14:22           ` valdis.kletnieks at vt.edu
     [not found]   ` <CABGNeczyadNCKYjLwWoK8N3o9dJdseUrAYCwFPx16DFr2Je7ng@mail.gmail.com>
2017-04-12 21:28     ` Mandeep Sandhu
     [not found]       ` <CABGNecxf3RnZH-kJ2VbC5JPuj=0Ka-1GPBA2x5R_tYyHLLm5EQ@mail.gmail.com>
     [not found]         ` <CAC+QLdTbDM9kTxE96ErcrHNMCoEhNbV1LKU+xcWaxj+j_DP1aA@mail.gmail.com>
2017-04-12 21:47           ` Mandeep Sandhu
2017-04-13  2:23 ` Aruna Hewapathirane

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.