Commit Graph

18 Commits

Author SHA1 Message Date
Etan Kissling 5578031344
Pass length explicitly instead of relying on NULL terminators (#44)
The `getDebuggingInfo` function relies on `programCounters` being a
NULL terminated list. However, none of the usage actually adds NULL...

- In the path that passes `getProgramCounters` result into
  `getDebuggingInfo`, no explicit 0 value is added to `result`.
  In practice, there happens to be a 0 there very frequently,
  but it is not guaranteed (`env MallocScribble=1`), and even
  if it is not there the implementation often continues to work
  when processing the extra garbage data, silencing the problem.

- In the path from Nim `addDebuggingInfo` (`system/stacktraces.nim`),
  the `programCounters` list is constructed by Nim logic and also
  does not add a 0 value to the list. This means that even if we fix
  `getProgramCounters` to produce NULL terminated list, other usage
  is still broken, and outside the control of this library.

Therefore, remove the NULL terminator logic and pass length explicitly
while retaining any early loop exits when encountering 0 for compat.

Also fix some memory leaks in error conditions.
2024-07-18 17:55:27 +02:00
tersec 66864ed4ae
use strutils.escape to handle more special chars (#37) 2024-03-26 19:09:04 +00:00
tersec 9f4fd37153
quote and library paths for use in passc/passl to allow embedded spaces (#36) 2024-03-26 18:00:23 +00:00
Zahary Karadjov 06380d57ff
Remove potential for ambiguos compilation 2023-04-05 19:14:23 +03:00
Ivan Yonchovski d4a9115a43
Restructure the project to allow nimble check to pass (#25) 2022-06-20 14:32:17 +03:00
Ștefan Talpalaru 656881b721
cross-compile with latest MXE (#22) 2022-03-22 16:04:03 +01:00
Ștefan Talpalaru e59f9f1fbf
better detection for missing debugging symbols (#15) 2021-04-26 19:19:47 +02:00
Ștefan Talpalaru 107878ad53
support Nim devel 2020-09-23 12:21:48 +02:00
Ștefan Talpalaru 3ff163ca58
two-step backtraces
Allow separating stack unwinding and program counter collection from the
more expensive step of getting the associated debugging info for each
program counter.

This is useful for implementing efficient backtraces for exceptions - a
scenario in which you add a new backtrace each time an exception is
re-raised, but you rarely need to print them (usually when that
exception is uncaught).

libunwind snapshot - 673484b34189b1bccf73a2ec96968092bc8a26a7
2020-09-07 01:40:57 +02:00
Zahary Karadjov 35eeb035b2
Make the library more friendly to JavaScript and NimScript 2020-06-16 22:09:07 +03:00
Ștefan Talpalaru da216986c6
allow module importing in Nimscript
even though it cannot work in there (a global "--import:libbacktrace"
flag may be applied to *.nims files, so we don't want the import to fail
in that case).
2020-03-31 14:50:21 +02:00
Ștefan Talpalaru dc1f508574
get rid of the last traces of the memory alignment experiment 2020-02-13 11:14:26 +01:00
Ștefan Talpalaru c868d1b62f
export xfree() to Nim 2020-02-11 03:39:19 +01:00
Ștefan Talpalaru 84b40137bb
prevent getBacktrace() from being inlined 2019-12-21 11:34:18 +01:00
Ștefan Talpalaru ad76b8f70a
fix for 32-bit Windows 2019-12-20 03:19:09 +01:00
Ștefan Talpalaru c04aedb805
support Windows by using the bundled libunwind
- use static libraries instead of "compile" pragmas
2019-12-20 03:03:12 +01:00
Ștefan Talpalaru 31ecb78d4c
change the Nim compiler integration mechanism 2019-12-18 21:24:06 +01:00
Ștefan Talpalaru ed57c0cf7c
initial commit 2019-12-18 02:09:27 +01:00