From fc5700619bfcab56fcfe7f62cf87906d1d012e8a Mon Sep 17 00:00:00 2001 From: Simon Hafner Date: Sun, 1 Feb 2015 23:24:43 -0600 Subject: [PATCH 1/4] report how to create a compiler stacktrace #1280 --- compiler/msgs.nim | 5 ++++- lib/system/excpt.nim | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 35a1217692..8d1a18b444 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -715,7 +715,10 @@ type proc handleError(msg: TMsgKind, eh: TErrorHandling, s: string) = template quit = if defined(debug) or gVerbosity >= 3 or msg == errInternal: - writeStackTrace() + if stackTraceAvailable(): + writeStackTrace() + else: + stderr.writeln("No stack traceback available\nTo create a stacktrace, rerun compilation with ./koch temp c ") quit 1 if msg >= fatalMin and msg <= fatalMax: diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim index 417a8634f6..1b3471978a 100644 --- a/lib/system/excpt.nim +++ b/lib/system/excpt.nim @@ -175,6 +175,8 @@ proc auxWriteStackTrace(f: PFrame, s: var string) = add(s, tempFrames[j].procname) add(s, "\n") +proc stackTraceAvailable*(): bool + when hasSomeStackTrace: proc rawWriteStackTrace(s: var string) = when NimStackTrace: @@ -188,6 +190,18 @@ when hasSomeStackTrace: auxWriteStackTraceWithBacktrace(s) else: add(s, "No stack traceback available\n") + proc stackTraceAvailable(): bool = + when NimStackTrace: + if framePtr == nil: + result = false + else: + result = true + elif defined(nativeStackTrace) and nativeStackTraceSupported: + result = true + else: + result = false +else: + proc stackTraceAvailable*(): bool = result = false proc quitOrDebug() {.inline.} = when not defined(endb): From d4c32102d829ffdbca117da27d2bbe876b4ad10f Mon Sep 17 00:00:00 2001 From: Simon Hafner Date: Wed, 4 Feb 2015 14:15:52 -0600 Subject: [PATCH 2/4] use dynamic message destination --- compiler/msgs.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 8d1a18b444..59789df6c3 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -718,7 +718,7 @@ proc handleError(msg: TMsgKind, eh: TErrorHandling, s: string) = if stackTraceAvailable(): writeStackTrace() else: - stderr.writeln("No stack traceback available\nTo create a stacktrace, rerun compilation with ./koch temp c ") + msgWriteln("No stack traceback available\nTo create a stacktrace, rerun compilation with ./koch temp c ") quit 1 if msg >= fatalMin and msg <= fatalMax: From 743ad639d48082c58685929c68b1463332552e7a Mon Sep 17 00:00:00 2001 From: Hans Raaf Date: Wed, 11 Feb 2015 20:54:34 +0100 Subject: [PATCH 3/4] Fixing dylib name for OSX I don't know if the (15|16...) is supposed to work on OSX. I have "libmysqlclient.18.dylib" in my lib directory and get "could not load: libmysqlclient.(15|16|17[18).dylib" on execution. After removing the pattern I can run my little example program and it works as "libmysqlclient.dylib" is a softlink to the current version anyway. --- lib/wrappers/mysql.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wrappers/mysql.nim b/lib/wrappers/mysql.nim index 9161f56722..3857744ae1 100644 --- a/lib/wrappers/mysql.nim +++ b/lib/wrappers/mysql.nim @@ -13,7 +13,7 @@ when defined(Unix): when defined(macosx): const - lib = "libmysqlclient.(15|16|17[18).dylib" + lib = "libmysqlclient.(15|16|17|18).dylib" else: const lib = "libmysqlclient.so.(15|16|17|18)" From ceffdebebb4c81a716908f60749aee26e2b1f232 Mon Sep 17 00:00:00 2001 From: Hans Raaf Date: Wed, 11 Feb 2015 21:03:24 +0100 Subject: [PATCH 4/4] Corrected warnings about deprecated names I got warning about deprecated names here. I also know that other names probably need to change (T/P prefixes) but I am unsure about the exact rules. I may do that later if you like. --- lib/impure/db_mysql.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/impure/db_mysql.nim b/lib/impure/db_mysql.nim index 968a2923ad..dab84c2d50 100644 --- a/lib/impure/db_mysql.nim +++ b/lib/impure/db_mysql.nim @@ -16,11 +16,11 @@ type TDbConn* = PMySQL ## encapsulates a database connection TRow* = seq[string] ## a row of a dataset. NULL database values will be ## transformed always to the empty string. - EDb* = object of EIO ## exception that is raised if a database error occurs + EDb* = object of IOError ## exception that is raised if a database error occurs TSqlQuery* = distinct string ## an SQL query string - FDb* = object of FIO ## effect that denotes a database operation + FDb* = object of IOEffect ## effect that denotes a database operation FReadDb* = object of FDb ## effect that denotes a read operation FWriteDb* = object of FDb ## effect that denotes a write operation