aboutsummaryrefslogtreecommitdiff
path: root/common/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/log.c')
-rw-r--r--common/log.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/common/log.c b/common/log.c
index f9242bf4..0c0ecf89 100644
--- a/common/log.c
+++ b/common/log.c
@@ -1,5 +1,6 @@
#include "log.h"
#include "sway.h"
+#include "readline.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -142,6 +143,9 @@ void error_handler(int sig) {
void *array[max_lines];
char **bt;
size_t bt_len;
+ char maps_file[256];
+ char maps_buffer[1024];
+ FILE *maps;
sway_log(L_ERROR, "Error: Signal %d. Printing backtrace", sig);
bt_len = backtrace(array, max_lines);
@@ -155,6 +159,22 @@ void error_handler(int sig) {
for (i = 0; (size_t)i < bt_len; i++) {
sway_log(L_ERROR, "Backtrace: %s", bt[i]);
}
+
+ sway_log(L_ERROR, "Maps:");
+ pid_t pid = getpid();
+ if (snprintf(maps_file, 255, "/proc/%zd/maps", (size_t)pid) < 255) {
+ maps = fopen(maps_file, "r");
+ while (!feof(maps)) {
+ char *m = read_line_buffer(maps, maps_buffer, 1024);
+ if (!m) {
+ fclose(maps);
+ sway_log(L_ERROR, "Unable to allocate memory to show maps");
+ break;
+ }
+ sway_log(L_ERROR, m);
+ }
+ fclose(maps);
+ }
#else
sway_log(L_ERROR, "Error: Signal %d.", sig);
#endif