From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21435 invoked by alias); 10 Mar 2014 03:38:44 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 21419 invoked by uid 89); 10 Mar 2014 03:38:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Mar 2014 03:38:40 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WMr2x-0005bU-Eg from Yao_Qi@mentor.com ; Sun, 09 Mar 2014 20:38:35 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 9 Mar 2014 20:38:35 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.2.247.3; Sun, 9 Mar 2014 20:38:34 -0700 Message-ID: <531D332F.10309@codesourcery.com> Date: Mon, 10 Mar 2014 03:38:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Jan Kratochvil CC: , Aleksandar Ristovski Subject: Re: [PATCH v4 8/8] Tests for validate symbol file using build-id References: <20140302195248.10290.22958.stgit@host1.jankratochvil.net> <20140302195349.10290.47187.stgit@host1.jankratochvil.net> In-Reply-To: <20140302195349.10290.47187.stgit@host1.jankratochvil.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00226.txt.bz2 On 03/03/2014 03:53 AM, Jan Kratochvil wrote: > gdb/testsuite/ > 2014-02-26 Aleksandar Ristovski > Tests for validate symbol file using build-id. > * gdb.base/solib-mismatch-lib.c: New file. > * gdb.base/solib-mismatch-libmod.c: New file. > * gdb.base/solib-mismatch.c: New file. > * gdb.base/solib-mismatch.exp: New file. Since the test is about GDBserver, so IWBN to move them testsuite/gdb.server/ directory. > + > +/* The following defines must correspond to solib-mismatch.exp */ ". " is missing after ".exp". > + > +/* DIRNAME must be defined at compile time. */ "DIRNAME and LIB must be ...." > +#ifndef DIRNAME > +#error DIRNAME not defined > +#endif > +#ifndef LIB > +#error LIB not defined > +#endif > + > diff --git a/gdb/testsuite/gdb.base/solib-mismatch.exp b/gdb/testsuite/gdb.base/solib-mismatch.exp > new file mode 100644 > index 0000000..4b723e0 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/solib-mismatch.exp > @@ -0,0 +1,160 @@ > +# Copyright 2014 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . */ > + > +standard_testfile > +set executable $testfile > + > +if ![is_remote target] { > + untested "only gdbserver supports build-id reporting" > + return -1 > +} > +if { [board_info target sockethost] != "localhost:" } { > + # The testcase below could be fixed for remote targets. > + untested "only gdbserver on localhost is supported (found [board_info target sockethost])" > + return -1 > +} I don't figure out why this test should be only performed against native gdbserver. > + > +# Test overview: > +# generate two shared objects. One that will be used by the process > +# and another, modified, that will be found by gdb. Gdb should > +# detect the mismatch and refuse to use mismatched shared object. > + > +if { [get_compiler_info] } { > + untested "get_compiler_info failed." > + return -1 > +} > + > +# First version of the object, to be loaded by ld. > +set srclibfilerun ${testfile}-lib.c > + > +# Modified version of the object to be loaded by gdb > +# Code in -libmod.c is tuned so it gives a mismatch but > +# leaves .dynamic at the same point. > +set srclibfilegdb ${testfile}-libmod.c > + > +# So file name: > +set binlibfilebase lib${testfile}.so > + > +# Setup run directory (where program is run from) > +# It contains executable and '-lib' version of the library. > +set binlibfiledirrun [standard_output_file ${testfile}_wd] > +set binlibfilerun ${binlibfiledirrun}/${binlibfilebase} > + > +# Second solib version is in current directory, '-libmod' version. > +set binlibfiledirgdb [standard_output_file ""] > +set binlibfilegdb ${binlibfiledirgdb}/${binlibfilebase} > + > +# Executable > +set srcfile ${testfile}.c > +set executable ${testfile} > + > +file delete -force -- "${binlibfiledirrun}" > +file mkdir "${binlibfiledirrun}" > + If test is only run in native-gdbserver, these file operations are fine, otherwise, we may use "rmeote_file target delete" and "remote_exec target mkdir" here. > +set exec_opts {} > + > +if { ![istarget "*-*-nto-*"] } { > + lappend exec_opts "shlib_load" > +} > + > +lappend exec_opts "additional_flags=-DDIRNAME\=\"${binlibfiledirrun}\" -DLIB\=\"./${binlibfilebase}\"" > +lappend exec_opts "debug" > + > +if { [build_executable $testfile.exp $executable $srcfile $exec_opts] != 0 } { > + return -1 > +} > + > +if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfilerun}" "${binlibfilerun}" [list debug ldflags=-Wl,--build-id]] != "" > + || [gdb_gnu_strip_debug "${binlibfilerun}"] > + || [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfilegdb}" "${binlibfilegdb}" [list debug ldflags=-Wl,--build-id]] != "" } { > + untested "compilation failed." > + return -1 > +} > + > +proc solib_matching_test { solibfile symsloaded msg } { > + global gdb_prompt > + global testfile > + global executable > + global srcdir > + global subdir > + global binlibfiledirrun > + global binlibfiledirgdb > + global srcfile > + > + clean_restart ${binlibfiledirrun}/${executable} > + > + gdb_test_no_output "set solib-search-path \"${binlibfiledirgdb}\"" "" > + if { [gdb_test "cd ${binlibfiledirgdb}" "" ""] != 0 } { > + untested "cd ${binlibfiledirgdb}" Caller of proc solib_matching_test emits UNTESTED, so don't have to do it again inside sobli_matching_test. -- Yao (齐尧)