From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45953 invoked by alias); 30 Oct 2019 12:47:56 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 45933 invoked by uid 89); 30 Oct 2019 12:47:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.6 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy=disrupt, unwinding, life X-Spam-Status: No, score=-6.6 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 30 Oct 2019 12:47:54 +0000 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 7CA09300B2E4; Wed, 30 Oct 2019 13:47:52 +0100 (CET) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 3A5B54766942; Wed, 30 Oct 2019 13:47:52 +0100 (CET) Message-ID: <1ce04b119fd9f326a9a7a2d1c0630b45afe35f6e.camel@klomp.org> Subject: Re: [PATCH 3/5] libdwfl: add interface for attaching to/detaching from threads From: Mark Wielaard To: Omar Sandoval , elfutils-devel@sourceware.org Date: Wed, 30 Oct 2019 12:47:00 -0000 In-Reply-To: <06926ca241daa563aba5398977b3d4acd70e47cd.1570438723.git.osandov@fb.com> References: <06926ca241daa563aba5398977b3d4acd70e47cd.1570438723.git.osandov@fb.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Evolution 3.28.5 (3.28.5-5.el7) Mime-Version: 1.0 X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2019-q4/txt/msg00081.txt.bz2 Hi Omar, On Mon, 2019-10-07 at 02:05 -0700, Omar Sandoval wrote: > libdwfl has implementations of attaching to/detaching from threads > and > unwinding stack traces. However, that functionality is only available > through the dwfl_thread_getframes interface, which isn't very flexible. > This adds two new functions, dwfl_attach_thread and dwfl_detach_thread, > which separate the thread stopping functionality out of > dwfl_thread_getframes. Additionally, it makes dwfl_thread_getframes > cache the stack trace for threads stopped this way. This makes it > possible to use the frames after dwfl_thread_getframes returns. The advantage of the dwfl_thread_getframes interface is that you cannot forget to "detach", so no Dwfl_Frames get dangling and (if the process is life) you don't disrupt it more than necessary. This new interface seems very simple to get wrong causing leaks and locking up processes/threads. Also, if we would adopt dwfl_attach_thread then I think it should take a Dwfl_Thread object not a pid/tid as argument. Could you provide some examples where this new interface/style is beneficial? Thanks, Mark