* unable to find function definition
@ 2016-04-20 6:17 Nijam Haider
2016-04-20 7:26 ` Cihangir Akturk
0 siblings, 1 reply; 14+ messages in thread
From: Nijam Haider @ 2016-04-20 6:17 UTC (permalink / raw)
To: kernelnewbies
i was going through the code leds-gpio.c.
i found a function "platform_gpio_blink_set" declared under private data of
"gpio_led_data",and was trying to get through this function. But hardly i can
find any link to definition for the same anywhere.
Regards
Nijam
^ permalink raw reply [flat|nested] 14+ messages in thread
* unable to find function definition
2016-04-20 6:17 unable to find function definition Nijam Haider
@ 2016-04-20 7:26 ` Cihangir Akturk
2016-04-26 8:30 ` Jay Aurabind
0 siblings, 1 reply; 14+ messages in thread
From: Cihangir Akturk @ 2016-04-20 7:26 UTC (permalink / raw)
To: kernelnewbies
On Wed, Apr 20, 2016 at 06:17:38AM +0000, Nijam Haider wrote:
> i was going through the code leds-gpio.c.
> i found a function "platform_gpio_blink_set" declared under private data of
> "gpio_led_data",and was trying to get through this function. But hardly i can
> find any link to definition for the same anywhere.
Hi,
That is a function pointer, so you should search assignments to
that pointer. That way you can find the real function you are
looking for.
^ permalink raw reply [flat|nested] 14+ messages in thread
* unable to find function definition
2016-04-20 7:26 ` Cihangir Akturk
@ 2016-04-26 8:30 ` Jay Aurabind
2016-04-26 8:50 ` Gadre Nayan
2016-04-27 1:35 ` John de la Garza
0 siblings, 2 replies; 14+ messages in thread
From: Jay Aurabind @ 2016-04-26 8:30 UTC (permalink / raw)
To: kernelnewbies
On 20 April 2016 at 12:56, Cihangir Akturk <cakturk@gmail.com> wrote:
> On Wed, Apr 20, 2016 at 06:17:38AM +0000, Nijam Haider wrote:
>> i was going through the code leds-gpio.c.
>> i found a function "platform_gpio_blink_set" declared under private data of
>> "gpio_led_data",and was trying to get through this function. But hardly i can
>> find any link to definition for the same anywhere.
>
> Hi,
>
> That is a function pointer, so you should search assignments to
> that pointer. That way you can find the real function you are
> looking for.
I've spotted such usages in a lot of places, outside the kernel as
well. Just wanted know if there is a smarted way of finding the
assignments, like some tools or any other tips which people could use
to make life easier ?
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
--
Thanks and Regards,
Aurabindo J
^ permalink raw reply [flat|nested] 14+ messages in thread
* unable to find function definition
2016-04-26 8:30 ` Jay Aurabind
@ 2016-04-26 8:50 ` Gadre Nayan
2016-04-26 10:45 ` Silvan Jegen
2016-04-27 1:35 ` John de la Garza
1 sibling, 1 reply; 14+ messages in thread
From: Gadre Nayan @ 2016-04-26 8:50 UTC (permalink / raw)
To: kernelnewbies
Ctags can help. Ctags -R on the entire source.
On 26 Apr 2016 2:19 p.m., "Jay Aurabind" <jay.aurabind@gmail.com> wrote:
> On 20 April 2016 at 12:56, Cihangir Akturk <cakturk@gmail.com> wrote:
> > On Wed, Apr 20, 2016 at 06:17:38AM +0000, Nijam Haider wrote:
> >> i was going through the code leds-gpio.c.
> >> i found a function "platform_gpio_blink_set" declared under private
> data of
> >> "gpio_led_data",and was trying to get through this function. But hardly
> i can
> >> find any link to definition for the same anywhere.
> >
> > Hi,
> >
> > That is a function pointer, so you should search assignments to
> > that pointer. That way you can find the real function you are
> > looking for.
>
> I've spotted such usages in a lot of places, outside the kernel as
> well. Just wanted know if there is a smarted way of finding the
> assignments, like some tools or any other tips which people could use
> to make life easier ?
>
> >
> > _______________________________________________
> > Kernelnewbies mailing list
> > Kernelnewbies at kernelnewbies.org
> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
>
> --
>
> Thanks and Regards,
> Aurabindo J
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160426/02bff7d7/attachment.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* unable to find function definition
2016-04-26 8:50 ` Gadre Nayan
@ 2016-04-26 10:45 ` Silvan Jegen
2016-04-26 12:56 ` Jay Aurabind
2016-04-27 20:26 ` Jakub Sitnicki
0 siblings, 2 replies; 14+ messages in thread
From: Silvan Jegen @ 2016-04-26 10:45 UTC (permalink / raw)
To: kernelnewbies
Am 2016-04-26 10:50, schrieb Gadre Nayan:
> Ctags can help. Ctags -R on the entire source.
In the Kernel Makefile there is actually a target for this. It's called
either 'tags' or 'tag' so
make tags [or tag]
should create the ctag file for you.
Cheers,
Silvan
^ permalink raw reply [flat|nested] 14+ messages in thread
* unable to find function definition
2016-04-26 10:45 ` Silvan Jegen
@ 2016-04-26 12:56 ` Jay Aurabind
2016-04-26 13:31 ` Silvan Jegen
2016-04-27 20:26 ` Jakub Sitnicki
1 sibling, 1 reply; 14+ messages in thread
From: Jay Aurabind @ 2016-04-26 12:56 UTC (permalink / raw)
To: kernelnewbies
On 26 April 2016 at 16:15, Silvan Jegen <me@sillymon.ch> wrote:
> Am 2016-04-26 10:50, schrieb Gadre Nayan:
>>
>> Ctags can help. Ctags -R on the entire source.
>
>
> In the Kernel Makefile there is actually a target for this. It's called
> either 'tags' or 'tag' so
>
> make tags [or tag]
>
> should create the ctag file for you.
I use ctags with vim. Mostly it takes me to declaration of the
function pointer. Then i go grep for that function and look for its
assignment. I was wondering if there is some plugin or script which
can find assignments to such function pointers.
>
>
> Cheers,
>
> Silvan
>
--
Thanks and Regards,
Aurabindo J
^ permalink raw reply [flat|nested] 14+ messages in thread
* unable to find function definition
2016-04-26 12:56 ` Jay Aurabind
@ 2016-04-26 13:31 ` Silvan Jegen
2016-04-26 15:24 ` Valdis.Kletnieks at vt.edu
0 siblings, 1 reply; 14+ messages in thread
From: Silvan Jegen @ 2016-04-26 13:31 UTC (permalink / raw)
To: kernelnewbies
Am 2016-04-26 14:56, schrieb Jay Aurabind:
> On 26 April 2016 at 16:15, Silvan Jegen <me@sillymon.ch> wrote:
>> Am 2016-04-26 10:50, schrieb Gadre Nayan:
>>>
>>> Ctags can help. Ctags -R on the entire source.
>>
>>
>> In the Kernel Makefile there is actually a target for this. It's
>> called
>> either 'tags' or 'tag' so
>>
>> make tags [or tag]
>>
>> should create the ctag file for you.
>
> I use ctags with vim. Mostly it takes me to declaration of the
> function pointer. Then i go grep for that function and look for its
> assignment. I was wondering if there is some plugin or script which
> can find assignments to such function pointers.
A simple but naive approach would be a grep command like this.
grep "function_pointer =" `find . -iname '*.c' -o -iname '*.h'`
Cheers,
Silvan
^ permalink raw reply [flat|nested] 14+ messages in thread
* unable to find function definition
2016-04-26 13:31 ` Silvan Jegen
@ 2016-04-26 15:24 ` Valdis.Kletnieks at vt.edu
2016-04-26 15:33 ` Silvan Jegen
0 siblings, 1 reply; 14+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2016-04-26 15:24 UTC (permalink / raw)
To: kernelnewbies
On Tue, 26 Apr 2016 15:31:51 +0200, Silvan Jegen said:
> A simple but naive approach would be a grep command like this.
>
> grep "function_pointer =" `find . -iname '*.c' -o -iname '*.h'`
Two better ways:
grep -r "function_pointer =' [A-Za-z]*
find * -name '*.[ch]' | xargs grep 'function pointer ='
Hint 1: Globbing * rather than . is a win at the top level of the
kernel source, because * won't match .git, which is a gigabyte or so
of stuff that you don't want to grep through
Hint 2: You want -name rather than -iname because there shouldn't be any
*.C or *.H files in the tree, and avoiding case-insensitive matches is a bit
faster.
And another winner if you have a git tree (which of course you should):
git grep 'function_pointer ='
One gotcha is that in some places, the kernel does evil pre-processor
stuff like:
#define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
#define ATOMIC_LONG_PFX(x) atomic ## x
#endif
#define ATOMIC_LONG_READ_OP(mo) static inline long atomic_long_read##mo(const atomic_long_t *l) { ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; return (long)ATOMIC_LONG_PFX(_read##mo)(v); }
ATOMIC_LONG_READ_OP()
ATOMIC_LONG_READ_OP(_acquire)
(this example from include/asm-generic/atomic-long.h, but similar ## abuse
happens elsewhere as well...)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160426/6af6fd75/attachment-0001.bin
^ permalink raw reply [flat|nested] 14+ messages in thread
* unable to find function definition
2016-04-26 15:24 ` Valdis.Kletnieks at vt.edu
@ 2016-04-26 15:33 ` Silvan Jegen
0 siblings, 0 replies; 14+ messages in thread
From: Silvan Jegen @ 2016-04-26 15:33 UTC (permalink / raw)
To: kernelnewbies
On Tue, Apr 26, 2016 at 11:24:43AM -0400, Valdis.Kletnieks at vt.edu wrote:
> On Tue, 26 Apr 2016 15:31:51 +0200, Silvan Jegen said:
>
> > A simple but naive approach would be a grep command like this.
> >
> > grep "function_pointer =" `find . -iname '*.c' -o -iname '*.h'`
>
> Two better ways:
>
> grep -r "function_pointer =' [A-Za-z]*
>
> find * -name '*.[ch]' | xargs grep 'function pointer ='
>
> Hint 1: Globbing * rather than . is a win at the top level of the
> kernel source, because * won't match .git, which is a gigabyte or so
> of stuff that you don't want to grep through
Good idea!
There may also be cases where there is no space before the assignment so
using a regexp like this may be better.
grep 'function_pointer ?='
> Hint 2: You want -name rather than -iname because there shouldn't be any
> *.C or *.H files in the tree, and avoiding case-insensitive matches is a bit
> faster.
True, this was mostly muscle memory.
> And another winner if you have a git tree (which of course you should):
>
> git grep 'function_pointer ='
Looks useful but I hope they did not implement their own version of
grep...
> One gotcha is that in some places, the kernel does evil pre-processor
> stuff like:
>
> #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
> #define ATOMIC_LONG_PFX(x) atomic ## x
>
> #endif
>
> #define ATOMIC_LONG_READ_OP(mo) static inline long atomic_long_read##mo(const atomic_long_t *l) { ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; return (long)ATOMIC_LONG_PFX(_read##mo)(v); }
> ATOMIC_LONG_READ_OP()
> ATOMIC_LONG_READ_OP(_acquire)
>
> (this example from include/asm-generic/atomic-long.h, but similar ## abuse
> happens elsewhere as well...)
Yeah, I don't think there is much you can do about these cases...
Cheers,
Silvan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160426/ba81f255/attachment.bin
^ permalink raw reply [flat|nested] 14+ messages in thread
* unable to find function definition
2016-04-26 8:30 ` Jay Aurabind
2016-04-26 8:50 ` Gadre Nayan
@ 2016-04-27 1:35 ` John de la Garza
2016-04-27 3:05 ` Jay Aurabind
1 sibling, 1 reply; 14+ messages in thread
From: John de la Garza @ 2016-04-27 1:35 UTC (permalink / raw)
To: kernelnewbies
On Tue, Apr 26, 2016 at 02:00:02PM +0530, Jay Aurabind wrote:
> On 20 April 2016 at 12:56, Cihangir Akturk <cakturk@gmail.com> wrote:
> > On Wed, Apr 20, 2016 at 06:17:38AM +0000, Nijam Haider wrote:
> >> i was going through the code leds-gpio.c.
> >> i found a function "platform_gpio_blink_set" declared under private data of
> >> "gpio_led_data",and was trying to get through this function. But hardly i can
> >> find any link to definition for the same anywhere.
> >
> > Hi,
> >
> > That is a function pointer, so you should search assignments to
> > that pointer. That way you can find the real function you are
> > looking for.
>
> I've spotted such usages in a lot of places, outside the kernel as
> well. Just wanted know if there is a smarted way of finding the
> assignments, like some tools or any other tips which people could use
> to make life easier ?
I've been able to print the address of the functions (once it has
been assigned), then check the System.map for the function name.
^ permalink raw reply [flat|nested] 14+ messages in thread
* unable to find function definition
2016-04-27 1:35 ` John de la Garza
@ 2016-04-27 3:05 ` Jay Aurabind
2016-04-27 3:10 ` nizam haider
0 siblings, 1 reply; 14+ messages in thread
From: Jay Aurabind @ 2016-04-27 3:05 UTC (permalink / raw)
To: kernelnewbies
On 27 April 2016 at 07:05, John de la Garza <john@jjdev.com> wrote:
> On Tue, Apr 26, 2016 at 02:00:02PM +0530, Jay Aurabind wrote:
>> On 20 April 2016 at 12:56, Cihangir Akturk <cakturk@gmail.com> wrote:
>> > On Wed, Apr 20, 2016 at 06:17:38AM +0000, Nijam Haider wrote:
>> >> i was going through the code leds-gpio.c.
>> >> i found a function "platform_gpio_blink_set" declared under private data of
>> >> "gpio_led_data",and was trying to get through this function. But hardly i can
>> >> find any link to definition for the same anywhere.
>> >
>> > Hi,
>> >
>> > That is a function pointer, so you should search assignments to
>> > that pointer. That way you can find the real function you are
>> > looking for.
>>
>> I've spotted such usages in a lot of places, outside the kernel as
>> well. Just wanted know if there is a smarted way of finding the
>> assignments, like some tools or any other tips which people could use
>> to make life easier ?
>
> I've been able to print the address of the functions (once it has
> been assigned), then check the System.map for the function name.
Thank you all for the smart answers!
--
Thanks and Regards,
Aurabindo J
^ permalink raw reply [flat|nested] 14+ messages in thread
* unable to find function definition
2016-04-27 3:05 ` Jay Aurabind
@ 2016-04-27 3:10 ` nizam haider
0 siblings, 0 replies; 14+ messages in thread
From: nizam haider @ 2016-04-27 3:10 UTC (permalink / raw)
To: kernelnewbies
Thank you all for replies.
sure these are helping a lot.
On Wed 27 Apr, 2016 8:35 am Jay Aurabind, <jay.aurabind@gmail.com> wrote:
> On 27 April 2016 at 07:05, John de la Garza <john@jjdev.com> wrote:
> > On Tue, Apr 26, 2016 at 02:00:02PM +0530, Jay Aurabind wrote:
> >> On 20 April 2016 at 12:56, Cihangir Akturk <cakturk@gmail.com> wrote:
> >> > On Wed, Apr 20, 2016 at 06:17:38AM +0000, Nijam Haider wrote:
> >> >> i was going through the code leds-gpio.c.
> >> >> i found a function "platform_gpio_blink_set" declared under private
> data of
> >> >> "gpio_led_data",and was trying to get through this function. But
> hardly i can
> >> >> find any link to definition for the same anywhere.
> >> >
> >> > Hi,
> >> >
> >> > That is a function pointer, so you should search assignments to
> >> > that pointer. That way you can find the real function you are
> >> > looking for.
> >>
> >> I've spotted such usages in a lot of places, outside the kernel as
> >> well. Just wanted know if there is a smarted way of finding the
> >> assignments, like some tools or any other tips which people could use
> >> to make life easier ?
> >
> > I've been able to print the address of the functions (once it has
> > been assigned), then check the System.map for the function name.
>
> Thank you all for the smart answers!
>
> --
>
> Thanks and Regards,
> Aurabindo J
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160427/c03702ea/attachment.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* unable to find function definition
2016-04-26 10:45 ` Silvan Jegen
2016-04-26 12:56 ` Jay Aurabind
@ 2016-04-27 20:26 ` Jakub Sitnicki
2016-04-28 4:23 ` Anupam Kapoor
1 sibling, 1 reply; 14+ messages in thread
From: Jakub Sitnicki @ 2016-04-27 20:26 UTC (permalink / raw)
To: kernelnewbies
On Tue, Apr 26, 2016 at 12:45 PM CEST, Silvan Jegen <me@sillymon.ch> wrote:
> Am 2016-04-26 10:50, schrieb Gadre Nayan:
>> Ctags can help. Ctags -R on the entire source.
>
> In the Kernel Makefile there is actually a target for this. It's called
> either 'tags' or 'tag' so
>
> make tags [or tag]
>
> should create the ctag file for you.
An alternative would be to use cscope:
$ # build the index (will take a moment)
$ make cscope
$ # find all assignments to a symbol
$ cscope -d -L -9 platform_gpio_blink_set
drivers/leds/leds-gpio.c <global> 130 led_dat->platform_gpio_blink_set = blink_set;
$ # or find all occurrences of a symbol and grep for assignments
$ cscope -d -L -0 platform_gpio_blink_set | grep =
drivers/leds/leds-gpio.c <global> 130 led_dat->platform_gpio_blink_set = blink_set;
The latter, for some reason, runs faster for me.
-Jakub
^ permalink raw reply [flat|nested] 14+ messages in thread
* unable to find function definition
2016-04-27 20:26 ` Jakub Sitnicki
@ 2016-04-28 4:23 ` Anupam Kapoor
0 siblings, 0 replies; 14+ messages in thread
From: Anupam Kapoor @ 2016-04-28 4:23 UTC (permalink / raw)
To: kernelnewbies
>>>>> [2016-04-28T01:56:26+0530]: "Jakub Sitnicki" (jakub-sitnicki):
,----[ jakub-sitnicki ]
| An alternative would be to use cscope:
|
| $ # build the index (will take a moment)
| $ make cscope
`----
this ! cscope generally just works for way better than other 'manual'
mechanisms. since it builds inverse database as well (the -q option),
symbol lookups are pretty fast.
xcscope provides a seamless experience within emacs...
--
kind regards
anupam
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2016-04-28 4:23 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-20 6:17 unable to find function definition Nijam Haider
2016-04-20 7:26 ` Cihangir Akturk
2016-04-26 8:30 ` Jay Aurabind
2016-04-26 8:50 ` Gadre Nayan
2016-04-26 10:45 ` Silvan Jegen
2016-04-26 12:56 ` Jay Aurabind
2016-04-26 13:31 ` Silvan Jegen
2016-04-26 15:24 ` Valdis.Kletnieks at vt.edu
2016-04-26 15:33 ` Silvan Jegen
2016-04-27 20:26 ` Jakub Sitnicki
2016-04-28 4:23 ` Anupam Kapoor
2016-04-27 1:35 ` John de la Garza
2016-04-27 3:05 ` Jay Aurabind
2016-04-27 3:10 ` nizam haider
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.