From patchwork Fri Aug 21 21:23:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 8377 Received: (qmail 121621 invoked by alias); 21 Aug 2015 21:24:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 121610 invoked by uid 89); 21 Aug 2015 21:24:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_05, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 21 Aug 2015 21:24:03 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 9CF2091581 for ; Fri, 21 Aug 2015 21:24:02 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7LLO0pL019952 for ; Fri, 21 Aug 2015 17:24:01 -0400 Subject: [PATCH v12 29/32] testcase: Test also locating shlibs by build-id From: Jan Kratochvil To: gdb-patches@sourceware.org Date: Fri, 21 Aug 2015 23:23:59 +0200 Message-ID: <20150821212359.6673.90456.stgit@host1.jankratochvil.net> In-Reply-To: <20150821212006.6673.35100.stgit@host1.jankratochvil.net> References: <20150821212006.6673.35100.stgit@host1.jankratochvil.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-IsSubscribed: yes Hi, testcase from the previous patch tests verification of build-id in shared libraries found by their name. This test adds testing that a library can be found by its build-id (debug-file-directory/.build-id/XX/YYYYY...YYYYY). Jan gdb/testsuite/ChangeLog 2015-08-20 Jan Kratochvil * gdb.base/solib-mismatch.exp (nocrlf, expected_header): Make them global. (solib_locate_test): New function. --- gdb/testsuite/gdb.base/solib-mismatch.exp | 46 ++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.base/solib-mismatch.exp b/gdb/testsuite/gdb.base/solib-mismatch.exp index 4983429..4ae8ac8 100644 --- a/gdb/testsuite/gdb.base/solib-mismatch.exp +++ b/gdb/testsuite/gdb.base/solib-mismatch.exp @@ -59,6 +59,10 @@ set binlibfilegdb ${binlibfiledirgdb}/${binlibfilebase} set srcfile ${testfile}.c set executable ${testfile} +# Pattern matching for 'info sharedlibrary'. +set nocrlf "\[^\r\n\]*" +set expected_header "From${nocrlf}To${nocrlf}Syms${nocrlf}Read${nocrlf}Shared${nocrlf}" + file delete -force -- "${binlibfiledirrun}" file mkdir "${binlibfiledirrun}" @@ -91,6 +95,8 @@ proc solib_matching_test { solibfile symsloaded } { global binlibfiledirrun global binlibfiledirgdb global srcfile + global expected_header + global nocrlf clean_restart ${binlibfiledirrun}/${executable} @@ -110,8 +116,6 @@ proc solib_matching_test { solibfile symsloaded } { gdb_test "sharedlibrary" "" "" - set nocrlf "\[^\r\n\]*" - set expected_header "From${nocrlf}To${nocrlf}Syms${nocrlf}Read${nocrlf}Shared${nocrlf}" set expected_line "${symsloaded}${nocrlf}${solibfile}" gdb_test "info sharedlibrary ${solibfile}" \ @@ -121,6 +125,23 @@ proc solib_matching_test { solibfile symsloaded } { return 0 } +proc solib_locate_test { solibfile symsloaded } { + global binlibfiledirrun + global binlibfilerun + global nocrlf + global expected_header + + gdb_test_no_output "set debug-file-directory ${binlibfiledirrun}" "" + gdb_test_no_output "nosharedlibrary" "" + gdb_test "sharedlibrary" "" "" + + set expected_line "${symsloaded}${nocrlf}${solibfile}" + + gdb_test "info sharedlibrary ${solibfile}" \ + "${expected_header}\r\n.*${expected_line}.*" \ + "Symbols for ${solibfile} loaded: expected '${symsloaded}'" +} + # Copy binary to working dir so it pulls in the library from that dir # (by the virtue of $ORIGIN). file copy -force "${binlibfiledirgdb}/${executable}" \ @@ -144,9 +165,30 @@ with_test_prefix "test --only-keep-debug" { solib_matching_test "${binlibfilebase}" "No" } +# Test locating file by its build-id - if the regular filename does not match. +# build-id file has to be a symlink - otherwise so_list->so_name shown in 'info +# sharedlibrary' would contain the build-id hash and not the library name. +set build_id_debug_relative [build_id_debug_filename_get $binlibfilerun] +if { ![regexp {^(.*)\.debug$} $build_id_debug_relative trash build_id_relative] } { + fail "strip debug $build_id_debug_relative" + return +} +set build_id_filename "${binlibfiledirrun}/$build_id_relative" +file mkdir [file dirname $build_id_filename] +remote_exec host "ln -sf $binlibfilerun $build_id_filename" +with_test_prefix "locate non-matching shared library" { + solib_locate_test "${binlibfilebase}" "Yes" +} + # Keep previous so for debugging puroses file copy -force "${binlibfilegdb}" "${binlibfilegdb}-orig1" +# Test locating file by its build-id - if the regular filename does not exist. +file delete -force "${binlibfilegdb}" +with_test_prefix "locate non-existing shared library" { + solib_locate_test "${binlibfilebase}" "Yes" +} + # Copy loaded so over the one gdb will find file copy -force "${binlibfilerun}" "${binlibfilegdb}"