0

I want to have A executed functions list. it will help me in debugging. one way is to create some code snippet which add the currently executing function name in the list and paste that in every function but its cumbersome as I have to do that for all the functions. So, is there anything that can ease my work?

example -

void function1()
{
 function2();
}
void function2()
{
 function3
}
void function3()
{
  // some other function call
}

Now, I want the list to have functions name arranged according to their execution order like this -- function3,function2,function1....

And I don't want to stop at function 3. The list should keep on population with the latest execution functions names.

  • Does this answer your question? [How do I get the calling method name and type using reflection?](https://stackoverflow.com/questions/3095696/how-do-i-get-the-calling-method-name-and-type-using-reflection) and [Get stacktrace inside c# method](https://stackoverflow.com/questions/37102450/get-stacktrace-inside-c-sharp-method) –  May 18 '21 at 16:44
  • @OlivierRogier Actually no, the issue is once the function call ends it gets removed from the stack. So, call stack doesn't keep the information retained to be fetched through code. – asta nigem May 18 '21 at 16:51
  • Do you mean you want to automatically add in a list all running methods from the process start like a debugger does? When each method begin like if you added `Trace.LogCurrentMethodEnter();` in each method? –  May 18 '21 at 16:55
  • yes, something like this so If I see any bug I would know which method would have caused that. – asta nigem May 18 '21 at 16:59
  • The debug stack trace will show where an error occurs. I am going to stick my neck out here and suggest that whatever reason you think you need this, there is almost certainly a better way to accomplish it. – Nicholas Hunter May 18 '21 at 17:00
  • Your request is very specific, thus there is no default implementation of that. You will have to add logging yourself. – JHBonarius May 18 '21 at 17:02
  • @JHBonarius ok, no issues . Thanks for the help guys. – asta nigem May 18 '21 at 17:04
  • Does this answer your question? [How to trace every method called](https://stackoverflow.com/questions/14862635/how-to-trace-every-method-called) and [How can I add a Trace() to every method call in C#?](https://stackoverflow.com/questions/559148/how-can-i-add-a-trace-to-every-method-call-in-c) and [Best way to record method calls to a file in C#/.NET?](https://stackoverflow.com/questions/6697303/best-way-to-record-method-calls-to-a-file-in-c-net) –  May 18 '21 at 17:04
  • [How to trace log method calls, including the parameter values](https://makolyte.com/how-to-trace-log-method-calls-including-the-parameter-values/) –  May 18 '21 at 17:05
  • @OlivierRogier maybe I need to check them and it would take some time. I think its safe to flag or should I delete myself. I am new so guide me a little – asta nigem May 18 '21 at 17:52

0 Answers0