If you get 5-6 layers, you probably have an indicator that you should redesign. In the normal case, you would only have 1-2 transitions between managed/unmanaged code. If this native code uses a COM object written in C#, we get yet another transition, and so it can continue. We start from the bottom, where a C++ app makes a call into a C++/CLI managed DLL, the managed DLL in turn calls native code. Native code that calls managed code, which in turn calls native code again. COM, C++/CLI, Interop, and/or PInvoke can be used to mix the two worlds. A managed application, using some sort of interop/ pinvoke, is not pure. A truly managed application only contains managed code. When we talk about a mixed-mode callstack, we refer to a non pure managed application.
![pinnacle profiler creating your own pin pinnacle profiler creating your own pin](https://1jpev4f9y3o2up6ug39nhvwi-wpengine.netdna-ssl.com/wp-content/uploads/2018/01/Cooperstown-Die-Struck-ANTIQUE-BRONZE-TWO-CUTOUTS-1.png)
In this article we will instead explore a profiler API of the CLR runtime, called ICorProfiler. I could see function calls of the CLR library but my own code appeared camouflaged as some calls to a CLR function where my JITted code was being executed. A Mixed-Mode Stackwalk with IDebugClient Interface which was my first attempt to walk a mixed-mode callstack resulted in a partial success.
![pinnacle profiler creating your own pin pinnacle profiler creating your own pin](https://www.topbestalternatives.com/wp-content/previews/pinnacle-game-profiler-27005-2.jpg)
Neither a native profiler nor a CLR profiler run separately could pin-point the problem. The reason I started with this was the need to optimize a C++/C# application, which was slow at importing large data files.
Pinnacle profiler creating your own pin how to#
This is a continuation of an article where we learned how to traverse a mixed-mode (unmanaged/managed) application using IDebugInterface and IXCLRProcessData. In this article I will share some of the DOs and DONTs, limitations, and possibilities, links to resources, and things I have learned. Due to limited documentation, I had to learn some things the hard way.
![pinnacle profiler creating your own pin pinnacle profiler creating your own pin](https://www.enamelpins.com/blog/wp-content/uploads/2019/06/Enamel-Pins.jpg)
Are you interested in how profilers work and how to walk mixed-mode applications? We will explore the ICorProfiler interface for doing a mixed-mode stack walking.