From owner-freebsd-ppc@freebsd.org Wed Jan 23 17:03:52 2019 Return-Path: Delivered-To: freebsd-ppc@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 26AF714AD369 for ; Wed, 23 Jan 2019 17:03:52 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C14EA824FC; Wed, 23 Jan 2019 17:03:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro-3.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 5764C154E2; Wed, 23 Jan 2019 17:03:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: GDB TLS testing [actually running some tests finally: a success with -pthread used] To: Mark Millard Cc: "freebsd-ppc@freebsd.org" References: <19343397-859C-4629-A4A5-B0DCDE25957B@yahoo.com> <5AA68ED2-2615-438B-A6AE-406CBD8E49F7@yahoo.com> <20027C29-0093-4001-A135-23783F8B87F3@yahoo.com> <4048D2A4-7E14-481C-9B5D-00567BCF4463@yahoo.com> <2AAC9738-73BD-475A-888A-252EE853A5C6@yahoo.com> <493AC0BE-3EC6-42B7-B027-FFB6454761B5@yahoo.com> <52E66D9B-C332-4565-B8E7-F54F6454B062@yahoo.com> From: John Baldwin Openpgp: preference=signencrypt Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiB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+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: Date: Wed, 23 Jan 2019 09:02:44 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <52E66D9B-C332-4565-B8E7-F54F6454B062@yahoo.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: C14EA824FC X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.99 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.99)[-0.990,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jan 2019 17:03:52 -0000 On 1/23/19 12:19 AM, Mark Millard wrote: > > > On 2019-Jan-22, at 22:53, Mark Millard wrote: > > > >> On 2019-Jan-22, at 19:19, Mark Millard wrote: >> >> >> >>> On 2019-Jan-22, at 18:32, Mark Millard wrote: >>> >>> >>> >>>> On 2019-Jan-22, at 17:06, Mark Millard wrote: >>>> >>>> >>>> >>>> . . . >>>> So I'm trying: >>>> >>>> # git clean -f >>>> # rm */config.cache */*/config.cache >>>> # env CPATH=/usr/local/include ./configure >>>> . . . >>>> # env CPATH=/usr/local/include gmake >>>> . . . >>>> >>>> in order to try to add paths after the command line -I paths. >>>> >>>> . . . This looks like it built. I've not used the build yet. >>>> >>> >>> Looking at a *.core did not go well for my context: >>> >>> # cc -g -O2 tls_gdb_test.c >>> tls_gdb_test.c:16:2: warning: indirection of non-volatile null pointer will be deleted, not trap [-Wnull-dereference] >>> *(char *)NULL = 1; >>> ^~~~~~~~~~~~~ >>> tls_gdb_test.c:16:2: note: consider using __builtin_trap() or qualifying pointer with 'volatile' >>> 1 warning generated. For me, builtin_trap didn't DTRT on ppc before, but that was probably using gcc rather than clang (and possibly using gcc4.2). >>> . . . >> >> >> So far all tried-combinations of using gcc versions for build >> the test program and/or building the gdb used do not work for >> "p id" and "p &id" in doing the test. clang is not essential >> to the behavior observed. > > Using "-g -O2 -pthread" to build the test program via system > clang or gcc8 (for example) did lead to the likes of: > > (gdb) run > Starting program: /root/c_tests/a.out > main: PID 15350 > id = 15350 (0x810055020) > > ^C > Program received signal SIGINT, Interrupt. > main (ac=, av=) at tls_gdb_test.c:16 > 16 *(char *)NULL = 1; > (gdb) bt > #0 main (ac=, av=) at tls_gdb_test.c:16 > (gdb) info threads > Id Target Id Frame > * 1 LWP 100324 of process 15350 main (ac=, av=) at tls_gdb_test.c:16 > (gdb) p id > $1 = 15350 > (gdb) p &id > $2 = (int *) 0x810055020 > > So it appears one branch of: > > static void > fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data) > { > TRY > { > /* Fetch offsets from debug symbols in rtld. */ > data->off_linkmap = parse_and_eval_long ("&((Obj_Entry *)0)->linkmap"); > data->off_tlsindex = parse_and_eval_long ("&((Obj_Entry *)0)->tlsindex"); > data->rtld_offsets_valid = true; > return; > } > CATCH (e, RETURN_MASK_ERROR) > { > data->off_linkmap = -1; > } > END_CATCH > > TRY > { > /* Fetch offsets from global variables in libthr. Note that > this does not work for single-threaded processes that are not > linked against libthr. */ > data->off_linkmap = fbsd_read_integer_by_name(gdbarch, > "_thread_off_linkmap"); > data->off_tlsindex = fbsd_read_integer_by_name(gdbarch, > "_thread_off_tlsindex"); > data->rtld_offsets_valid = true; > return; > } > CATCH (e, RETURN_MASK_ERROR) > { > data->off_linkmap = -1; > } > END_CATCH > } > > is working when -pthread is used. Yes. The second one only works for programs linked against -lthr. Otherwise you need to have built your system with debug symbols (which is the default), and gdb needs to be able to access /usr/lib/debug/libexec/ld-elf.so.1.debug to determine the offsets of the two fields in Obj_Entry (this is what the first TRY clause does). -- John Baldwin