I am not sure if this is possible or even makes sense: Assuming I have build with -g and I have, either in a C stub or in OCaml code, a value which is a closure/function. Can I somehow poll/extract the “location” (source code location) of that closure/function from the value?
The use case is, from code which operates on sequences of closures/functions, to log what is being called, without having to insert this logging in the actual underlying closures/functions.
Note that this will provide you with the location of the callsite, while the OP is more interested by the location of the function definition, if I understand correctly.