Skip to content

Commit

Permalink
Print Native Stacktrace on mono_llvm_cpp_throw_exception when profile…
Browse files Browse the repository at this point in the history
…r is enabled. (#51026)

* Print call stack when profile is enabled in a mono_llvm_cpp_throw_exception (void) this was asked by @jeromelaban

* Update src/mono/mono/mini/llvm-runtime.cpp

Co-authored-by: Jérôme Laban <jlaban@gmail.com>

* As suggested by @jeromelaban

Co-authored-by: Jérôme Laban <jlaban@gmail.com>
  • Loading branch information
thaystg and jeromelaban committed Apr 12, 2021
1 parent ef2c630 commit b1df28a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/mono/mono/mini/llvm-runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
#include "llvm-runtime.h"

#include <glib.h>
#include <mono/utils/mono-logger-internals.h>

#include <mono/metadata/mono-debug.h>
#include <mono/metadata/profiler.h>
#include "trace.h"

extern "C" {

Expand All @@ -10,6 +15,9 @@ mono_llvm_cpp_throw_exception (void)
{
gint32 *ex = NULL;

if (mono_trace_is_enabled ())
mono_runtime_printf_err ("Native Stacktrace (mono_llvm_cpp_throw_exception)\n");

/* The generated code catches an int32* */
throw ex;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/mini-exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -3445,7 +3445,7 @@ mono_print_thread_dump_internal (void *sigctx, MonoContext *start_ctx)
mono_walk_stack_with_ctx (print_stack_frame_to_string, &ctx, MONO_UNWIND_LOOKUP_ALL, text);

#if HOST_WASM
mono_runtime_printf_err ("%s", text->str); //to print the native callstack
mono_runtime_printf_err ("%s\n", text->str); //to print the native callstack
#else
mono_runtime_printf ("%s", text->str);
#endif
Expand Down
3 changes: 3 additions & 0 deletions src/mono/mono/mini/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ void
mono_trace_tail_method (MonoMethod *method, MonoJitInfo *ji, MonoMethod *target);

void mono_trace_enable (gboolean enable);

G_EXTERN_C
gboolean mono_trace_is_enabled (void);

gboolean mono_trace_eval_exception (MonoClass *klass);

#endif /* __MONO_TRACE_H__ */

0 comments on commit b1df28a

Please sign in to comment.