在嵌入式单声道中捕获异常

Catch an exception in embedded mono

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 是一个静态函数顺便说一句,如果没有抛出异常,这些代码可以正常工作

您应该指示 gdb 忽略 SIGPWR(以及更多信号):

handle SIGXCPU SIG33 SIG35 SIGPWR nostop noprint

可以在此处找到有关使用 gdb 调试 Mono 的更多信息:http://www.mono-project.com/docs/debug+profile/debug/