mirror of
https://github.com/swaywm/sway.git
synced 2024-11-25 17:31:28 +00:00
Added in backtrace printing
This commit is contained in:
parent
dbad30a409
commit
7c5b6f8c52
|
@ -16,6 +16,7 @@ void sway_log(log_importance_t verbosity, const char* format, ...) __attribute__
|
||||||
void sway_log_errno(log_importance_t verbosity, char* format, ...) __attribute__((format(printf,2,3)));
|
void sway_log_errno(log_importance_t verbosity, char* format, ...) __attribute__((format(printf,2,3)));
|
||||||
void sway_abort(const char* format, ...) __attribute__((format(printf,1,2)));
|
void sway_abort(const char* format, ...) __attribute__((format(printf,1,2)));
|
||||||
bool sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3)));
|
bool sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3)));
|
||||||
|
void error_handler(int sig);
|
||||||
|
|
||||||
void layout_log(const swayc_t *c, int depth);
|
void layout_log(const swayc_t *c, int depth);
|
||||||
#endif
|
#endif
|
||||||
|
|
25
sway/log.c
25
sway/log.c
|
@ -8,6 +8,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <execinfo.h>
|
||||||
|
|
||||||
int colored = 1;
|
int colored = 1;
|
||||||
log_importance_t v = L_SILENT;
|
log_importance_t v = L_SILENT;
|
||||||
|
@ -30,6 +31,8 @@ void init_log(log_importance_t verbosity) {
|
||||||
fcntl(fd[i], F_SETFD, flag | FD_CLOEXEC);
|
fcntl(fd[i], F_SETFD, flag | FD_CLOEXEC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
signal(SIGSEGV, error_handler);
|
||||||
|
signal(SIGABRT, error_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sway_log_colors(int mode) {
|
void sway_log_colors(int mode) {
|
||||||
|
@ -114,6 +117,28 @@ bool sway_assert(bool condition, const char* format, ...) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void error_handler(int sig) {
|
||||||
|
int i;
|
||||||
|
int max_lines = 20;
|
||||||
|
void *array[max_lines];
|
||||||
|
char **bt;
|
||||||
|
size_t bt_len;
|
||||||
|
|
||||||
|
sway_log(L_ERROR, "Error: Signal %d. Printing backtrace", sig);
|
||||||
|
bt_len = backtrace(array, max_lines);
|
||||||
|
bt = backtrace_symbols(array, bt_len);
|
||||||
|
if (!bt) {
|
||||||
|
sway_log(L_ERROR, "Could not allocate sufficient memory for backtrace_symbols(), falling back to stderr");
|
||||||
|
backtrace_symbols_fd(array, bt_len, STDERR_FILENO);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; (size_t)i < bt_len; i++) {
|
||||||
|
sway_log(L_ERROR, "Backtrace: %s", bt[i]);
|
||||||
|
}
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
|
|
||||||
/* XXX:DEBUG:XXX */
|
/* XXX:DEBUG:XXX */
|
||||||
|
|
Loading…
Reference in a new issue