In this case, feel free to create a pull request here. We'll see if that works.Īs I am not a native English speaker, it is very likely that you will find an error.
But be aware to see some ASM code ? Also I try to retrieve the line number from a stack frame. In one of the next article we are taking a look at FunctionEnter and FunctionLeave stuff. I hope you got a little insight into the process of event handling. I showed you some use cases and how you can handle them. Given a weird and senseless program with some nested calls I get this output: Please note that I added the callback not to the ProfilerCallback class because I did not succeed in passing a pointer to a member function into DoStackSnapshot. Not sure if this is considered to be best practice in C++ ?
I manipulated the pointer output to append the next frame to output plus a new line. To get more information about an event, utilize the instance of type ICorProfilerInfo.īool Utils :: GetClassNameByObjectId ( ObjectID objectId, char * output, ULONG outputLength ) But be sure that all of this has been done for easier understanding. You should be aware that I will not write the most performant code and you may encounter a lot of things that could be improved. I create an own class for the methods that retrieve more information about an event. Wouldn't it be nice if we could print the name of the exception? Let's do this. There we implemented the ExceptionThrown callback. Let's take the example project from the last lesson. So if you have questions, please ask and I'll try to answer them. I mean, I'm only calling some functions in a very stupid manner. To make your life easier, I will show you some use cases.
But maybe the whole process is documented somewhere in the. Unfortunately it is often not very obviously what kind of method you have to use. On the other hand, you have to call a few methods to get more information. This makes sense as passing more information to the callbacks will increase the overall CPU & RAM load. a FunctionId or a ClassId and such things. If you looked at several callback methods, you may have noticed, that often you get only an id. Do you remember the output? It was just exception thrown, which may be useful but surely it will be much more useful if the exception name would be printed. Until now we setup a simple profiler that is capable of logging every exception.