首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用Mono Soft Debugger远程调试,因为出现'debugger-agent: DWP握手失败‘错误

无法使用Mono Soft Debugger远程调试,因为出现'debugger-agent: DWP握手失败‘错误
EN

Stack Overflow用户
提问于 2010-09-13 22:09:54
回答 1查看 2.6K关注 0票数 2

我已经在我的应用程序中嵌入了mono。该应用程序是支持插件的控制台应用程序。插件是.NET程序集。所有这些都运行得很好,但我想要调试它们。要在我的C代码中启用调试,我需要:

代码语言:javascript
复制
mono_set_dirs (ASSEMBLIES_DIR_NAME, ASSEMBLIES_DIR_NAME);
assembly_add_to_bundle(API_ASSEMBLY);

soft_debug = getenv("MYAPP_SOFT_DEBUG");
if (soft_debug != NULL) {
   char *options; 
   options = malloc(17 + strlen(soft_debug));
   sprintf(options, "--debugger-agent=%s", soft_debug); 

   mono_jit_parse_options (1, &options); 
   free (options); 

   mono_debug_init (MONO_DEBUG_FORMAT_MONO);
}

domain = JIT_INIT();

...

上面的代码初始化了mono运行时,这是我为启用调试所做的全部工作。为了能够在MonoDevelop端进行调试,我创建了一个插件并实现了必要的类。启动调试的那个是从RemoteSoftDebuggerSession派生的。下面是我的OnRun方法:

代码语言:javascript
复制
protected override void OnRun (DebuggerStartInfo startInfo)
{
   var dsi = (MyAppDebuggerStartInfo) startInfo;
   var procStartInfo = new ProcessStartInfo(@"C:\MyApp\myapp.exe") {                
    UseShellExecute = false,
    RedirectStandardOutput = true,
    RedirectStandardError = true,
    WorkingDirectory = @"C:\MyApp",
    Arguments = dsi.AppName
   };

   procStartInfo.EnvironmentVariables.Add("MYAPP_SOFT_DEBUG",                       
      String.Format("transport=dt_socket,address={0}:{1}", 
         dsi.Address, dsi.DebugPort));

   this._myapp = Process.Start(procStartInfo);
   this._runner.EnableRaisingEvents = true;
   base.ConnectOutput(this._runner.StandardOutput, false);
   base.ConnectOutput(this._runner.StandardError, true);

   this._runner.Exited += delegate { this.EndSession(); };
   base.StartListening(dsi);
}

问题是,当我开始调试myapp时,会打印"debugger-agent: DWP握手失败“,调试结束。我所能弄清楚的是,发送到myapp.exe的恰好是13个字节,接收的是13个字节(“DWP-握手”中的字符数)。

有人知道这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-09-16 18:36:08

问题解决了。问题出在下面这几行中的VirtualMachineManager.ListenInternal(2)方法中:

代码语言:javascript
复制
dbg_sock.Disconnect (false);
dbg_sock.Close ();

由于某些原因,这是未处理的异常(在断开连接时)。try-catch解决了这个问题。现在所有的工作都很棒!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3701211

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档