From patchwork Wed Nov 8 21:25:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 24168 Received: (qmail 13375 invoked by alias); 8 Nov 2017 21:26:36 -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 13352 invoked by uid 89); 8 Nov 2017 21:26:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-Spam-User: qpsmtpd, 2 recipients X-HELO: 19pmail.ess.barracuda.com Received: from 19pmail.ess.barracuda.com (HELO 19pmail.ess.barracuda.com) (64.235.150.244) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Nov 2017 21:26:34 +0000 Received: from MIPSMAIL01.mipstec.com (mailrelay.mips.com [12.201.5.28]) by mx28.ess.sfj.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Wed, 08 Nov 2017 21:25:40 +0000 Received: from [10.20.78.183] (10.20.78.183) by mips01.mipstec.com (10.20.43.31) with Microsoft SMTP Server id 14.3.361.1; Wed, 8 Nov 2017 13:25:38 -0800 Date: Wed, 8 Nov 2017 21:25:27 +0000 From: "Maciej W. Rozycki" To: Pedro Alves CC: Djordje Todorovic , , , "nemanja.popov@rt-rk.com" , , "Ananthakrishna Sowda (asowda)" , Nikola Prica Subject: [committed v7 3/3] Add test for fetching TLS from core file In-Reply-To: Message-ID: References: <74618d56-fa31-4cfe-329f-6a9078bac92b@rt-rk.com> <724f0bc9-6744-a915-d19d-77db7e9ce514@rt-rk.com> <64ad38a4-b8ae-912e-45d6-7048135ada2e@rt-rk.com> <8475f0b7-969d-3c27-27f2-a4944e58e954@rt-rk.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 X-BESS-ID: 1510176339-637138-27155-933384-8 X-BESS-VER: 2017.12-r1710252241 X-BESS-Apparent-Source-IP: 12.201.5.28 X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.186733 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 From: Djordje Todorovic A correct PID is needed by `libthread_db' library supplied with glibc repository revisions before commit c579f48edba8 ("Remove cached PID/TID in clone") or versions before 2.25 release for GDB to fetch value of TLS variable from core file. On MIPS platforms it was omitted and fetching value of TLS variable was not available. This adds a new test in order to be sure if GDB on native platforms can successfully fetch value of TLS variable. gdb/testsuite: * gdb.threads/tls-core.c: New file. * gdb.threads/tls-core.exp: Likewise. --- gdb/testsuite/gdb.threads/tls-core.c | 37 +++++++++++++++++++++ gdb/testsuite/gdb.threads/tls-core.exp | 56 +++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 gdb/testsuite/gdb.threads/tls-core.c create mode 100644 gdb/testsuite/gdb.threads/tls-core.exp Index: binutils/gdb/testsuite/gdb.threads/tls-core.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils/gdb/testsuite/gdb.threads/tls-core.c 2017-11-07 21:06:38.057852979 +0000 @@ -0,0 +1,37 @@ +/* This test is part of GDB, the GNU debugger. + + Copyright 2017 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 . */ + +#include + +int __thread foo = 0xdeadbeef; + +static void * +thread_proc (void *arg) +{ + return arg; +} + +int +main (void) +{ + pthread_t thread; + + pthread_create (&thread, NULL, thread_proc, NULL); + pthread_join (thread, NULL); + + return 0; +} Index: binutils/gdb/testsuite/gdb.threads/tls-core.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ binutils/gdb/testsuite/gdb.threads/tls-core.exp 2017-11-07 21:40:30.604166048 +0000 @@ -0,0 +1,56 @@ +# Copyright 2017 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 + +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ + executable { debug }] != "" } { + return -1 +} + + +clean_restart ${binfile} + +runto thread_proc + +# +# Generate corefile. +# +set corefile [standard_output_file gcore.test] +set core_supported [gdb_gcore_cmd "$corefile" "save a corefile"] +if {!$core_supported} { + return 0 +} + +# +# Restart gdb and load generated corefile. +# +clean_restart ${binfile} + +set core_loaded [gdb_core_cmd "$corefile" "load generated corefile"] +if { $core_loaded != 1 } { + # No use proceeding from here. + return 0 +} + +# This fails in cross-debugging due to the use of native `libthread_db'. +if {![string match $host_triplet $target_triplet]} { + setup_kfail "threads/22381" "*-*-*" +} +gdb_test "p/x foo" \ + "\\$\[0-9]+ = 0xdeadbeef" \ + "print thread-local storage variable" + +gdb_exit