Commit ef57b62c authored by alex@thinkpad's avatar alex@thinkpad
Browse files

Stack traces for crash and assert logs, using the backtrace backend

--HG--
branch : backtrace
parent bd2144bbbec2
......@@ -41,6 +41,7 @@
#include "reloc.h"
#include "ml-cbr.h"
#include "backtrace.h"
#if defined(FEATURE_GPS_TWEAKS)
#include "gps.h"
......@@ -583,34 +584,36 @@ void hold_your_horses()
* Custom assert handler - intercept ERR70 and try to save a crash log.
* Crash log should contain Canon error message.
*/
static char assert_msg[256] = "";
static char assert_msg[512] = "";
static int (*old_assert_handler)(char*,char*,int,int) = 0;
const char* get_assert_msg() { return assert_msg; }
static int my_assert_handler(char* msg, char* file, int line, int arg4)
{
snprintf(assert_msg, sizeof(assert_msg),
int len = snprintf(assert_msg, sizeof(assert_msg),
"ASSERT: %s\n"
"at %s:%d, task %s\n"
"lv:%d mode:%d\n",
"lv:%d mode:%d\n\n",
msg,
file, line, get_current_task_name(),
lv, shooting_mode
);
backtrace_getstr(assert_msg + len, sizeof(assert_msg) - len);
request_crash_log(1);
return old_assert_handler(msg, file, line, arg4);
}
void ml_assert_handler(char* msg, char* file, int line, const char* func)
{
snprintf(assert_msg, sizeof(assert_msg),
int len = snprintf(assert_msg, sizeof(assert_msg),
"ML ASSERT:\n%s\n"
"at %s:%d (%s), task %s\n"
"lv:%d mode:%d\n",
"lv:%d mode:%d\n\n",
msg,
file, line, func, get_current_task_name(),
lv, shooting_mode
);
backtrace_getstr(assert_msg + len, sizeof(assert_msg) - len);
request_crash_log(2);
}
......
......@@ -458,7 +458,7 @@ static void save_crash_log()
FILE* f = FIO_CreateFile(log_filename);
if (f)
{
my_fprintf(f, "%s\n\n", get_assert_msg());
my_fprintf(f, "%s\n", get_assert_msg());
my_fprintf(f,
"Magic Lantern version : %s\n"
"Mercurial changeset : %s\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment