From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7891 invoked from network); 9 Feb 2022 20:44:34 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 9 Feb 2022 20:44:34 -0000 Received: (qmail 15495 invoked by uid 550); 9 Feb 2022 20:44:32 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 15472 invoked from network); 9 Feb 2022 20:44:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644439460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/OEp7cMlbM38BEczRCtEoyBF7rDbaWGj14sprHzI1yQ=; b=H7k3hZpyVETxryVa7YV0MQKogut4qtOA/8afUq6JJbB6JuYpjVvPQDbhZOgdzJvR8ABoQ9 NyYEYjpp4slDMUqzuXjdBeRuhsSDEyIzeqYMMiKIpQZKzVBEaD95rMcoTu2uE1BYfFV8ek tjdf0Jkshu2CWDN19oHQVT8OoLDx/6A= X-MC-Unique: QEQBcYZTMEqJFWY3c5nJ_A-1 From: Florian Weimer To: Rich Felker Cc: Yehuda Yitchak , musl@lists.openwall.com References: <20220209183326.GB7074@brightrain.aerifal.cx> Date: Wed, 09 Feb 2022 21:44:13 +0100 In-Reply-To: <20220209183326.GB7074@brightrain.aerifal.cx> (Rich Felker's message of "Wed, 9 Feb 2022 13:33:26 -0500") Message-ID: <87h797zs6a.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=fweimer@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Subject: Re: [musl] Accessing Thread-Local-Storage in GDB * Rich Felker: > On Wed, Feb 09, 2022 at 09:32:10AM +0200, Yehuda Yitchak wrote: >> Hello >> >> one of the applications i am debugging is compiled using MUSL libc >> (aarch64) Version 1.1.19 >> when i inspect a core-dump and try to view TLS variables with "print >> __percpu_dev" gdb (v8.3) complains: >> >> Cannot find thread-local storage for LWP 22873, executable file >> >> Cannot find thread-local variables on this target >> >> Any idea how I can overcome this? >> Appreciate if you could CC me since i'm not subscribed. > > I think this is a consequence of gdb wanting to have a libthread_db (a > GNU- and Solaris-ism) to tell it how to interact with the threads > implementation of the process being debugged rather than just doing > things in a libpthread-agnostic way like musl wants it to do. I think > it should be fixable on the gdb side without too much headache, but I > don't know how. GDB would have to poke at libc internals and basically reimplement __tls_get_addr. Maybe something can be done by calling libc ABI functions for TLS access instead, but that doesn't work for core files. > As a workaround, if the program is dynamic-linked, you can do > something like print *(int *)dlsym(0, "foo") from the relevant thread > context and it should work. This only works if foo is a dynamic symbol (and if you aren't examining a coredump). My interest in initial-exec TLS (despite its impact on dlopen) is somewhat motivated by a desire to make things easier for debuggers. Thanks, Florian