From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33578 invoked by alias); 17 May 2019 16:26:24 -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 33569 invoked by uid 89); 17 May 2019 16:26:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Spam-Relays-External:209.85.221.68, H*RU:209.85.221.68, restart, HX-Languages-Length:1730 X-HELO: mail-wr1-f68.google.com Received: from mail-wr1-f68.google.com (HELO mail-wr1-f68.google.com) (209.85.221.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 May 2019 16:26:23 +0000 Received: by mail-wr1-f68.google.com with SMTP id m3so7618737wrv.2 for ; Fri, 17 May 2019 09:26:23 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:4eeb:42ff:feef:f164? ([2001:8a0:f913:f700:4eeb:42ff:feef:f164]) by smtp.gmail.com with ESMTPSA id v20sm5605065wmj.10.2019.05.17.09.26.20 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Fri, 17 May 2019 09:26:20 -0700 (PDT) Subject: Re: [PATCH] Add "thread-exited" annotation To: Amos Bird , Simon Marchi References: <87d0l8pzdz.fsf@gmail.com> <87ef5j33au.fsf@tromey.com> <87ftpzo1wa.fsf@gmail.com> <20190516131419.GA29999@blade.nx> <87ftpepk1l.fsf@gmail.com> <83d0kicvs6.fsf@gnu.org> <87ef4ypif5.fsf@gmail.com> <441e0b74-a391-2d68-e5d3-f43f1b8da188@simark.ca> <87r28xciz3.fsf@gmail.com> <87pnohcc5t.fsf@gmail.com> Cc: Eli Zaretskii , gbenson@redhat.com, gdb-patches@sourceware.org, tom@tromey.com From: Pedro Alves Message-ID: <070c42f3-78bd-e605-3f9d-e708f3f0a65c@redhat.com> Date: Fri, 17 May 2019 16:26:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <87pnohcc5t.fsf@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-05/txt/msg00433.txt.bz2 On 5/17/19 4:51 PM, Amos Bird wrote: > +proc thread_exit {} { > + global decimal > + gdb_test_multiple "call (void)pthread_exit()" "thread exit" { Since this is calling a function, it would need to be gated with a gdb,cannot_call_functions check (grep for uses). Does that call return? If the thread exits, the "call" command will continue running without returning to the prompt, right? I guess that's why you don't expect the prompt here: > + gdb_test_multiple "call (void)pthread_exit()" "thread exit" { > + -re ".*\032\032thread-exited,id=\"${decimal}\",group-id=\"i${decimal}\"" { > + pass "thread exit" > + } > + } > +} Note that this approach means that if someone were to add a test after this one, we'd need to either ctrl-c the program, or restart gdb. Please test this with make check RUNTESTFLAGS="--target_board=native-gdbserver" too. In that case, you're debugging with gdbserver, and gdb/gdbserver won't notice that the thread exited until the program next stops. Also, you probably don't have debug info for glibc/libpthread in your system. I say this because pthread_exit takes an argument and above you're not passing any, resulting in undefined behavior. I'd be much better if the .c file were tweaked to make the thread exit on its own, or a new .c file were added for that purpose, IMO. E.g., make the main thread join a child thread and hit a breakpoint once the thread exits and the join unlocks. > + -re ".*\032\032thread-exited,id=\"${decimal}\",group-id=\"i${decimal}\"" { > + pass "thread exit" > + } > + } > +} > + > thread_test > thread_switch > +thread_exit > > # restore the original prompt for the rest of the testsuite Thanks, Pedro Alves