That strikes me as a very very risky proposition. You can never guarantee how many times we will opt to run a function in a SQL statement. For example
SQL> create table t as select * from dba_objects
2 where object_id is not null;
SQL> create or replace
2 function my_function(p_param int) return number as
3 x int;
5 x := 1/0;
6 return p_param+1;
So obviously if I call this function, I will get an error because I'm dividing by zero, thus
SQL> select object_id, my_function(object_id)
2 from t;
select object_id, my_function(object_id)
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "MCDONAC.MY_FUNCTION", line 4
But what about this one then?
SQL> select count(*)
3 ( select object_id, my_function(object_id)
4 from t
The database is free to re-arrange the SQL in any way it chooses as long as we observe the correctness of results.
You could go digging around into dbms_utility.format_call_stack, but I'd strongly suggest a rethink of your approach.