diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2017-08-24 16:09:48 +0200 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2018-10-18 02:51:51 +0200 |
commit | 68b8a15f87cfaf9aff1d483abb037005c237fb24 (patch) | |
tree | 771365083373b2f0824c70665011b09f2bfa5508 /tests/lib | |
parent | Merge pull request #3192 from lkrishnamoor/evpn_route_server (diff) | |
download | frr-68b8a15f87cfaf9aff1d483abb037005c237fb24.tar.xz frr-68b8a15f87cfaf9aff1d483abb037005c237fb24.zip |
lib: add libunwind support for backtraces
libunwind provides an alternate to backtrace() for printing out the call
stack of a particular location. It doesn't use the frame pointer, it
goes by the DWARF debug info. In most cases the traces have exactly the
same information, but there are some situations where libunwind traces
are better.
(On some platforms, the libc backtrace() also uses the DWARF debug info
[e.g.: ARM backtraces are impossible without it] but this is not the
case everywhere, especially not on BSD libexecinfo.)
Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/test_segv.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/lib/test_segv.c b/tests/lib/test_segv.c index 3c9b57f04..43ca0837d 100644 --- a/tests/lib/test_segv.c +++ b/tests/lib/test_segv.c @@ -32,10 +32,39 @@ struct quagga_signal_t sigs[] = {}; struct thread_master *master; -static int threadfunc(struct thread *thread) +void func1(int *arg); +void func3(void); + +void func1(int *arg) { int *null = NULL; *null += 1; + *arg = 1; +} + +static void func2(size_t depth, int *arg) +{ + /* variable stack frame size */ + int buf[depth]; + for (size_t i = 0; i < depth; i++) + buf[i] = arg[i] + 1; + if (depth > 0) + func2(depth - 1, buf); + else + func1(&buf[0]); + for (size_t i = 0; i < depth; i++) + buf[i] = arg[i] + 2; +} + +void func3(void) +{ + int buf[6]; + func2(6, buf); +} + +static int threadfunc(struct thread *thread) +{ + func3(); return 0; } |