]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
tests: backtrace.c only check we caught the last instruction on x86_64.
authorMark Wielaard <mjw@redhat.com>
Sat, 21 Dec 2013 18:39:19 +0000 (19:39 +0100)
committerMark Wielaard <mjw@redhat.com>
Sat, 21 Dec 2013 18:39:19 +0000 (19:39 +0100)
On some architectures gcc might introduce some "padding instructions"
at the end of the function (like on ppc64). So only assert we are at the
last instruction of backtracegen if on x86_64 native. In theory the assert
could even fail on that architectures, but in practice it doesn't and it
is a nice test to have.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
tests/ChangeLog
tests/backtrace.c

index 0d91c3b2ccff1a4ce1d7d5263ce906c70182a42d..23c5051dab2a0dee420b958079ae23483539b589 100644 (file)
@@ -1,3 +1,8 @@
+2013-12-21  Mark Wielaard  <mjw@redhat.com>
+
+       * backtrace.c (callback_verify): Only assert that case 5 is the last
+       instruction of backtracegen on x86_64 native.
+
 2013-12-18  Jan Kratochvil  <jan.kratochvil@redhat.com>
            Mark Wielaard  <mjw@redhat.com>
 
index 06d3878211c3745b48c69d3bb8ee776a6174ec91..8a7d6dfcb1d0dd5f063a22f040ba26c200eee20c 100644 (file)
@@ -118,7 +118,13 @@ callback_verify (pid_t tid, unsigned frameno, Dwarf_Addr pc,
       mod = dwfl_addrmodule (dwfl, pc);
       if (mod)
        symname2 = dwfl_module_addrname (mod, pc);
-      assert (symname2 == NULL || strcmp (symname2, "backtracegen") != 0);
+
+      // Note that the following assert might in theory even fail on x86_64,
+      // there is no guarantee that the compiler doesn't reorder the
+      // instructions or even inserts some padding instructions at the end
+      // (which apparently happens on ppc64).
+      if (is_x86_64_native)
+        assert (symname2 == NULL || strcmp (symname2, "backtracegen") != 0);
       break;
   }
 }