Vs2013在Linux开发中的应用(16): 修改调试器参数
快乐虾
http://blog.csdn.net/lights_joy/
欢迎转载,但请保留作者信息
仿照debugger_local_windows.xml的写法,修改名称和ID:
<?xml version="1.0"encoding="utf-8"?>
<!--Copyright, Microsoft Corporation, All rights reserved.-->
<Rule Name="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>
<DataSource Persistence="UserFile"/>
</Rule.DataSource>
<StringProperty Name="LocalDebuggerCommand" DisplayName="命令" Description="要执行的调试命令。" F1Keyword="VC.Project.IVCLocalDebugPageObject.Command">
<StringProperty.ValueEditors>
<ValueEditor EditorType="DefaultFindFullPathPropertyEditor" DisplayName="<regsvr32.exe>">
<ValueEditor.Metadata>
<NameValuePair Name="Exename"Value="regsvr32.exe"/>
</ValueEditor.Metadata>
</ValueEditor>
<ValueEditor EditorType="DefaultStringPropertyEditor" DisplayName="<编辑...>"/>
<ValueEditor EditorType="DefaultFilePropertyEditor" DisplayName="<浏览...>"/>
</StringProperty.ValueEditors>
</StringProperty>
</EnumProperty>
</Rule>
在IDE界面上可以看到我们自定义的调试器:
但此时按F5,VS并不会调用我们的调试器:
查下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:
<LocalGPUDebuggerTargetType Condition="‘$(GPUDebuggerTargetType)‘== ‘‘">{F4453496-1DB8-47F8-A7D5-31EBDDC2EC96}</LocalGPUDebuggerTargetType>
<RemoteGPUDebuggerTargetType Condition="‘$(GPUDebuggerTargetType)‘== ‘‘">{F4453496-1DB8-47F8-A7D5-31EBDDC2EC96}</RemoteGPUDebuggerTargetType>
这里的{F4453496-1DB8-47F8-A7D5-31EBDDC2EC96}就是预先注册的一个调试器:
我们将这里的GUID替换为自己的调试器的GUID:
<PropertyGroup>
<DebuggerType>GpuOnly</DebuggerType>
<LocalGPUDebuggerTargetType Condition="‘$(GPUDebuggerTargetType)‘== ‘‘">{9F2571B6-5567-43D2-8510-BFB85D559120}</LocalGPUDebuggerTargetType>
<RemoteGPUDebuggerTargetType Condition="‘$(GPUDebuggerTargetType)‘== ‘‘">{9F2571B6-5567-43D2-8510-BFB85D559120}</RemoteGPUDebuggerTargetType>
</PropertyGroup>
再将调试启动选项配置为:
再按F5启动调试,果然VS正确调用了我们的调试器!!!
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。