From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124852 invoked by alias); 4 Oct 2016 01:49:29 -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 123641 invoked by uid 89); 4 Oct 2016 01:49:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.7 required=5.0 tests=AWL,BAYES_00,BODY_8BITS,FREEMAIL_FROM,GARBLED_BODY,RCVD_IN_DNSWL_LOW,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=Safe, safe!, dongliang, Safe! X-HELO: mail-oi0-f46.google.com Received: from mail-oi0-f46.google.com (HELO mail-oi0-f46.google.com) (209.85.218.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Oct 2016 01:49:10 +0000 Received: by mail-oi0-f46.google.com with SMTP id m72so49678950oik.3 for ; Mon, 03 Oct 2016 18:49:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=a95VScDjwA0vC5twpgTys97F+7N3p39kFRVL9kEX6Mo=; b=B3s0RZR05VMKpGFLMkF8Blsf4QriB8RtDj6ioEA0hMytBpyjx4LOWgk7awClW31frt 6e94yAsSyas+F0Kr2c+19QUkWMyr293qhHYAnkdUKu6kGZc4DCeF1WCIxOr3NXTBCZE/ RjjwXwWBH8ZQT++BQlWJZsn3vNYew9YX0PkJNHeudVkbpmeDDmcX7OLRJqLctb9G6dxA lSsnG/VofBGOSMdJFEHDARudvmyJOWaOGzalf8ASDKWZTDj3E4+aC1SYZkRemFDimIiK gz58wwqCdjEFkYD+uNJ+Hkhi5kwVYLn0xEwlCaIFjr0m1G885m7kdKunDsuB5qjFSgUE B5RQ== X-Gm-Message-State: AA6/9RnzKX/i8ulAIYkMHB0SQBmAn4G0ew8iqCFZ1LAsIkIuFqjzzPyHddcohU7FxTIbgQuJ8VinApNB3xBOSQ== X-Received: by 10.157.27.99 with SMTP id l90mr691648otl.4.1475545749111; Mon, 03 Oct 2016 18:49:09 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.97.136 with HTTP; Mon, 3 Oct 2016 18:48:38 -0700 (PDT) In-Reply-To: <20161004012026.GA30611@host1.jankratochvil.net> References: <20161004012026.GA30611@host1.jankratochvil.net> From: =?UTF-8?B?5oWV5Yas5Lqu?= Date: Tue, 04 Oct 2016 01:49:00 -0000 Message-ID: Subject: Re: How to get value of gs:0xc with LTS note in coredump? To: Jan Kratochvil Cc: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg00006.txt.bz2 2016-10-03 21:20 GMT-04:00 Jan Kratochvil : > On Tue, 04 Oct 2016 02:59:45 +0200, =E6=85=95=E5=86=AC=E4=BA=AE wrote: >> I have a question about gs and TLS in core dump. When I read the >> assembly code from one coredump, there is one memory dereference : >> gs:[edx] or gs:0xc. >> >> I googled gs register and found it points to Thread Local Storage. >> However, gs is a selector to GDT and this structure is in the kernel. >> And I could not obtain it in coredump. > > %gs on i386 (and %fs on x86_64) points to pthread_self() which is > 'struct pthread *' (if you have glibc debug info available) where at offs= et 0xc > is 'void *self' which is the pthread_self() pointer itself (%gs:0xc is fa= ster > to access). > > >> Then I searched all the segments in core dump. I found a note entry >> with type NT_386_TLS, length 0x30. Is gs:0xc in this note ? And gs:0xc >> is the 12th element of this note entry? > > Yes, pthread_self() is coincidentally also the value of %gsbase (%fsbase = on > x86_64) but GDB cannot show that register, in a core file you can see it = by > "eu-readelf -n" (from elfutils, "readelf -n" from binutils does not show = it) > as: > LINUX 48 386_TLS > index: 12, base: 0xf7778800, limit: 0x000fffff, flags: 0x00000051 > ^^^^^^^^^^=3Dpthread_self() > I need to analyze this note entry in my C code. How is it arranged by kernel or gdb? And what's the data structure for every item in this entry? LINUX 48 386_TLS index: 6, base: 0xb7fd57c0, limit: 0x000fffff, flags: 0x00000051 index: 7, base: 0x00000000, limit: 0x00000000, flags: 0x00000028 index: 8, base: 0x00000000, limit: 0x00000000, flags: 0x00000028 The above is output from "eu-readelf -n mycore". -- My best regards to you. No System Is Safe! Dongliang Mu > > Jan