mono的远程调试
mono可以让.net程序运行在linux平台上。于是.net程序员有了mono之后就转身跨平台了。但开放环境往往还是在windows下,于是有了这样的需求,是否可以用windows下的源码来实机调试linux下的程序呢?
如今Xamarin已经被广泛地使用在移动平台的应用开发上,当然也能够支持实机调试。
大概是内部维护一个TCP连接,传递调用堆栈信息。
查阅了一些文档和stackoverflow搜索结果之后看到下面这样的描述:
Remote debugging is actually really easy with the Mono soft debugger. The IDE sends commands over TCP/IP to the Mono Soft Debugger agent inside the runtime. Depending how you launch the debuggee, you can either have it connect to the IDE over TCP, or have it open a port and wait for the IDE to connect to it.
For simple prototyping purposes, you can just set the MONODEVELOP_SDB_TEST env var, and a new "Run->Run With->Custom Soft Debugger" command will show up in Xamarin Studio / MonoDevelop, and you can specify an arbitrary IP and port or connect or or listen on, and optionally a command to run. Then you just have to start the debuggee with the correct --debugger-agentarguments (see the Mono manpage for details), start the connection, and start debugging.
For a production workflow, you'd typically create a MonoDevelop addin with a debugger engine and session subclassing the soft debugger classes, and overriding how to launch the app and set up the connection parameters. You'd typically have a custom project type too subclassing the DotNetProject, so you could override how the project was built and executed, and so that the new debugger engine could be the primary debugger for projects of that type. You'd get all the default .NET/Mono project and debugger functionality "for free".
恩,就和手机调试一样,linux上运行mono,远程使用XamarinStudio调试也非常方便。
我的测试代码如下
public static void Main (string[] args)
{
Console.WriteLine ("Hello World!");
while (true) {
string input =Console.ReadLine ();
Console.WriteLine (input);//此处可做断点
if (input == "q") {
break;
}
}
Console.WriteLine ("byebye");
Console.ReadKey ();
}
首先,在mono运行的时候带上参数
例如:mono --debug --debugger-agent=transport=dt_socket,address=127.0.0.1:8088,server=y,suspend=y MyApp.exe
因为我设置了server参数为y,表示这里是socket的监听方,然后suspend=y。之后MyApp.exe并没开始运行,而是等待连接。
然后,在另一端,比如windows下,安装monodevelop(XamarinStudio), 配置环境变量
MONODEVELOP_SDB_TEST=1
启动monodevelop,打开项目,设置默认F5(Run)为"Run->Run With->Custom Soft Debugger"
会打开一个对话框,在对话框中输入需要连接的mono运行机器的ip和端口,因为是linux端监听,所以选择connect(当然如果mono运行时的参数server是n,那就是相反啦)。
连接成功,linux界面输出hello world,然后随意输入字符串,回车,windows下获得断点,检查变量值调用堆栈ok数据获取成功。
远程调试测试成功。
怎么样,是不是觉得很像使用Unity的感觉呢?
是的,看这个:相关的情报
另外,如果想要mono运行MyApp.exe不等待连接,设置suspend为n即可,程序将先运行而不阻塞等待连接。
但是,我仍然不知道连接之后如何断开调试而不结束进程,希望知道的朋友能够给予帮助。
注意,还有一个--debug的参数非常重要,与之配套的是exe(dll)程序集配套生成的.mdb文件。mono的调试信息中包括源代码的路径、对应的代码在几行等等信息都在里面,远程调试的时候都需要这些信息。
不然即使连接建立,mono也不知道如何将数据和本地代码联系起来。所以源码也不要轻易地移动目录哦。
.mdb文件可以用monodevelop生成,也可以到mono安装目录下的bin文件夹中找到mdb生成工具生成。
mono的远程调试的更多相关文章
- 在windows通过visual studio远程调试linux mono程序
本文参考文章 https://github.com/techl/MonoRemoteDebugger 1.通过连接https://github.com/techl/MonoRemoteDebugger ...
- 微信公众号开发之VS远程调试
目录 (一)微信公众号开发之VS远程调试 (二)微信公众号开发之基础梳理 (三)微信公众号开发之自动消息回复和自定义菜单 前言 微信公众平台消息接口的工作原理大概可以这样理解:从用户端到公众号端一个流 ...
- tomcat开发远程调试端口以及利用eclipse进行远程调试
一.tomcat开发远程调试端口 方法1 WIN系统 在catalina.bat里: SET CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compi ...
- Visual Studio 2012远程调试中遇到的问题
有的时候开发环境没问题的代码在生产环境中会某些开发环境无法重现的问题,或者需要对生产环境代码进行远程调试该怎么办? Vs已经提供给开发者远程调试的工具 下面简单讲讲该怎么用,前期准备:1.本地登录账户 ...
- 使用Eclipse进行远程调试
转自:http://blog.csdn.net/sunyujia/article/details/2614614 今天决定做件有意义的事,写篇图文并茂的blog,为什么要图文并茂?因为很多事可能用语言 ...
- 微信公众号开发系列教程一(调试环境部署续:vs远程调试)
http://www.cnblogs.com/zskbll/p/4080328.html 目录 C#微信公众号开发系列教程一(调试环境部署) C#微信公众号开发系列教程一(调试环境部署续:vs远程调试 ...
- tomcat 远程调试
1.服务端查看cataline.sh 中的描述 cataline jpda start 开启服务端远程调试 远程调试端口JPDA_ADDRESS="8000" 2.本地代码参考 ...
- 在Visual Studio上开发Node.js程序(2)——远程调试及发布到Azure
[题外话] 上次介绍了VS上开发Node.js的插件Node.js Tools for Visual Studio(NTVS),其提供了非常方便的开发和调试功能,当然很多情况下由于平台限制等原因需要在 ...
- [教学] Delphi Berlin 10.1 开发 Windows 10 平板 App 远程调试
Delphi Berlin 10.1 开发 Windows 10 平板 App 远程调试安装步骤: 准备电脑: 一台开发电脑,安装 Delphi 开发环境 一台平板电脑,安装 PAServer,安装方 ...
随机推荐
- windows环境下安装vue+webpack的开发环境
本人最近在学习vue,在学习的过程中遇到对的问题和解决方法 1.我们首先要安装node.js.node.js的官方地址为:https://nodejs.org/en/download/,下载完毕,按照 ...
- 第五回. $e$ 的引入
假如你有 $1$ 块钱, 存银行, 利率为 $100\%$, 那么一年后本息和为$$1+1=2.$$ 如果你换种存法, 存半年, 把本息和取出来, 再存半年, 那么一年后本息和为$$\left(1+\ ...
- JAVA多线程 问题 转载
参考:http://ifeve.com/java-multi-threading-concurrency-interview-questions-with-answers/ http://www.cn ...
- Android之GridView
<GridView android:id="@+id/gridView" android:layout_width="match_parent" andr ...
- [linux] 默认权限修改(umask)
1 文件默认权限 对于目录,默认权限=777-umask 对于文件,默认权限=666-umask(文件默认无执行权限) 默认权限修改: vim /etc/bashrc 71行是普通用户的更改,73是超 ...
- mvc AddImplicitRequiredAttributeForValueTypes
1.AddImplicitRequiredAttributeForValueTypes (为值类型添加隐式必填验证),默认值 为true.刚在mvc view(html)中会为model的值类型属性( ...
- VS2010--canot determine the locationof the vs common tools folder
在vcvars32.bat第一行后复制 @SET VSINSTALLDIR=c:\Program Files\Microsoft Visual Studio 10.0 @SET VCINSTALLDI ...
- iOS常用公共方法
iOS常用公共方法 字数2917 阅读3070 评论45 喜欢236 1. 获取磁盘总空间大小 //磁盘总空间 + (CGFloat)diskOfAllSizeMBytes{ CGFloat si ...
- 【CMD】日常总结
命令脚本可以提升工作效率,之前用过也写过一些脚本,但时间一长就忘记了.写篇随笔记录一下,随用随记哈. 调用程序 //切换到某个路径下 cd D:\Glodon\GDW\GDW\Release\Bin ...
- Android Service完全解析,关于服务你所需知道的一切(上)
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/11952435 相信大多数朋友对Service这个名词都不会陌生,没错,一个老练的A ...