From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 82574 invoked by alias); 23 Nov 2017 13:22:34 -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 82547 invoked by uid 89); 23 Nov 2017 13:22:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=BAYES_00,KAM_SHORT,KB_WAM_FROM_NAME_SINGLEWORD,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy= 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 ESMTP; Thu, 23 Nov 2017 13:22:32 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1933A49039 for ; Thu, 23 Nov 2017 13:22:31 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46E3F60841; Thu, 23 Nov 2017 13:22:30 +0000 (UTC) Subject: Re: [PATCH] linux: Add maintenance commands to test libthread_db To: Gary Benson , gdb-patches@sourceware.org References: <1511361761-1333-1-git-send-email-gbenson@redhat.com> From: Pedro Alves Message-ID: <5e445a82-3238-b4d7-16c5-7e2f079ba453@redhat.com> Date: Thu, 23 Nov 2017 13:22:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1511361761-1333-1-git-send-email-gbenson@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-11/txt/msg00535.txt.bz2 On 11/22/2017 02:42 PM, Gary Benson wrote: > > Built and regtested on RHEL 7.4 x86_64. > > Ok to commit? I noticed you're missing a NEWS entry. Some more comments below. > +static int > +check_thread_db_callback (const td_thrhandle_t *th, void *arg) > +{ > + gdb_assert (tdb_testinfo != NULL); > + tdb_testinfo->threads_seen = true; > + > +#define LOG(fmt, args...) \ > + do \ > + { \ > + if (tdb_testinfo->log_progress) \ > + { \ > + debug_printf (fmt, ## args); \ > + gdb_flush (gdb_stdlog); \ > + } \ > + } \ > + while (0) > + > +#define __CHECK(expr, args...) \ Symbols that start with __ are reserved for the C/C++ implementation. (E.g., glibc would be in the right to define it in some header for its own purposes). You can rename it to CHECK_1 or something like that. > + do \ > + { \ > + if (!(expr)) \ > + { \ > + LOG (" ... FAIL!\n"); \ > + error (args); \ > + } \ > + } \ > + while (0) > + > +#define CHECK(expr) \ > + __CHECK (expr, "(%s) == false", #expr) > + > +#define CHECK_CALL(func, args...) \ > + do \ > + { \ > + td_err_e __err = tdb_testinfo->info->func ## _p (args); \ > + \ > + __CHECK (__err == TD_OK, _("%s failed: %s"), #func, \ > + thread_db_err_str (__err)); \ Likewise __err. > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +# This test only works for native processes on Linux. GNU/Linux, because glibc. > +if { ![isnative] || [is_remote host] || [target_info exists use_gdb_stub] > + || ![istarget *-linux*] } { > + continue I think this fails to filter out --target_board=native-extended-gdbserver ? This would be more to the point, and would work, I think (haven't tested): # This test only works for native processes on GNU/Linux. if {[target_info gdb_protocol] != "" || ![istarget *-linux*]} { continue } > +} > + > +standard_testfile > + > +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ > + executable debug] != "" } { > + return -1 > +} > + > +# TEST 1: Manual check with libthread_db not loaded. Please remove the numbering in "TEST 1", etc. We have a few old testcases that have comments like that, and over the years as tests are added/removed to the file, the numbering gets annoyingly in the way / odd, when inevitably in the future we want to insert a test in the middle, remove or reorder tests, etc. > + > +clean_restart ${binfile} > + > +gdb_test "maint show check-libthread-db" \ > + "Whether to check libthread_db at load time is off." > + > +gdb_test_no_output "set stop-on-solib-events 1" > +gdb_run_cmd > +gdb_test "" \ > + ".*Stopped due to shared library event.*no libraries added or removed.*" > + > +gdb_test "maint check libthread-db" \ > + "No libthread_db loaded" \ > + "libpthread.so not loaded" > + > + > +# TEST 2: Manual check with NPTL uninitialized. > +# libthread_db should fake a single thread with th_unique == NULL. > + > +gdb_test "continue" \ > + ".*Stopped due to shared library event.*Inferior loaded .*libpthread.*" > + > +gdb_test_sequence "maint check libthread-db" \ > + "libpthread.so not initialized (manual)" { > + "\[\r\n\]+Running libthread_db integrity checks:" > + "\[\r\n\]+\[ \]+Got thread 0x0 => \[0-9\]+ => 0x0 ... OK" > + "\[\r\n\]+libthread_db integrity checks passed." > + } > + > + > +# TEST 3: Manual check with NPTL fully operational. > + > +gdb_test_no_output "set stop-on-solib-events 0" > +gdb_breakpoint break_here > +gdb_continue_to_breakpoint break_here > + > +gdb_test_sequence "maint check libthread-db" \ > + "libpthread.so fully initialized (manual)" { > + "\[\r\n\]+Running libthread_db integrity checks:" > + "\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+; errno = 23 ... OK" > + "\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+; errno = 42 ... OK" > + "\[\r\n\]+libthread_db integrity checks passed." > + } > + > + > +# TEST 4: Automated check with NPTL uninitialized. > + > +clean_restart ${binfile} > + > +gdb_test_no_output "maint set check-libthread-db 1" > +gdb_test_no_output "set debug libthread-db 1" > +gdb_breakpoint break_here > +gdb_run_cmd > + > +gdb_test_sequence "" \ > + "libpthread.so not initialized (automated)" { > + "\[\r\n\]+Running libthread_db integrity checks:" > + "\[\r\n\]+\[ \]+Got thread 0x0 => \[0-9\]+ => 0x0 ... OK" > + "\[\r\n\]+libthread_db integrity checks passed." > + "\[\r\n\]+[Thread debugging using libthread_db enabled]" > + } > + > + > +# TEST 5: Automated check with NPTL fully operational. > + > +clean_restart ${binfile} > + > +gdb_test_no_output "maint set check-libthread-db 1" > +gdb_test_no_output "set debug libthread-db 1" > + > +set test_spawn_id [spawn_wait_for_attach $binfile] > +set testpid [spawn_id_get_pid $test_spawn_id] > + > +gdb_test_sequence "attach $testpid" \ > + "libpthread.so fully initialized (automated)" { > + "\[\r\n\]+Running libthread_db integrity checks:" > + "\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+ ... OK" > + "\[\r\n\]+\[ \]+Got thread 0x\[1-9a-f\]\[0-9a-f\]+ => \[0-9\]+ => 0x\[1-9a-f\]\[0-9a-f\]+ ... OK" > + "\[\r\n\]+libthread_db integrity checks passed." > + "\[\r\n\]+[Thread debugging using libthread_db enabled]" > + } > + > + > +gdb_exit > +kill_wait_spawned_process $test_spawn_id > I'm surprised to not see any validation when debugging a core dump. Would it work? Thanks, Pedro Alves