I am trying to modify few existing c-functions in my project, and add a line of code at the beginning of each function using python. But I am unable to obtain the first line inside a function. What I have tried: -- using the gcc-addr2line utility to convert the absolute start address of function into the corresponding line inside c-code. However it doesn't always return the first line(in case the first operation is a conditional execution, it returns the line where first statement inside condition executes).
-- also tried using regular expression to identify the start of function.
(for ex: void\s*_function__name_\s*\(.*\)\s*{
). Doesn't return what I need. Also I am not very experienced with this.
I do not have trouble finding the function definition, although I am not able to find the line where the first statement inside c-function exists.