Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authortherzok <marius.ungureanu@xamarin.com>2019-05-30 16:03:59 +0300
committertherzok <marius.ungureanu@xamarin.com>2019-05-30 17:11:59 +0300
commitf12e4d32923724db3850b98d5e1400f1b3f847d8 (patch)
treedb9f8a4f8842f2f49066a9d49273b5c5c6dbd9f3 /main
parent5fcab1a3e0a08573ce2ec457b6ff01f6ffb65c60 (diff)
Properly bind exception stacktrace for native gtk errors
Diffstat (limited to 'main')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/GLibLogging.cs20
-rw-r--r--main/tests/Ide.Tests/MonoDevelop.Ide.Gui/GLibLoggingTests.cs1
2 files changed, 9 insertions, 12 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/GLibLogging.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/GLibLogging.cs
index 5f6ef79aff..2604d036e7 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/GLibLogging.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/GLibLogging.cs
@@ -33,6 +33,7 @@ using System.Runtime.InteropServices;
using System.Collections;
using System.Runtime.ExceptionServices;
using System.Runtime.CompilerServices;
+using System.Diagnostics;
namespace MonoDevelop.Ide.Gui
{
@@ -271,8 +272,7 @@ namespace MonoDevelop.Ide.Gui
case LogLevelFlags.Critical:
default:
try {
- // Otherwise exception info is not gathered.
- throw new CriticalGtkException (msg, Environment.StackTrace);
+ throw new CriticalGtkException (msg);
} catch (CriticalGtkException e) {
if (logLevel.HasFlag (LogLevelFlags.FlagFatal))
LoggingService.LogFatalError ("Fatal GLib error", e);
@@ -289,17 +289,15 @@ namespace MonoDevelop.Ide.Gui
sealed class CriticalGtkException : Exception
{
- public CriticalGtkException (string message, string stacktrace) : base (message)
+ public CriticalGtkException (string message) : base (message)
{
- StackTrace = stacktrace;
- }
-
- public override string StackTrace { get; }
+ const System.Reflection.BindingFlags flags =
+ System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.SetField;
- public override string ToString ()
- {
- // Matches normal exception format:
- return GetType() + ": " + Message + Environment.NewLine + StackTrace;
+ var trace = new [] { new StackTrace (true), };
+ //// Otherwise exception stacktrace is not gathered.
+ typeof (Exception)
+ .InvokeMember ("captured_traces", flags, null, this, new object [] { trace } );
}
}
}
diff --git a/main/tests/Ide.Tests/MonoDevelop.Ide.Gui/GLibLoggingTests.cs b/main/tests/Ide.Tests/MonoDevelop.Ide.Gui/GLibLoggingTests.cs
index 61ac439b6a..b49711ed74 100644
--- a/main/tests/Ide.Tests/MonoDevelop.Ide.Gui/GLibLoggingTests.cs
+++ b/main/tests/Ide.Tests/MonoDevelop.Ide.Gui/GLibLoggingTests.cs
@@ -91,7 +91,6 @@ namespace MonoDevelop.Ide.Gui
Assert.That (stacktrace, Contains.Substring ("at GLib.Log.g_logv"));
Assert.That (stacktrace, Contains.Substring ("at MonoDevelop.Ide.Gui.GLibLogging.LoggerMethod"));
Assert.That (stacktrace, Contains.Substring ("at MonoDevelop.Ide.Gui.GLibLoggingTests"));
-
}
}
}