[PATCH 1/4] Add missing tests to .gitignore
Some test binaries were missing and showed up in "git status". Signed-off-by: Ulf Hermann --- .gitignore | 12 1 file changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index c583347..0ee3af7 100644 --- a/.gitignore +++ b/.gitignore @@ -93,6 +93,7 @@ Makefile.in /tests/asm-tst9 /tests/backtrace /tests/backtrace-child +/tests/backtrace-child-biarch /tests/backtrace-data /tests/backtrace-dwarf /tests/buildid @@ -102,18 +103,26 @@ Makefile.in /tests/dwarf-getmacros /tests/dwarf-getstring /tests/dwarf-ranges +/tests/dwelfgnucompressed /tests/dwfl-addr-sect /tests/dwfl-bug-addr-overflow /tests/dwfl-bug-fd-leak /tests/dwfl-bug-getmodules /tests/dwfl-bug-report +/tests/dwfl-proc-attach /tests/dwfl-report-elf-align /tests/dwfllines /tests/dwflmodtest /tests/dwflsyms /tests/early-offscn /tests/ecp +/tests/elfgetchdr +/tests/elfgetzdata +/tests/elfputzdata +/tests/elfshphehdr +/tests/elfstrmerge /tests/elfstrtab +/tests/emptyfile /tests/find-prologues /tests/funcretval /tests/funcscopes @@ -139,6 +148,7 @@ Makefile.in /tests/show-die-info /tests/showptable /tests/strptr +/tests/system-elf-libelf-test /tests/test-elf_cntl_gelf_getshdr /tests/test-flag-nobits /tests/test-nlist @@ -149,5 +159,7 @@ Makefile.in /tests/update3 /tests/update4 /tests/varlocs +/tests/vendorelf /tests/vdsosyms +/tests/zstrptr /version.h -- 2.1.4
[PATCH 2/4] 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 --- tests/ChangeLog| 6 ++ tests/backtrace-data.c | 16 +--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index 7031cf5..7040ac8 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2017-02-09 Ulf Hermann + + * backtrace-data.c: Don't assert that symbols are found. + The unwinder is allowed to ask for invalid addresses. We deny + such requests, rather than make the test fail. + 2016-11-17 Mark Wielaard * run-readelf-s.sh: Add --symbols=.dynsym and --symbols=.symtab tests. diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c index b7158da..a387d8f 100644 --- a/tests/backtrace-data.c +++ b/tests/backtrace-data.c @@ -76,10 +76,15 @@ memory_read (Dwfl *dwfl, Dwarf_Addr addr, Dwarf_Word *result, errno = 0; long l = ptrace (PTRACE_PEEKDATA, child, (void *) (uintptr_t) addr, NULL); - assert (errno == 0); + + // The unwinder can ask for an invalid address. + // Don't assert on that but just politely refuse. + if (errno != 0) { + errno = 0; + return false; + } *result = l; - /* We could also return false for failed ptrace. */ return true; } @@ -103,7 +108,8 @@ maps_lookup (pid_t pid, Dwarf_Addr addr, GElf_Addr *basep) unsigned long start, end, offset; i = fscanf (f, "%lx-%lx %*s %lx %*x:%*x %*x", &start, &end, &offset); assert (errno == 0); - assert (i == 3); + if (i != 3) + break; char *filename = strdup (""); assert (filename); size_t filename_len = 0; @@ -131,6 +137,8 @@ maps_lookup (pid_t pid, Dwarf_Addr addr, GElf_Addr *basep) } free (filename); } + *basep = 0; + return NULL; } /* Add module containing ADDR to the DWFL address space. @@ -145,6 +153,8 @@ report_module (Dwfl *dwfl, pid_t child, Dwarf_Addr addr) { GElf_Addr base; char *long_name = maps_lookup (child, addr, &base); + if (!long_name) + return NULL; // not found Dwfl_Module *mod = dwfl_report_elf (dwfl, long_name, long_name, -1, base, false /* add_p_vaddr */); assert (mod); -- 2.1.4
[PATCH 3/4] Optionally allow unknown symbols in the backtrace tests
This is useful to test unwinding without debug information. The binaries being examined might still have frame pointers that allow us to bridge the unknown symbols. Signed-off-by: Ulf Hermann --- tests/ChangeLog | 6 ++ tests/backtrace-subr.sh | 14 ++ tests/backtrace.c | 30 ++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index 7040ac8..bca47be 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,5 +1,11 @@ 2017-02-09 Ulf Hermann + * backtrace.c: Add an option to allow unknown symbols in the trace + * backtrace-substr.sh: Add an option to allow unknown symbols + to check_core() and allow failed symbol lookups in check_err() + +2017-02-09 Ulf Hermann + * backtrace-data.c: Don't assert that symbols are found. The unwinder is allowed to ask for invalid addresses. We deny such requests, rather than make the test fail. diff --git a/tests/backtrace-subr.sh b/tests/backtrace-subr.sh index 790b4f4..5d3937c 100644 --- a/tests/backtrace-subr.sh +++ b/tests/backtrace-subr.sh @@ -44,9 +44,12 @@ check_gsignal() # In some cases we cannot reliably find out we got behind _start as some # operating system do not properly terminate CFI by undefined PC. # Ignore it here as it is a bug of OS, not a bug of elfutils. +# If the CFI is not terminated correctly, we might find another frame by +# checking for frame pointers. This is still not our problem, but only +# gives an error message when trying to look up the function name. check_err() { - if [ $(egrep -v <$1 'dwfl_thread_getframes: (No DWARF information found|no matching address range)$' \ + if [ $(egrep -v <$1 'dwfl_thread_getframes: (No DWARF information found|no matching address range|address out of range)$' \ | wc -c) \ -eq 0 ] then @@ -61,7 +64,9 @@ check_all() bt=$1 err=$2 testname=$3 - check_main $bt $testname + if [ "x$4" != "x--allow-unknown" ]; then +check_main $bt $testname + fi check_gsignal $bt $testname check_err $err $testname } @@ -98,13 +103,14 @@ check_native_unsupported() check_core() { arch=$1 + args=$2 testfiles backtrace.$arch.{exec,core} tempfiles backtrace.$arch.{bt,err} echo ./backtrace ./backtrace.$arch.{exec,core} - testrun ${abs_builddir}/backtrace -e ./backtrace.$arch.exec --core=./backtrace.$arch.core 1>backtrace.$arch.bt 2>backtrace.$arch.err || true + testrun ${abs_builddir}/backtrace $args -e ./backtrace.$arch.exec --core=./backtrace.$arch.core 1>backtrace.$arch.bt 2>backtrace.$arch.err || true cat backtrace.$arch.{bt,err} check_unsupported backtrace.$arch.err backtrace.$arch.core - check_all backtrace.$arch.{bt,err} backtrace.$arch.core + check_all backtrace.$arch.{bt,err} backtrace.$arch.core $args } # Backtrace live process. diff --git a/tests/backtrace.c b/tests/backtrace.c index 1ff6353..34a2ab0 100644 --- a/tests/backtrace.c +++ b/tests/backtrace.c @@ -64,6 +64,7 @@ dump_modules (Dwfl_Module *mod, void **userdata __attribute__ ((unused)), return DWARF_CB_OK; } +static bool allow_unknown; static bool use_raise_jmp_patching; static pid_t check_tid; @@ -78,7 +79,8 @@ callback_verify (pid_t tid, unsigned frameno, Dwarf_Addr pc, seen_main = true; if (pc == 0) { - assert (seen_main); + if (!allow_unknown) +assert (seen_main); return; } if (check_tid == 0) @@ -103,11 +105,12 @@ callback_verify (pid_t tid, unsigned frameno, Dwarf_Addr pc, && (strcmp (symname, "__kernel_vsyscall") == 0 || strcmp (symname, "__libc_do_syscall") == 0)) reduce_frameno = true; - else + else if (!allow_unknown || symname) assert (symname && strcmp (symname, "raise") == 0); break; case 1: - assert (symname != NULL && strcmp (symname, "sigusr2") == 0); + if (!allow_unknown || symname) +assert (symname != NULL && strcmp (symname, "sigusr2") == 0); break; case 2: // x86_64 only /* __restore_rt - glibc maybe does not have to have this symbol. */ @@ -116,20 +119,24 @@ callback_verify (pid_t tid, unsigned frameno, Dwarf_Addr pc, if (use_raise_jmp_patching) { /* Verify we trapped on the very first instruction of jmp. */ - assert (symname != NULL && strcmp (symname, "jmp") == 0); + if (!allow_unknown || symname) +assert (symname != NULL && strcmp (symname, "jmp") == 0); mod = dwfl_addrmodule (dwfl, pc - 1); if (mod) symname2 = dwfl_module_addrname (mod, pc - 1); - assert (symname2 == NULL || strcmp (symname2, "jmp") != 0); + if (!allow_unknown || symname2) +assert (symname2 == NULL || strcmp (symname2, "jmp") != 0); break; } /* FALLTHRU */ case 4: - assert (symname != NULL && strcmp (symname, "stdarg") == 0); +
Re: [PATCH 3/4] Optionally allow unknown symbols in the backtrace tests
Hi, I have another patch here, that introduces the actual feature; a fallback mode for unwinding by frame pointer if unwinding by cfi fails. Unfortunately your mail server thinks it's spam, presumably because of the inline test binaries. What can I do about that? br, Ulf Hermann
Re: [PATCH 3/4] Optionally allow unknown symbols in the backtrace tests
On Fri, 2017-02-10 at 15:25 +0100, Ulf Hermann wrote: > I have another patch here, that introduces the actual feature; a > fallback mode for unwinding by frame pointer if unwinding by cfi > fails. That sounds like a useful feature! > Unfortunately your mail server thinks it's spam, presumably because of > the inline test binaries. What can I do about that? Do you have the bounce message, then we can investigate. Otherwise could you post the patch without the test binaries? Then we get them some other way. Although I am surprised the mailinglist rejects the output of git send-email. It really shouldn't, so having the bounce message would be good (we can then discuss on overseers@... to see what really happened). Thanks, Mark
Re: [PATCH 3/4] Optionally allow unknown symbols in the backtrace tests
Unfortunately your mail server thinks it's spam, presumably because of the inline test binaries. What can I do about that? Do you have the bounce message, then we can investigate. Otherwise could you post the patch without the test binaries? Then we get them some other way. The bounce message is somewhat messy, containing inline html and attachments. This is a somewhat readable text representation: Your message to elfutils-devel@sourceware.org couldn't be delivered. sourceware.org suspects your message is spam and rejected it. ulf.hermann Office 365 sourceware.org Sender Action Required Messages suspected as spam How to Fix It Try to modify your message, or change how you're sending the message, using the guidance in this article: Bulk E-mailing Best Practices for Senders Using Forefront Online Protection for Exchange. Then resend your message. If you continue to experience the problem, contact the recipient by some other means (by phone, for example) and ask them to ask their email admin to add your email address, or your domain name, to their allowed senders list. Was this helpful? Send feedback to Microsoft. More Info for Email Admins Status code: 550 5.7.350 When Office 365 tried to send the message to the recipient (outside Office 365), the recipient's email server (or email filtering service) suspected the sender's message is spam. If the sender can't fix the problem by modifying their message, contact the recipient's email admin and ask them to add your domain name, or the sender's email address, to their list of allowed senders. Although the sender may be able to alter the message contents to fix this issue, it's likely that only the recipient's email admin can fix this problem. Unfortunately, Office 365 Support is unlikely to be able to help fix these kinds of externally reported errors. Original Message Details Created Date: 2/10/2017 2:20:21 PM Sender Address: ulf.herm...@qt.io Recipient Address: elfutils-devel@sourceware.org Subject:[PATCH 4/4] Add frame pointer unwinding as fallback on x86_64 Error Details Reported error: 550 5.7.350 Remote server returned message detected as spam -> 552 spam score exceeded threshold DSN generated by: VI1PR0201MB1869.eurprd02.prod.outlook.com Remote server: sourceware.org Message Hops HOP TIME (UTC) FROMTO WITHRELAY TIME 1 2/10/2017 2:20:22 PM [10.9.78.60]VI1PR0201MB1869.eurprd02.prod.outlook.com Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) 1 sec Original Message Headers DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qtcompany.onmicrosoft.com; s=selector1-qt-io; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=j1DH0w0/pXTH2S/0HIhEj4Ruuawzgt1pBNwl4lbKAqU=; b=F8/u6gSVjlPl4d34hVp3S0ehZJGze8mXCGjPHO++IwhFa61XiFtanOSgXWvVgEgeRAv4sdbP3Dx0J3Q32sJFUdkdUMP7qg9ea+2SGGeCX5/aUvxOCFZqcT1bdRFyIfAURQNNPHSGaTk9IsaFb4n6VhZWwKBV0RD3P5G1b//DpLA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ulf.herm...@qt.io; Received: from [10.9.78.60] (62.220.2.194) by VI1PR0201MB1869.eurprd02.prod.outlook.com (10.167.206.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Fri, 10 Feb 2017 14:20:22 + From: Ulf Hermann Subject: [PATCH 4/4] Add frame pointer unwinding as fallback on x86_64 To: Message-ID: <6007c160-b26f-a757-d00b-d40b4c582...@qt.io> Date: Fri, 10 Feb 2017 15:20:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [62.220.2.194] X-ClientProxiedBy: DB5PR03CA0083.eurprd03.prod.outlook.com (10.164.34.51) To VI1PR0201MB1869.eurprd02.prod.outlook.com (10.167.206.147) Return-Path: ulf.herm...@qt.io X-MS-Office365-Filtering-Correlation-Id: ec09c7eb-12da-48b3-ab58-08d451bff373 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:VI1PR0201MB1869; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0201MB1869;3:R1nBXKiZxfHImwXYgHnoCPlwj548vce+nOHis8TgdLGSGnWq5EpPzVdJg4gykOxZ76C0AQs+CdNH+WCTGZ52qcic1z3f8trei8HMHtrcRYK4DyWEWjzujBCtD+ckfl4r+8iYRtAVkOcnrWCTK951whAvXK9QpZYjO3LuLsfOaVAzsjwq1hYSCtcsjFSUUkswBvZNkkCmUwYdckggdmLTN7IpgyUQN3KLo6+IDtn9tuvmcVJk//HmpelY1wFN3XFeJGcRbyzGYFucG4+ETmhRww==;25:PW9H6AvU67yyWrJz4zsRyDMdEgQSeVltnnJvsN/Vs7hGTdQ5EZd6xRVKlQ3v1QaD6KNjU+rgPp4BbbI/swQOWx1DjztURFfPqmaDWAxLeBI+djpCH9Dp+MQH7sPPSQyHCeW0FU0Rxg+5o4Wh8JQaidmKe3DrUyN0OW/9N6qw9XcS7+d7TeyhXBI6jVSBTstqhe8L3M8x7XD49aIHGOIkMrEIKPxo18ht6Xrgt5yhp2pv7HqDEaKoBYZbh7nNYIdmIUhnjuTC6P3ROIPqyNoidVEleaSzL4ATISomo6IWWx6bMtVFm3Ci5BDPM08CPzWak6u/FhQifXqnfO14RP03qY9q377tksmbHyxmiEhgP1FStP3vFd/u43XbkeyRVXA1RES12WTWhwlXPKVHQCqmWajEPkXYEMay0FYVjx1FSaQg8ia6F1edoskLWr+rrBfbjjF+qCP9IpLMwjINf40qwA== X-Microsoft-
Re: [PATCH 3/4] Optionally allow unknown symbols in the backtrace tests
Try sending suspicious content via something like fpaste.org. I don't think it's very suspicious, but I don't intend to start a pointless argument as first thing I do here ;) fpaste.org won't accept it either, but paste.kde.org does. So, here we go: https://paste.kde.org/pgs6oqk2z br, Ulf Hermann