Hello!

That's a good fix for the tests, which changes the expected results from nonsense to sensible things.

The problem must stem from the fact that on x86_64 the code is optimized and doesn't follow the ABI for library-internal function calls (therefore ltrace printed nonsense as result, and that was saved into the tests), whereas on x86 (32bit) the ABI is followed, but some noise is added by GCC into the code (the "thunk" calls; I've just found some explanation for what this is at https://ewontfix.com/18/ : "32-bit x86 Position Independent Code").

For illustrative purpose (for future developers) I would leave also the old code without that workaround against optimization which gives wrong ltrace results on x86_64 as "X-Fail" tests (if that is available in dejagnu). So that this challenge remains visible to future developers of ltrace: librarry-internal calls are quite complicate to trace.

(It's better to post a series of patches as a series of separate messages, so that discussion can continue in threads.)

--
Best regards,
Ivan
>From 35e258e47b0f25a21501b4f242503dd6ae563a04 Mon Sep 17 00:00:00 2001
From: Grigory Ustinov <[email protected]>
Date: Wed, 22 Nov 2017 09:55:41 +0300
Subject: [PATCH 4/5] Fix errors in tests

- Add printf for disable compiler optimization even with -O0
- Correct output of function treetest
- Add more "-x" options to exclude __x86.get_pc_thunk calls
---
 testsuite/ltrace.main/dwarf.exp  | 20 ++++++++++----------
 testsuite/ltrace.main/dwarflib.c |  4 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/testsuite/ltrace.main/dwarf.exp b/testsuite/ltrace.main/dwarf.exp
index 7af7d99..faa6d39 100644
--- a/testsuite/ltrace.main/dwarf.exp
+++ b/testsuite/ltrace.main/dwarf.exp
@@ -56,10 +56,10 @@ set ltrace_opts_l {"-A5" "-l" "libdwarftest.so"}
 set ref_output_l [subst -nocommands -novariables {
 dwarf->linkedlisttest({ 5, nil }) * = <void>
 dwarf->treetest({ 1, { 2, nil, nil }, { 3, nil, { 4, nil, nil } } } <unfinished ...>
-libdwarftest.so->treetest({ 2, nil, nil }) * = nil
+libdwarftest.so->treetest({ 2, nil, nil }) * = { 3, nil, nil }
 libdwarftest.so->treetest({ 3, nil, { 4, nil, nil } } <unfinished ...>
-libdwarftest.so->treetest({ 4, nil, nil }) * = nil
-<... treetest resumed> ) * = { 5, nil, nil }
+libdwarftest.so->treetest({ 4, nil, nil }) * = { 5, nil, nil }
+<... treetest resumed> ) * = { 4, nil, { 5, nil, nil } }
 <... treetest resumed> ) * = { 2, { 3, nil, nil }, { 4, nil, { 5, nil, nil } } }
 dwarf->looptest({ { recurse^, 6 }, 5 }) * = <void>
 dwarf->enumtest(A, B) * = 0
@@ -84,14 +84,14 @@ libdwarftest.so->f55(Colors5)(RED5) * = RED5
 } ]
 run_dwarf_test $ref_output_demangling $ltrace_opts_demangling
 
-set ltrace_opts_x {"-A5" "-L" "-x" "@libdwarftest.so"}
+set ltrace_opts_x {"-A5" "-L" "-x" "*test*@libdwarftest.so" "-x" "*Color*@libdwarftest.so" "-x" "*void*@libdwarftest.so"}
 set ref_output_x [subst -nocommands -novariables {
 [email protected]({ 5, nil }) * = <void>
 [email protected]({ 1, { 2, nil, nil }, { 3, nil, { 4, nil, nil } } } <unfinished ...>
[email protected]({ 2, nil, nil }) * = nil
[email protected]({ 2, nil, nil }) * = { 3, nil, nil }
 [email protected]({ 3, nil, { 4, nil, nil } } <unfinished ...>
[email protected]({ 4, nil, nil }) * = nil
-<... treetest resumed> ) * = { 5, nil, nil }
[email protected]({ 4, nil, nil }) * = { 5, nil, nil }
+<... treetest resumed> ) * = { 4, nil, { 5, nil, nil } }
 <... treetest resumed> ) * = { 2, { 3, nil, nil }, { 4, nil, { 5, nil, nil } } }
 [email protected]({ { recurse^, 6 }, 5 }) * = <void>
 [email protected](A, B) * = 0
@@ -110,10 +110,10 @@ run_dwarf_test $ref_output_x $ltrace_opts_x
 
 set ltrace_opts_e {"-A5" "-e" "@libdwarftest.so"}
 set ref_output_e [subst -nocommands -novariables {
-libdwarftest.so->treetest({ 2, nil, nil }) * = nil
+libdwarftest.so->treetest({ 2, nil, nil }) * = { 3, nil, nil }
 libdwarftest.so->treetest({ 3, nil, { 4, nil, nil } } <unfinished ...>
-libdwarftest.so->treetest({ 4, nil, nil }) * = nil
-<... treetest resumed> ) * = { 5, nil, nil }
+libdwarftest.so->treetest({ 4, nil, nil }) * = { 5, nil, nil }
+<... treetest resumed> ) * = { 4, nil, { 5, nil, nil } }
 libdwarftest.so->_Z3f127Colors2(GREEN2) * = RED1
 libdwarftest.so->_Z3f347Colors4(BLUE4) * = RED3
 libdwarftest.so->_Z3f557Colors5(RED5) * = RED5
diff --git a/testsuite/ltrace.main/dwarflib.c b/testsuite/ltrace.main/dwarflib.c
index 2402400..85b171e 100644
--- a/testsuite/ltrace.main/dwarflib.c
+++ b/testsuite/ltrace.main/dwarflib.c
@@ -24,8 +24,8 @@ void linkedlisttest( struct list* l )
 
 struct tree treetest(struct tree* t)
 {
-    if(t->left  != NULL) treetest(t->left);
-    if(t->right != NULL) treetest(t->right);
+    if(t->left  != NULL) printf("%d",treetest(t->left).x);
+    if(t->right != NULL) printf("%d",treetest(t->right).x);
     t->x++;
 
     return *t;
-- 
2.10.4

_______________________________________________
Ltrace-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/ltrace-devel

Reply via email to