Re: unable to find function definition
On 27 April 2016 at 07:05, John de la Garza wrote: > On Tue, Apr 26, 2016 at 02:00:02PM +0530, Jay Aurabind wrote: >> On 20 April 2016 at 12:56, Cihangir Akturk wrote: >> > On Wed, Apr 20, 2016 at 06:17:38AM +, 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 ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: unable to find function definition
Thank you all for replies. sure these are helping a lot. On Wed 27 Apr, 2016 8:35 am Jay Aurabind, wrote: > On 27 April 2016 at 07:05, John de la Garza wrote: > > On Tue, Apr 26, 2016 at 02:00:02PM +0530, Jay Aurabind wrote: > >> On 20 April 2016 at 12:56, Cihangir Akturk wrote: > >> > On Wed, Apr 20, 2016 at 06:17:38AM +, 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 > ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: unable to find function definition
On Tue, Apr 26, 2016 at 02:00:02PM +0530, Jay Aurabind wrote: > On 20 April 2016 at 12:56, Cihangir Akturk wrote: > > On Wed, Apr 20, 2016 at 06:17:38AM +, 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. ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: unable to find function definition
On Tue, Apr 26, 2016 at 11:24:43AM -0400, valdis.kletni...@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 signature.asc Description: PGP signature ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: unable to find function definition
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...) pgpsiSWGQqzKT.pgp Description: PGP signature ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: unable to find function definition
Am 2016-04-26 14:56, schrieb Jay Aurabind: > On 26 April 2016 at 16:15, Silvan Jegen 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 ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: unable to find function definition
On 26 April 2016 at 16:15, Silvan Jegen 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 ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: unable to find function definition
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 ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Contributing to Kernel Networking stack
Shraddha kamat writes: > I have strong desire to contribute to kernel networking stack. What is the > most effective way to do some pretty significant changes (bug fixes, > feature addition) in less time. By providing high quality patches which improve Linux and require minimal maintainer efforts to apply. It's as simple as that :) A few key words: test, explain, listen I'd also suggest starting simple, sending tested bug fixes obviously improving the code. Significant improvements, like e.g. adding features, might be difficult to start with. It's good to be known for quality work first. And there will always be a question on how to implement more complex changes. You should expect several rounds back to the drawing board for each such patch set. Having some experience and "gut feeling" will reduce the number. Which is necessary, since you might otherwise end up with noone bothering to review after a few cycles. That puts all the load on the maintainer. Which is not good. But if you have something to offer and the ability to take feedback, then anything is possible. Yes, and of course: READ the available docs in Documentation/Submit* Bjørn ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: unable to find function definition
Ctags can help. Ctags -R on the entire source. On 26 Apr 2016 2:19 p.m., "Jay Aurabind" wrote: > On 20 April 2016 at 12:56, Cihangir Akturk wrote: > > On Wed, Apr 20, 2016 at 06:17:38AM +, 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@kernelnewbies.org > > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > > > -- > > Thanks and Regards, > Aurabindo J > > ___ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: unable to find function definition
On 20 April 2016 at 12:56, Cihangir Akturk wrote: > On Wed, Apr 20, 2016 at 06:17:38AM +, 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@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies -- Thanks and Regards, Aurabindo J ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies