mono debug information with exceptions on debian?

*爱你&永不变心* 提交于 2019-12-18 14:51:53

问题


I thought apt-get install mono-dbg would solve it but i was wrong. How do i get debug information with mono? i am using debian squeeze but couldnt figure it out on debian lenny or etch.

I wrote a dummy program below and i was hoping for a line number but i got this instead. This is a copy/paste from the console/terminal.

Unhandled Exception: System.Exception: nooo blah
  at ExceptionTest.Program.func (Int32 a) [0x00000] in <filename unknown>:0
  at ExceptionTest.Program.func (Int32 a) [0x00000] in <filename unknown>:0
  at ExceptionTest.Program.func (Int32 a) [0x00000] in <filename unknown>:0
  at ExceptionTest.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExceptionTest
{
    class Program
    {
        static void Main(string[] args)
        {
            func(3);
        }
        static void func(int a)
        {
            if (a == 18)
                throw new Exception("nooo blah");
            func(a + a + 2);
        }
    }
}

回答1:


To get file names and line numbers, compile your application with -debug (like gmcs -debug prog.cs) and then run mono --debug prog.exe.

The mono-dbg package gives you debugging symbols for /usr/bin/mono (and libmono).

$ gmcs -debug prog.cs
$ mono --debug prog.exe

Unhandled Exception: System.Exception: nooo blah
  at ExceptionTest.Program.func (Int32 a) [0x0001d] in /tmp/prog.cs:19 
  at ExceptionTest.Program.func (Int32 a) [0x00013] in /tmp/prog.cs:18 
  at ExceptionTest.Program.func (Int32 a) [0x00013] in /tmp/prog.cs:18 
  at ExceptionTest.Program.Main (System.String[] args) [0x00000] in /tmp/prog.cs:12 


来源:https://stackoverflow.com/questions/5317343/mono-debug-information-with-exceptions-on-debian

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!