MonoObject * pException = NULL;
// this method will cause an exception in c#, something like null exception
MonoString * pResult = (MonoString*) mono_runtime_invoke(g_pGetMethod, NULL, monoargs, &pException);
/* debugging with gdb:
(gdb) n
Program received signal SIGPWR, Power fail/restart.
then this program stopped.
*/
char * szResult = NULL;
if(pException == NULL)
{
szResult = mono_string_to_utf8(pResult);
} else
{
//MonoString * pMsg = mono_object_to_string_ex(pException, NULL);
//szResult = mono_string_to_utf8(pMsg);
szResult = "Mono throwed an Exception!";
}
我试图像上面那样抓住MonoException,
有什么我错的吗?
g_pGetMethod是一个静态函数btw,如果没有抛出异常,这些代码可以正常工作
答案 0 :(得分:1)
您应该指示gdb忽略SIGPWR(以及更多信号):
handle SIGXCPU SIG33 SIG35 SIGPWR nostop noprint
有关使用gdb调试Mono的更多信息,请访问:http://www.mono-project.com/docs/debug+profile/debug/