Click here to Skip to main content
12,243,180 members (22,049 online)
Click here to Skip to main content

Stats

17.1K views
815 downloads
25 bookmarked
Posted

A Mixed-Mode Stackwalk with the IDebugClient Interface

, 22 Apr 2012 Ms-PL
A native stackwalk funtion like Stackwalk64 cannot handle mixed-mode stacks, since managed code does not use the stack in the same way as native code does. There is an API called IDebugClient, that does walk a mixed-mode stack correctly, which we will explore.
MixedModeStack_demo
CppCliApp.exe
CppCliApp.ilk
CppCliApp.pdb
DiagApp.exe
DiagApp.ilk
DiagApp.pdb
ManagedLib0.dll
ManagedLib0.pdb
MixedLib1.dll
MixedLib1.ilk
MixedLib1.pdb
MixedStackTraceLibrary.dll
MixedStackTraceLibrary.ilk
MixedStackTraceLibrary.pdb
StackTraceLibrary.dll
StackTraceLibrary.pdb
StackWalk64App.exe
StackWalk64App.ilk
StackWalk64App.pdb
MixedModeStack_src
SampleApps
CppCliApp
app.ico
CppCliApp.vcxproj.filters
CppCliApp.vcxproj.user
Debug
CppCliApp.Build.CppClean.log
CppCliApp.log
Debug
ManagedLib0
bin
Debug
Release
obj
Debug
TempPE
Properties
MixedLib1
app.ico
Debug
MixedLib1.Build.CppClean.log
MixedLib1.log
MixedLib1.vcxproj.filters
MixedLib1.vcxproj.user
MixedStackTraceLibrary
app.ico
Debug
MixedStackTraceLibrary.Build.CppClean.log
MixedStackTraceLibrary.log
MixedStackTraceLibrary.vcxproj.filters
MixedStackTraceLibrary.vcxproj.user
sdk
inc
lib
dbgeng.lib
dbghelp.lib
engextcpp.lib
StackTraceLibrary
bin
Debug
Release
obj
Debug
TempPE
Properties
StackwalkApps
Debug
DiagApp
app.ico
Debug
DiagApp.log
DiagApp.vcxproj.filters
DiagApp.vcxproj.user
sdk
inc
lib
dbgeng.lib
dbghelp.lib
engextcpp.lib
xclrdata
StackWalk64App
Debug
StackWalk64App.log
sdk
inc
lib
dbgeng.lib
dbghelp.lib
engextcpp.lib
StackWalk64App.vcxproj.filters
StackWalk64App.vcxproj.user
MICROSOFT SHARED SOURCE CLI, C#, AND JSCRIPT LICENSE 

This License governs use of the accompanying Software, and your use of
the Software constitutes acceptance of this license.   

You may use this Software for any non-commercial purpose, subject to
the restrictions in this license. Some purposes which can be
non-commercial are teaching, academic research, and personal
experimentation.   You may also distribute this Software with books or
other teaching materials, or publish the Software on websites, that
are intended to teach the use of the Software. 

You may not use or distribute this Software or any derivative works in
any form for commercial purposes.  Examples of commercial purposes
would be running business operations, licensing, leasing, or selling
the Software, or distributing the Software for use with commercial
products. 

You may modify this Software and distribute the modified Software for
non-commercial purposes, however, you may not grant rights to the
Software or derivative works that are broader than those provided by
this License.   For example, you may not distribute modifications of
the Software under terms that would permit commercial use, or under
terms that purport to require the Software or derivative works to be
sublicensed to others. 

You may use any information in intangible form that you remember after
accessing the Software.  However, this right does not grant you a
license to any of Microsoft's copyrights or patents for anything you
might create using such information. 

In return, we simply require that you agree:

1.	Not to remove any copyright or other notices from the Software.

2.	That if you distribute the Software in source or object form,
          you will include a verbatim copy of this license. 

3.	That if you distribute derivative works of the Software in
          source code form you do so only under a license that
          includes all of the provisions of this License, and if you
          distribute derivative works of the Software solely in object
          form you do so only under a license that complies with this
          License.  
	
4.	That if you have modified the Software or created derivative
          works, and distribute such modifications or derivative
          works, you will cause the modified files to carry prominent
          notices so that recipients know that they are not receiving
          the original Software.  Such notices must state: (i) that
          you have changed the Software; and (ii) the date of any
          changes. 

5.	THAT THE SOFTWARE COMES "AS IS", WITH NO WARRANTIES.  THIS
          MEANS NO EXPRESS, IMPLIED OR STATUTORY WARRANTY, INCLUDING
          WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY OR FITNESS
          FOR A PARTICULAR PURPOSE OR ANY WARRANTY OF TITLE OR
          NON-INFRINGEMENT.  ALSO, YOU MUST PASS THIS DISCLAIMER ON
          WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS. 

6.	THAT MICROSOFT WILL NOT BE LIABLE FOR ANY DAMAGES RELATED TO
          THE SOFTWARE OR THIS LICENSE, INCLUDING DIRECT, INDIRECT,
          SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE MAXIMUM
          EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS
          BASED ON.  ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY
          ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE
          WORKS. 

7.	That if you sue anyone over patents that you think may apply
          to the Software or anyone's use of the Software, your
          license to the Software ends automatically. 

8.	That your rights under the License end automatically if you
          breach it in any way. 

9.	Microsoft reserves all rights not expressly granted to you in
          this license. 

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

Mattias Högström
Architect Visma Software AB
Sweden Sweden
Mattias works at Visma, a leading Nordic ERP solution provider. He has good knowledge in C++/.Net development, test tool development, and debugging. His great passion is memory dump analysis. He likes giving talks and courses.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160426.1 | Last Updated 22 Apr 2012
Article Copyright 2012 by Mattias Högström
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid