diff --git a/bin/uce_fastcgi.debug.linux.bin b/bin/uce_fastcgi.debug.linux.bin index 337d006..51995ca 100755 Binary files a/bin/uce_fastcgi.debug.linux.bin and b/bin/uce_fastcgi.debug.linux.bin differ diff --git a/build_linux.sh b/build_linux.sh index 7a87972..1557ca1 100755 --- a/build_linux.sh +++ b/build_linux.sh @@ -16,7 +16,7 @@ mkdir bin/assets > /dev/null 2>&1 mkdir work > /dev/null 2>&1 COMPILER="clang++" -FLAGS="-g -w -Wall -$OPT_FLAG -std=c++17 -fpermissive -ffast-math" +FLAGS="-g -rdynamic -w -Wall -$OPT_FLAG -std=c++17 -fpermissive -ffast-math" LIBS="-ldl -lm -lpthread " SRCFLAGS="-D EXEC_NAME=\"$GF\" -D PLATFORM_NAME=\"linux\"" diff --git a/scripts/compile b/scripts/compile index 3c24b24..93fd790 100755 --- a/scripts/compile +++ b/scripts/compile @@ -24,7 +24,7 @@ OPT_FLAG="O0" COMPILER="clang++" #COMPILER="g++" -FLAGS="-shared -w -Wall -$OPT_FLAG -std=c++17 -fpermissive -ffast-math -fPIC" +FLAGS="-shared -g -rdynamic -w -Wall -$OPT_FLAG -std=c++17 -fpermissive -ffast-math -fPIC" LIBS="-ldl -lm -lpthread " SRCFLAGS="-D PLATFORM_NAME=\"linux\"" diff --git a/src/lib/dtree.h b/src/lib/dtree.h index 2bd40d5..4bbe8db 100644 --- a/src/lib/dtree.h +++ b/src/lib/dtree.h @@ -201,34 +201,34 @@ string json_decode_string(string s, u32& i) switch(c) { case('t'): - result.append('\t', 1); + result.append(1, '\t'); break; case('n'): - result.append('\n', 1); + result.append(1, '\n'); break; case('r'): - result.append('\r', 1); + result.append(1, '\r'); break; case('\\'): - result.append('\\', 1); + result.append(1, '\\'); break; case('b'): - result.append('\b', 1); + result.append(1, '\b'); break; case('f'): - result.append('\f', 1); + result.append(1, '\f'); break; case('u'): // todo decode break; default: - result.append(c, 1); + result.append(1, c); break; } } else { - result.append(c, 1); + result.append(1, c); } i += 1; } @@ -252,7 +252,7 @@ string json_decode_keyword(string s, u32& i) char c = s[i]; if(isalnum(c)) { - result.append(c, 1); + result.append(1, c); } else { @@ -272,7 +272,7 @@ string json_decode_number(string s, u32& i) char c = s[i]; if(isdigit(c) || c == '.') { - result.append(c, 1); + result.append(1, c); } else { @@ -289,9 +289,6 @@ DTree json_decode_value(string s, u32& i) string value = ""; json_consume_space(s, i); char c = s[i]; - result.set("CHAR_"); - result._string.append(to_string(c)); - return(result); if(c == '"') // string value { result.type = 'S'; @@ -329,9 +326,9 @@ DTree json_decode_map(string s, u32& i) { DTree result; string key = ""; + json_consume_space(s, i); while(i < s.length()) { - json_consume_space(s, i); char c = s[i]; if(c == '}') { @@ -348,7 +345,10 @@ DTree json_decode_map(string s, u32& i) json_consume_space(s, i); if(s[i] != ':') return(result); // malformed - result[key] = json_decode_value(s, i); + //result[key] = json_decode_value(s, i); + printf("%s\n", key.c_str()); + i += 1; + json_consume_space(s, i); } else { @@ -356,6 +356,7 @@ DTree json_decode_map(string s, u32& i) return(result); } i += 1; + json_consume_space(s, i); } return(result); } diff --git a/src/lib/sys.h b/src/lib/sys.h index d242833..cfb4603 100644 --- a/src/lib/sys.h +++ b/src/lib/sys.h @@ -148,3 +148,19 @@ string expand_path(string path) } return(result); } + +#include +#include + +void on_segfault(int sig) { + void *array[10]; + size_t size; + + // get void*'s for all entries on the stack + size = backtrace(array, 10); + + // print out all the frames to stderr + fprintf(stderr, "SEG FAULT: %d:\n", sig); + backtrace_symbols_fd(array, size, STDERR_FILENO); +} + diff --git a/src/lib/uce_gen.h b/src/lib/uce_gen.h index a011535..4406ec8 100644 --- a/src/lib/uce_gen.h +++ b/src/lib/uce_gen.h @@ -14,5 +14,6 @@ Request* context; extern "C" void set_current_request(Request* _request) { context = _request; + signal(SIGSEGV, on_segfault); } diff --git a/src/linux_fastcgi.cpp b/src/linux_fastcgi.cpp index aa85fbc..a97d797 100644 --- a/src/linux_fastcgi.cpp +++ b/src/linux_fastcgi.cpp @@ -89,6 +89,7 @@ FastCGIServer server; int main(int argc, char** argv) { + signal(SIGSEGV, on_segfault); srand(time()); // Set up our request handlers diff --git a/test/json.uce b/test/json.uce index ecdf0ce..497caf0 100644 --- a/test/json.uce +++ b/test/json.uce @@ -34,7 +34,7 @@ RENDER() Parsed:
Params