Commit Graph

22 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
Ștefan Talpalaru 71af218992
skip internal functions like "raiseExceptionEx.constprop.0" 2021-04-26 19:59:32 +02:00
Ștefan Talpalaru e59f9f1fbf
better detection for missing debugging symbols (#15) 2021-04-26 19:19:47 +02:00
Ștefan Talpalaru f0bbe7eb6b
version 0.0.5 2021-03-14 18:53:33 +01:00
Ștefan Talpalaru d6d449446b
deal with functions inlined into "main()"
and limit the number of "no debugging symbols available" error messages
per stack trace
2021-03-14 18:24:59 +01:00
Timothee Cour cfe5032ddb yuk, using tab to match source 2021-03-13 23:44:40 -08:00
Timothee Cour 74bc7a4c71 fix #9 stacktrace works if triggered by a signal, eg SIGSEGV 2021-03-13 23:37:41 -08: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
Ștefan Talpalaru dc1f508574
get rid of the last traces of the memory alignment experiment 2020-02-13 11:14:26 +01:00
Ștefan Talpalaru 465cb67f23
remove the memory alignment - it was a red herring 2020-02-11 04:31:56 +01:00
Ștefan Talpalaru 6e3808e7bc
replace buggy snprintf() with __mingw_snprintf() on Windows 2020-02-11 04:18:30 +01:00
Ștefan Talpalaru c868d1b62f
export xfree() to Nim 2020-02-11 03:39:19 +01:00
Ștefan Talpalaru ebbe604a27
make xstrdup() use xmalloc() 2020-02-11 03:13:33 +01:00
Ștefan Talpalaru d4909855cf
use _aligned_malloc() and _aligned_free() on Windows 2020-02-11 02:25:29 +01:00
Ștefan Talpalaru a136925305
xmalloc(): align memory to 16 bytes for SSE opcodes 2020-02-11 02:06:10 +01:00
Ștefan Talpalaru 2ec2964d97
more debugging info 2019-12-21 11:25:43 +01:00
Ștefan Talpalaru 9df7ee3b65
debugging support
and avoid returning empty stack traces
2019-12-20 19:06:29 +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 5db221ef07
reset cbd->bt_lineno when skipping lines but continuing the trace 2019-12-18 12:30:13 +01:00
Ștefan Talpalaru 1eab9b317a
plug memory leaks - fixes #1 2019-12-18 12:03:55 +01:00
Ștefan Talpalaru ed57c0cf7c
initial commit 2019-12-18 02:09:27 +01:00