首页 > 代码库 > Vs2013在Linux开发中的应用(16): 修改调试器参数

Vs2013在Linux开发中的应用(16): 修改调试器参数

快乐虾

http://blog.csdn.net/lights_joy/

欢迎转载,但请保留作者信息


仿照debugger_local_windows.xml的写法,修改名称和ID


<?xmlversion="1.0"encoding="utf-8"?>


<!--Copyright, Microsoft Corporation, All rights reserved.-->


<RuleName="9F2571B6-5567-43D2-8510-BFB85D559120"DisplayName="远程 gdb 调试器"PageTemplate="debugger"Description="远程 gdb 调试器选项 ssh"xmlns:sys="clr-namespace:System;assembly=mscorlib"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns="http://schemas.microsoft.com/build/2009/properties">


 


 <Rule.DataSource>


   <DataSourcePersistence="UserFile"/>


 </Rule.DataSource>


 


 <StringPropertyName="LocalDebuggerCommand"DisplayName="命令"Description="要执行的调试命令。"F1Keyword="VC.Project.IVCLocalDebugPageObject.Command">


   <StringProperty.ValueEditors>


     <ValueEditorEditorType="DefaultFindFullPathPropertyEditor"DisplayName="&lt;regsvr32.exe&gt;">


       <ValueEditor.Metadata>


         <NameValuePairName="Exename"Value="regsvr32.exe"/>


       </ValueEditor.Metadata>


     </ValueEditor>


     <ValueEditorEditorType="DefaultStringPropertyEditor"DisplayName="&lt;编辑...&gt;"/>


     <ValueEditorEditorType="DefaultFilePropertyEditor"DisplayName="&lt;浏览...&gt;"/>


   </StringProperty.ValueEditors>


 </StringProperty>


 


 </EnumProperty>


</Rule>


IDE界面上可以看到我们自定义的调试器:


但此时按F5VS并不会调用我们的调试器:


查下MSDN关于启动调试有这样一段话:


Programmatically, when the userfirst presses F5, Visual Studio‘s debug package calls the project package(which is associated with the type of program being launched) through theDebugLaunch method, which in turn fills out a VsDebugTargetInfo2 structure with the solution‘s active project debugsettings. This structure is passed back to the debug package through a call tothe LaunchDebugTargets2 method. The debug package then instantiates the sessiondebug manager (SDM), which launches the program being debugged and any associateddebug engines.


 


One of the arguments passed tothe SDM is the GUID of the DE to be used to launch the program.


 


If the DE GUID is not GUID_NULL,the SDM co-creates the DE, and then calls itsIDebugEngineLaunch2::LaunchSuspended method to launch the program. For example,if a program is written in native code, thenIDebugEngineLaunch2::LaunchSuspended will probably call CreateProcess andResumeThread (Win32 functions) to run the program.


也就是说,IDE会先调用VC Package中的IVsDebuggableProjectCfg.DebugLaunch方法,在VC实现的这个方法中填充VsDebugTargetInfo2结构体,然后初始化SDM。而VC的填充过程是我们无法干预的,即使我们添加了自己的调试器参数,VC似乎也使用不上。


观察MSBUILD目录下的文件,发现有个地方出现了一个调试器的GUID


   <LocalGPUDebuggerTargetTypeCondition="‘$(GPUDebuggerTargetType)‘== ‘‘">{F4453496-1DB8-47F8-A7D5-31EBDDC2EC96}</LocalGPUDebuggerTargetType>


   <RemoteGPUDebuggerTargetTypeCondition="‘$(GPUDebuggerTargetType)‘== ‘‘">{F4453496-1DB8-47F8-A7D5-31EBDDC2EC96}</RemoteGPUDebuggerTargetType>


这里的{F4453496-1DB8-47F8-A7D5-31EBDDC2EC96}就是预先注册的一个调试器:


我们将这里的GUID替换为自己的调试器的GUID


 <PropertyGroup>


   <DebuggerType>GpuOnly</DebuggerType>


   <LocalGPUDebuggerTargetTypeCondition="‘$(GPUDebuggerTargetType)‘== ‘‘">{9F2571B6-5567-43D2-8510-BFB85D559120}</LocalGPUDebuggerTargetType>


   <RemoteGPUDebuggerTargetTypeCondition="‘$(GPUDebuggerTargetType)‘== ‘‘">{9F2571B6-5567-43D2-8510-BFB85D559120}</RemoteGPUDebuggerTargetType>


 </PropertyGroup>


再将调试启动选项配置为:


再按F5启动调试,果然VS正确调用了我们的调试器!!!







Vs2013在Linux开发中的应用(16): 修改调试器参数