Changeset 4762301 in opengl-game
- Timestamp:
- Jun 6, 2019, 1:13:48 AM (6 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 17f28a1
- Parents:
- b373466
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
CrashLogger.cpp
rb373466 r4762301 5 5 #include <csignal> 6 6 #include <cstring> 7 #include <cstdint> // Check if this lets me remove any windows includes 7 8 8 9 #include <fcntl.h> … … 133 134 134 135 // retrieve current stack addresses 135 u int32_t addrlen = backtrace(addrlist, sizeof(addrlist) / sizeof(void*));136 unsigned int addrlen = backtrace(addrlist, sizeof(addrlist) / sizeof(void*)); 136 137 137 138 if (addrlen == 0) { … … 144 145 145 146 size_t funcnamesize = 1024; 146 char * funcname = (char*)malloc(funcnamesize);147 char funcname[1024]; 147 148 148 149 // iterate over the returned symbol lines 149 150 // skip the first few, since those are printStackTrace, abortHandler, 150 151 // and a couple others called after the crash 151 for (unsigned int i = 4; i < addrlen; i++) {152 for (unsigned int i = 0; i < addrlen; i++) { 152 153 char* begin_name = NULL; 153 154 char* begin_offset = NULL; 154 char* end_offset = NULL; // Iirc, this is used in the Linux code (Check what it's used for)155 char* end_offset = NULL; 155 156 156 157 #ifdef MAC … … 158 159 if ((*p == '_') && (*(p-1) == ' ')) { 159 160 begin_name = p-1; 160 } else if (*p == '+') {161 } else if (*p == '+') { 161 162 begin_offset = p-1; 162 163 } … … 175 176 if (status == 0) { 176 177 funcname = ret; // use possibly realloc()-ed string 178 write(fd_out, " ", 2); 177 179 write(fd_out, symbollist[i], strlen(symbollist[i])); 178 180 write(fd_out, " ", 1); 179 181 write(fd_out, funcname, strlen(funcname)); 180 182 write(fd_out, " ", 1); 181 write(fd_out, begin_offset, strlen(begin_offset));182 183 } else { 183 184 // demangling failed. Output function name as a C function with no arguments. 184 write(fd_out, " Error\n", 6);185 write(fd_out, " ", 2); 185 186 write(fd_out, symbollist[i], strlen(symbollist[i])); 186 187 write(fd_out, " ", 1); 187 188 write(fd_out, begin_name, strlen(begin_name)); 188 189 write(fd_out, "() ", 3); 190 } 191 write(fd_out, begin_offset, strlen(begin_offset)); 192 write(fd_out, "\n", 1); 193 } else {` 194 // couldn't parse the line? print the whole line. 195 write(fd_out, symbollist[i], strlen(symbollist[i])); 196 } 197 #else 198 for (char *p = symbollist[i]; *p; p++) { 199 if (*p == '(') { 200 begin_name = p; 201 } else if (*p == '+') { 202 begin_offset = p; 203 } else if (*p == ')' && (begin_offset || begin_name)) { 204 end_offset = p; 205 } 206 } 207 208 if (begin_name && end_offset && (begin_name < end_offset)) { 209 *begin_name++ = '\0'; 210 *end_offset++ = '\0'; 211 if (begin_offset) { 212 *begin_offset++ = '\0'; 213 } 214 215 // mangled name is now in [begin_name, begin_offset) and caller 216 // offset in [begin_offset, end_offset). now apply 217 // __cxa_demangle(): 218 int status; 219 char* ret = abi::__cxa_demangle(begin_name, funcname, &funcnamesize, &status); 220 221 write(fd_out, " ", 2); 222 write(fd_out, symbollist[i], strlen(symbollist[i])); 223 write(fd_out, " ( ", 3); 224 if (status == 0) { 225 write(fd_out, ret, strlen(ret)); 226 } else { 227 write(fd_out, begin_name, strlen(begin_name)); 228 } 229 if (begin_offset) { 230 write(fd_out, " + ", 3); 189 231 write(fd_out, begin_offset, strlen(begin_offset)); 190 } 232 } else { 233 write(fd_out, " ", 9); 234 } 235 write(fd_out, ") ", 1); 236 write(fd_out, end_offset, strlen(end_offset)); 237 write(fd_out, "\n", 1); 191 238 } else { 192 239 // couldn't parse the line? print the whole line. 193 240 write(fd_out, symbollist[i], strlen(symbollist[i])); 194 241 } 195 write(fd_out, "\n", 1);196 #else197 // Check that this works on Linux Mint198 write(fd_out, symbollist[i], strlen(symbollist[i]));199 write(fd_out, "\n", 1);200 242 #endif 201 243 } 202 244 203 free(funcname);204 245 free(symbollist); 205 246 -
makefile
rb373466 r4762301 1 1 OS = $(shell uname) 2 2 CC = g++ 3 CFLAGS = -std=c++0x -Wall -pedantic#-Wextra -fno-inline 3 CFLAGS = -std=c++0x -Wall -pedantic -rdynamic 4 #-Wextra -fno-inline 4 5 5 6 ifeq ($(OS),Darwin) -
utils.h
rb373466 r4762301 5 5 6 6 #include <glm/mat4x4.hpp> 7 #include <glm/gtc/type_ptr.hpp> 7 8 8 9 using namespace std;
Note:
See TracChangeset
for help on using the changeset viewer.