From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27037 invoked by alias); 12 Feb 2018 14:02:53 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 26987 invoked by uid 89); 12 Feb 2018 14:02:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Switching X-HELO: mail-qk0-f173.google.com Received: from mail-qk0-f173.google.com (HELO mail-qk0-f173.google.com) (209.85.220.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Feb 2018 14:02:51 +0000 Received: by mail-qk0-f173.google.com with SMTP id i184so7359810qkf.10 for ; Mon, 12 Feb 2018 06:02:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=0KQutTzScROx0S5EquClwrruVcc/HV25HsvtUfyxkOw=; b=kWjmNPbz/f2c6JCxcUys5Xq2JIk1PDQQgUHp1ZlAgF4EuBWd6kDLRG4OPpu78UBEry IOjJSfgQfepDa6iV7vE4w1tUh89DPEdt+tbaAhZSYwDPsZ4X1GqnpOGkgY+MY3teXZlH uc6mQfPEtmXFG1jJC3HhsuGXHqwxU/kNx3TV5E/6uGuXcHZdUoWw0RH52XhWt5RXFDZ/ kxhVj8zEJj3c+KqQttpE8xuXo6NaBNBgQ1KkToJcWDYR7eLnV6phm+H7SDCDSIShehAW 0jclw+fRHhTFfbIE2Fk3BVuJoXkyN9o9jjBYYuvE6Ur7X9e1kQjlamo7tf4ocD/TslZC JjWw== X-Gm-Message-State: APf1xPDsxzIZ+ZkuzXiNRQuJahVgmYnxQTVIr2qHmekHj/501d/2BOdv M0OyukYYuufYJK4EHhHHVvtrM+BA6oIayRxfhIE= X-Google-Smtp-Source: AH8x2261qhfgcOFEef7tWJCCDQizIowRikKIz2HaO7CVlNikW25loGmL0gkB9S2iE1P2G3khPPiQWe6lqDTBkNWlu1E= X-Received: by 10.55.98.70 with SMTP id w67mr877216qkb.278.1518444169863; Mon, 12 Feb 2018 06:02:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.153.232 with HTTP; Mon, 12 Feb 2018 06:02:49 -0800 (PST) In-Reply-To: <780169f5-fa63-3357-ed78-a3045991c307@nvidia.com> References: <780169f5-fa63-3357-ed78-a3045991c307@nvidia.com> From: Yao Qi Date: Mon, 12 Feb 2018 14:02:00 -0000 Message-ID: Subject: Re: Printing thread_local a.k.a. __thread variables To: Dmitry Antipov Cc: GDB Development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg00083.txt.bz2 On Mon, Feb 12, 2018 at 1:29 PM, Dmitry Antipov wrote: > I just tried the recent git snapshot (on x86 GNU/Linux) and always seeing > 100 for 'tlocal' variable. Compiled wit GCC 7.3, -O0 -g3, regardless of > -gdwarf-4 default or -gdwarf-5. Am I doing wrong something? > Because you are in thread 1, main thread, in which tlocal is not changed. If you switch to other threads, you'll see the right value of tlocal. Thread 1 "2.exe" received signal SIGINT, Interrupt. 0x00007ffff7bc565b in pthread_join () from /lib/x86_64-linux-gnu/libpthread= .so.0 (gdb) p tlocal $1 =3D 100 (gdb) thread 2 [Switching to thread 2 (Thread 0x7ffff6fc6700 (LWP 29726))] #0 0x00007ffff7bcbb9d in nanosleep () from /lib/x86_64-linux-gnu/libpthread.so.0 (gdb) p tlocal $2 =3D 104 (gdb) thread 4 [Switching to thread 4 (Thread 0x7ffff5fc4700 (LWP 29728))] #0 0x00007ffff7bcbb9d in nanosleep () from /lib/x86_64-linux-gnu/libpthread.so.0 (gdb) p tlocal $4 =3D 112 (gdb) thread apply all print tlocal Thread 9 (Thread 0x7ffff37bf700 (LWP 29733)): $5 =3D 148 Thread 8 (Thread 0x7ffff3fc0700 (LWP 29732)): $6 =3D 121 Thread 7 (Thread 0x7ffff47c1700 (LWP 29731)): $7 =3D 124 Thread 6 (Thread 0x7ffff4fc2700 (LWP 29730)): $8 =3D 110 Thread 5 (Thread 0x7ffff57c3700 (LWP 29729)): $9 =3D 112 Thread 4 (Thread 0x7ffff5fc4700 (LWP 29728)): $10 =3D 112 Thread 3 (Thread 0x7ffff67c5700 (LWP 29727)): $11 =3D 108 Thread 2 (Thread 0x7ffff6fc6700 (LWP 29726)): $12 =3D 104 Thread 1 (Thread 0x7ffff7fca780 (LWP 29722)): $13 =3D 100 --=20 Yao (=E9=BD=90=E5=B0=A7)