*
* Note: this profiler is completely unsafe wrt handling managed objects,
* don't use and don't copy code from here.
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "config.h"
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/class.h>
#include <mono/metadata/class-internals.h>
+#include <mono/metadata/object-internals.h>
#include <mono/metadata/image.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/debug-helpers.h>
static inline void print_report (const gchar *format, ...)
{
+ MonoError error;
MonoClass *klass;
MonoProperty *prop;
MonoString *str;
klass = mono_class_load_from_name (mono_get_corlib (), "System", "Environment");
mono_class_init (klass);
prop = mono_class_get_property_from_name (klass, "StackTrace");
- str = (MonoString*)mono_property_get_value (prop, NULL, NULL, NULL);
- stack_trace = mono_string_to_utf8 (str);
+ str = (MonoString*)mono_property_get_value_checked (prop, NULL, NULL, &error);
+ mono_error_assert_ok (&error);
+ stack_trace = mono_string_to_utf8_checked (str, &error);
+ mono_error_assert_ok (&error);
fprintf (stdout, "-= Stack Trace =-\n%s\n\n", stack_trace);
g_free (stack_trace);
static inline void append_report (GString **report, const gchar *format, ...)
{
-#if defined (_EGLIB_MAJOR) || GLIB_CHECK_VERSION(2,14,0)
va_list ap;
if (!*report)
*report = g_string_new ("");
va_start (ap, format);
g_string_append_vprintf (*report, format, ap);
va_end (ap);
-#else
- g_assert_not_reached ();
-#endif
}
static gboolean saved_strings_find_func (gpointer key, gpointer value, gpointer user_data)
{
+ MonoError error;
SavedStringFindInfo *info = (SavedStringFindInfo*)user_data;
SavedString *saved = (SavedString*)value;
gchar *utf_str;
if (!info || !saved || mono_string_length (saved->string) != info->len)
return FALSE;
- utf_str = mono_string_to_utf8 (saved->string);
+ utf_str = mono_string_to_utf8_checked (saved->string, &error);
+ mono_error_assert_ok (&error);
hash = do_calc_string_hash (0, utf_str);
g_free (utf_str);