如何使用MonoDevelop调试MonoDevelop加载项? [英] How can I debug MonoDevelop add-ins with MonoDevelop?

查看:444
本文介绍了如何使用MonoDevelop调试MonoDevelop加载项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个话题说了一切。我不能在monodevelop网站或谷歌找到任何信息。



甚至添加 System.Diagnostics.Debugger.Break()并运行 mono --debug MonoDevelop.exe 似乎没有做任何事情。

解决方案

mono --debug 与调试器没有任何关系,它只是使Mono跟踪调试信息,以便它可以给你文件/行/ col信息在回溯。



System.Diagnostics.Debugger.Break()的行为取决于在您的Mono版本。 AFAIK在其基本形式中设置了一个硬断点,因此如果您的应用程序不在本机硬盘调试器中运行,则会简单崩溃。如果您的应用程序在Mono软件调试器(Mono 2.11或更高版本尚未发布)内运行,则会为软调试器设置一个软断点,并按预期工作。



启用插件调试的基本方法是在您的插件项目中设置一个自定义执行命令。打开项目选项,进入运行>自定义命令部分,为执行添加一个自定义命令。将可执行文件设置为MonoDevelop.exe,将工作目录设置为其包含的目录。这意味着当您运行/调试您的项目时,MD将实际执行该可执行文件,而不是直接执行您的项目。如果MonoDevelop.exe加载您的插件,那么您将能够设置断点,步骤等。



这里困难的部分是使MD加载您的插件。执行此操作的一种方法是让您的项目将加载项输出到MD搜索加载项的目录之一,但这在开发时是一件非常棘手的事情。一个更好的解决方案是使用未记录的环境变量MONODEVELOP_DEV_ADDINS来指定一个额外的目录,MD用于加载加载项。在MD中没有用于为自定义命令设置env vars的UI,但是在内部支持 - 您必须手动编辑csproj文件。



找到部分看起来像:

 < CustomCommands> 
< CustomCommands>
< Command type =Execute
command =.. \..\..\monodevelop\main\build\bin\MonoDevelop.exe
workingdir =.. \..\..\monodevelop\main\build\bin/>
< / CustomCommands>
< / CustomCommands>

并将其更改为:

 < CustomCommands> 
< CustomCommands>
< Command type =Execute
command =.. \..\..\monodevelop\main\build\bin\MonoDevelop.exe
workingdir =.. \..\..\monodevelop\main\build\bin>
< EnvironmentVariables>
< Variable name =MONODEVELOP_DEV_ADDINSvalue =$ {TargetDir}/>
< / EnvironmentVariables>
< / Command>
< / CustomCommands>
< / CustomCommands>

如果您想知道为什么< CustomCommands> 元素是两深的,这是一个已知的错误。


The topic says it all. I cannot find any information on the monodevelop site or through google.

Even adding System.Diagnostics.Debugger.Break() and running with mono --debug MonoDevelop.exe doesn't seem to do anything..

解决方案

mono --debug doesn't have anything to do with the debugger, it simply causes Mono to track debug information so it can give you file/line/col information in backtraces.

The behaviour of System.Diagnostics.Debugger.Break() depends on your Mono version. AFAIK in its basic form it sets a hard breakpoint, so if your app's not running in a native hard debugger it will simply crash. If your app is running inside the Mono Soft Debugger with Mono 2.11 or later (which has not yet been released), it will set a soft breakpoint for the soft debugger and work as expected.

The basic way to enable debugging of addins is to set a custom execution command in your addin project. Open 'Project Options', got to the 'Run>Custom Commands' section, add a custom command for 'Execute'. Set the executable to MonoDevelop.exe and the working directory to be its containing directory. This means that when you run/debug your project, MD will actually execute that executable instead of executing your project directly. If MonoDevelop.exe loads your addin, then you'll be able to set breakpoints, step, etc.

The difficult part here is making MD load your addin. One way to do this would be to have your project output the addin dll into one of the directories that MD searches for addins, but that's a very hacky thing to do at development time. A better solution is to use the undocumented environment variable MONODEVELOP_DEV_ADDINS to specify an additional directory from which for MD to load addins. There isn't a UI in MD for setting env vars for custom commands, but it is supported internally - you'll have to manually edit the csproj file.

Find the part that looks like:

<CustomCommands>
  <CustomCommands>
    <Command type="Execute"
      command="..\..\..\monodevelop\main\build\bin\MonoDevelop.exe"
      workingdir="..\..\..\monodevelop\main\build\bin" />
  </CustomCommands>
</CustomCommands>

And change it to:

<CustomCommands>
  <CustomCommands>
    <Command type="Execute"
      command="..\..\..\monodevelop\main\build\bin\MonoDevelop.exe"
      workingdir="..\..\..\monodevelop\main\build\bin">
      <EnvironmentVariables>
        <Variable name="MONODEVELOP_DEV_ADDINS" value="${TargetDir}" />
      </EnvironmentVariables>
    </Command>
  </CustomCommands>
</CustomCommands>

If you're wondering why the <CustomCommands> elements are two-deep, that a known bug.

这篇关于如何使用MonoDevelop调试MonoDevelop加载项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆