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,安装方 ...
随机推荐
- chartjs执行图表
<html> <head> <title></title> </head> <body> <div style='widt ...
- VBA学习之关于数据透视表的应用
工作中很多地方需要同时处理多个数据表,而且用数据透视表进行排版,排序,计算字段,一个一个的做非常累,这里给出批量处理的方法. 学习VBA之前最好懂一点点VB的基础知识,因为里面的很多语法问题都是由VB ...
- jsp中,个别乱码进行转码操作
来自大神 if(xh!=null && xh!=""){ xhmc =new String(xh.getBytes("ISO-8859-1"), ...
- @helper函数使用方法
这个函数方法,我也是通过别人博客看到的,感觉不错和大家一起学习分享一下. 1.自定义函数方法,只在同一个view视图文件里调用 Controller public ActionResult Index ...
- spring知识大全(3)
4 Spring对持久层的支持 Spring对持久层的支持:① JDBC,② O/R Mapping(Hibernate,TopLink等) 一.Spring对持久层支持采用的策略: 1.Spring ...
- java 获取服务器 linux 服务器IP 信息
public String getUnixLocalIp() { String ip = ""; try { Enumeration<?> e1 = (Enumerat ...
- windows下nginx的启动关闭
Windows下Nginx的启动.停止等命令 在Windows下使用Nginx,我们需要掌握一些基本的操作命令,比如:启动.停止Nginx服务,重新载入Nginx等,下面我就进行一些简单的介绍. .启 ...
- 我与solr(四)--solrJ
SolrJ索引库: solr提供的一个客户端操作框架,在文件/solr6.2/dist下面可以找到该jar包solrj.jar以及相关jar包,可以使用maven添加. java使用solrJ如下: ...
- 【解题报告】BZOJ2550: [Ctsc2004]公式编辑器
题意:给定一个可视化计算器的操作序列,包括插入数字.字母.运算符.分数.矩阵以及移动光标.矩阵插入行.插入列,输出操作序列结束后的屏显(数学输出). 解法:这题既可以用来提升OI/ACM写大代码模拟题 ...
- 数据库软件dbForge Studio for MySQL更新至v.6.1
本文转自:慧都控件网 说到MariaDB,这个数据库算是MySQL的一个分支.现在非常的流行,很多地方都能看到它的身影.MariaDB作为一种新的数据库管理系统,在短时间内获得如此高的关注度.这也是D ...