diff options
author | ckelsel <ckelsel@hotmail.com> | 2017-08-12 08:28:10 +0800 |
---|---|---|
committer | ckelsel <ckelsel@hotmail.com> | 2017-08-12 08:28:10 +0800 |
commit | d59e9a2c25c563e3460b1eeb31ab4d5971097331 (patch) | |
tree | 26f42a8d349db94f9faf87846aaae116582a76e7 /src/nvim/log.c | |
parent | 9a5d309b5743d70832b4daedcea934af5e6cc127 (diff) | |
parent | f2fd5afb48786c4272105b0adda6977ee1fd6f2e (diff) | |
download | rneovim-d59e9a2c25c563e3460b1eeb31ab4d5971097331.tar.gz rneovim-d59e9a2c25c563e3460b1eeb31ab4d5971097331.tar.bz2 rneovim-d59e9a2c25c563e3460b1eeb31ab4d5971097331.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/nvim/log.c')
-rw-r--r-- | src/nvim/log.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/nvim/log.c b/src/nvim/log.c index b64aef3cac..3baf0b2ebd 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -178,7 +178,8 @@ FILE *open_log_file(void) } #ifdef HAVE_EXECINFO_BACKTRACE -void log_callstack(const char *const func_name, const int line_num) +void log_callstack_to_file(FILE *log_file, const char *const func_name, + const int line_num) { void *trace[100]; int trace_size = backtrace(trace, ARRAY_SIZE(trace)); @@ -190,8 +191,6 @@ void log_callstack(const char *const func_name, const int line_num) } assert(24 + exepathlen < IOSIZE); // Must fit in `cmdbuf` below. - do_log(DEBUG_LOG_LEVEL, func_name, line_num, true, "trace:"); - char cmdbuf[IOSIZE + (20 * ARRAY_SIZE(trace))]; snprintf(cmdbuf, sizeof(cmdbuf), "addr2line -e %s -f -p", exepath); for (int i = 1; i < trace_size; i++) { @@ -202,12 +201,8 @@ void log_callstack(const char *const func_name, const int line_num) // Now we have a command string like: // addr2line -e /path/to/exe -f -p 0x123 0x456 ... - log_lock(); - FILE *log_file = open_log_file(); - if (log_file == NULL) { - goto end; - } - + do_log_to_file(log_file, DEBUG_LOG_LEVEL, func_name, line_num, true, + "trace:"); FILE *fp = popen(cmdbuf, "r"); char linebuf[IOSIZE]; while (fgets(linebuf, sizeof(linebuf) - 1, fp) != NULL) { @@ -218,6 +213,18 @@ void log_callstack(const char *const func_name, const int line_num) if (log_file != stderr && log_file != stdout) { fclose(log_file); } +} + +void log_callstack(const char *const func_name, const int line_num) +{ + log_lock(); + FILE *log_file = open_log_file(); + if (log_file == NULL) { + goto end; + } + + log_callstack_to_file(log_file, func_name, line_num); + end: log_unlock(); } |