Commit Graph

14 Commits

Author SHA1 Message Date
Mark Wielaard 858e7305de tests: Add break to avoid implicit-fallthrough warning
For some reason gcc might fail to recognize the assert (0) will never
return and emit an implicit-fallthrough warning. Just add a break to
silence it.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2019-12-11 00:33:19 +01:00
Mark Wielaard fe7d3f3635 tests: Remove assert (errno == 0) from tests.
When a function fails it might set errno. But it isn't a guarantee
that if a function succeeds that it sets errno to zero.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2019-01-31 23:18:25 +01:00
Yonghong Song cfaf954701 tests: parse inode in /proc/pid/maps/correctly in run-backtrace-data.sh
The backtrace-data.c parsed the inode in /proc/pid/maps with
format "%*x".
This caused failure if inode is big. For example,
  7f269223d000-7f269226b000 r-xp 00000000 00:50 10224326387095067468       /home/...

The error likes below:
  -bash-4.4$ cat run-backtrace-data.sh.log
  backtrace-data: /home/engshare/elfutils/0.174/src/elfutils-0.174/tests/backtrace-data.c:110:
    maps_lookup: Assertion `errno == 0' failed.
  /home/engshare/elfutils/0.174/src/elfutils-0.174/tests/test-subr.sh: line 84:
    3123578 Aborted                 (core dumped)
    LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" $VALGRIND_CMD "$@"
  data: no main
  -bash-4.4$
The reason is errno is ERANGE.

Fix the test with inode format string "%*u" as inode here is presented
as decimal numbers.

Suggested-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Yonghong Song <yhs@fb.com>
2019-01-31 22:18:10 +01:00
Mark Wielaard 63160fceaa tests: Improve backtrace-data SKIP message.
The backtrace-data testcase is x86_64 linux only because it uses its
own set_initial_registers and scans its own /proc/pid/maps file.
The SKIP message it gave on other platforms was misleading. It said
"Unwinding not supported for this architecture". Change it to
"x86_64 linux only test" to be less confusing.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2018-11-28 13:58:31 +01:00
Ross Burton e893aab0d1 Consolidate error.h inclusion in system.h
error.h isn't standard and so isn't part of the musl C library.
To easy future porting, consolidate the inclusion of error.h into system.h.

https://sourceware.org/bugzilla/show_bug.cgi?id=21008

Signed-off-by: Ross Burton <ross.burton@intel.com>
2018-07-05 21:06:40 +02:00
Ulf Hermann a9d7469866 Make the backtrace-data test helper more robust
When unwinding by frame pointer the unwinder might ask for invalid
addresses. We don't have to fail the test in this case. In fact
any broken dwarf information can lead to requests for invalid
addresses, also without frame pointer unwinding.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
2017-02-14 10:24:36 +01:00
Mark Wielaard a3cc8182b2 Add GCC7 -Wimplicit-fallthrough support/fixes.
GCC7 will have a new -Wimplicit-fallthrough warning. It did catch one
small buglet in elflint option procession. So it seems useful to enable
to make sure all swatch case fallthroughs are deliberate.

Add configure check to detect whether gcc support -Wimplicit-fallthrough
and enable it. Add fixes and explicit fallthrough comments where necessary.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2016-11-10 11:59:00 +01:00
Pino Toscano 65251494ae Reduce scope of some includes
Use some includes only according to the #ifdef block of the respective
code, or matching the fact they are Linux-only.  This way, includes
potentially unportable are not unconditionally used.

Signed-off-by: Pino Toscano <toscano.pino@tiscali.it>
2015-06-27 14:56:12 +02:00
Max Filippov c801acf1cb Replace assert_perror with assert
assert_perror is a GNU extension, it's not provided by uClibc and it's
only used in tests. Replace it with assert.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2015-05-05 10:36:53 +02:00
Kurt Roeckx 02cefdaa64 Unwinding is only supported on Linux
Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
2014-04-23 10:56:01 +02:00
Mark Wielaard 70c3a53baa tests: Don't use ptrace detach stopped trick. Raise can return.
On older kernels the ptrace detach stop trick doesn't work reliably.
Just keep the child processes attached and stopped during the tests,
dwfl_linux_proc_attach will handle that fine now. Also on older kernels
raise would sometimes return anyway and cause a spurious assert. Just
ignore it.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-01-04 23:28:33 +01:00
Mark Wielaard e962ec3bcb libdwfl: Add dwfl_getthread_frames.
dwfl_getthread_frames is a convenience function for when the user is only
interested in one specific thread id of a process. It can be implemented by
a simple wrapper function that removes an extra callback layer just to
filter on thread id. But it also provides an optimized path to getting
access to just one particular Dwfl_Thread of the Dwfl process by providing
and (optional) new callback for the state provider. The pid_thread_callbacks
now provide an (optional) pid_getthread that doesn't need to travers all
threads anymore. Which is implemented for the linux-pid-attach provider.

stack now uses this to implement a new '-1' option that shows just one
specific thread of a process.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-12-23 22:57:22 +01:00
Mark Wielaard 813aae0e94 tests: SKIP backtrace-data and backtrace-dwarf on unsupported arches.
run-backtrace-data.sh did check stderr whether the arch was unsupported
but the test didn't print that message yet. backtrace-dwarf did print
the message but was missing a check_unsupported test. Also add an explicit
check_main test for backtrace-dwarf.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-12-05 15:29:36 +01:00
Jan Kratochvil 8ae9bc9d31 Tests for unwinder of x86*.
Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
2013-12-02 20:54:28 +01:00