From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9716 invoked by alias); 20 Sep 2005 19:08:57 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 6740 invoked by uid 22791); 20 Sep 2005 19:08:06 -0000 Received: from host254.speakeasy.net (HELO douglas.highley-recommended.com) (216.231.62.254) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 20 Sep 2005 19:08:06 +0000 Received: from douglas.highley-recommended.com (localhost.localdomain [127.0.0.1]) by douglas.highley-recommended.com (8.13.4/8.13.4) with ESMTP id j8KJ83iE017651 for ; Tue, 20 Sep 2005 12:08:03 -0700 Received: (from dhighley@localhost) by douglas.highley-recommended.com (8.13.4/8.13.4/Submit) id j8KJ838m017649 for gdb@sources.redhat.com; Tue, 20 Sep 2005 12:08:03 -0700 From: David Highley Message-Id: <200509201908.j8KJ838m017649@douglas.highley-recommended.com> Subject: Re: GDB problem with statically linked application To: gdb@sources.redhat.com Date: Tue, 20 Sep 2005 19:08:00 -0000 In-Reply-To: <1127242220.7875@horse.he.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2005-09/txt/msg00141.txt.bz2 "Ajay Patel wrote:" > > Hi Daniel, > > Here is the summary/Problem report. > > I compile gdb with gdb-6.3-orig + patches from gdb_6.3-6.diff for > both powerpc and i686. > > Using this gdb on respective arch, I ran different tests > on a simple test program. (Program attached). > I normally comile this program through > "gcc -g -static -o pthread_test pthread_test.c -lpthread" > or through cross compilation. I see that you have fallen into the same compiler trap we have just discovered. It appears to never be correct to use the flag "-lpthread" when using the compiler. You should always use "-pthread". This flag is used in the preprocessor to turn on different code generation and the reentrancy options. But.... What about the case where you do a two step build? g++ -c -pthread thread.cpp g++ -o thread ???? thread.o Above we use the compiler to help with setting up the startup code for the linker. We, I just, finished a test where I did a one step build and then did both options for the two step build of using "-pthread" or "-lpthread". I ran a cmp on the executables and found that the executables are created differently if you use the "-lpthread" for linking. You can run with -v and --save-temps and compare the results without finding a difference. I will be submitting a bug report to the gcc project to trap this option as invalid as I can not see a case from testing where it would ever be valid to use "-lpthread" with the compiler. This is the kind of issue that can really tank alot of time to discover. We still see multiple pid's for static linked applications and not for dynamically linked applications. We are now in the process of rebuilding and running tests on our applications. > > On All tests, I setup a breakpoint in run_thread1. > As soon as breakpoint is encountered in non-main thread, > the program terminates with following message. > "Program terminated with signal SIGTRAP, Trace/breakpoint trap". > > Test 1 on PowerPC (Apple's EMAC) > Kernel Version-2.6.11.2 (from kernel.org), Glibc 2.3.5 (with NPTL). > Program terminated with signal SIGTRAP, Trace/breakpoint trap > > Test 2 on PowerPC (Apple's EMAC) > Kernel Version-2.6.11.2 (from kernel.org), Glibc 2.3.4 (with NPTL). > Program terminated with signal SIGTRAP, Trace/breakpoint trap > > Test 3 on i686 (Dell optiplex) > Kernel Version-2.6.13.2 (from kernel.org), glibc 2.3.4 (with NPTL). > Program terminated with signal SIGTRAP, Trace/breakpoint trap > > Test 4 on i686 (Dell optiplex) > Kernel Version-2.6.13.2 (from kernel.org), glibc 2.3.3 (Linux threads) > Program terminated with signal SIGTRAP, Trace/breakpoint trap > > If you need more info please let me know. > > Thanks for your help. > > Thanks > Ajay > > > > ------=WEBMAIL_ATT_0.095466501386003 > Content-Type: application/octet-stream; > name="pthread_test.c" > Content-Transfer-Encoding: base64 > > LyogJE9wZW5CU0Q6IHB0aHJlYWRfdGVzdC5jLHYgMS40IDIwMDMvMDcvMzEgMjE6NDg6MDUgZGVy > YWFkdCBFeHAgJCAqLwovKiBQVUJMSUMgRE9NQUlOIE9jdCAyMDAyIDxtYXJjQHNuYWZ1Lm9yZz4g > Ki8KCiNpbmNsdWRlIDxzaWduYWwuaD4KI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDx1bmlz > dGQuaD4KI2luY2x1ZGUgPHN0Z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TsKICAgIAlwcmludGYgKCJNYWluIHRocmVhZCBpcyBnb2luZyBi > YWNrIHRvIHNsZWVwXG4iKTsKICAgIH0KfQo= > > ------=WEBMAIL_ATT_0.095466501386003-- > -- Regards, David Highley Phone: (206) 669-0081 Highley Recommended, Inc. FAX: (253) 838-8509 2927 SW 339th Street Email: dhighley@highley-recommended.com Federal Way, WA 98023-7732 WEB: http://www.highley-recommended.com