From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17994 invoked by alias); 22 Aug 2018 14:34:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 17982 invoked by uid 89); 22 Aug 2018 14:34:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Aug 2018 14:34:38 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w7MEYVV1025681 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Aug 2018 10:34:36 -0400 Received: by simark.ca (Postfix, from userid 112) id A8BE41EAB8; Wed, 22 Aug 2018 10:34:31 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 0B2861E76F; Wed, 22 Aug 2018 10:34:31 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 22 Aug 2018 14:34:00 -0000 From: Simon Marchi To: Xavier Roirand Cc: gdb-patches@sourceware.org, brobecker@adacore.com Subject: Re: [RFA 5/5] Darwin: fix SIGTRAP when debugging In-Reply-To: <1534932677-9496-6-git-send-email-roirand@adacore.com> References: <1534932677-9496-1-git-send-email-roirand@adacore.com> <1534932677-9496-6-git-send-email-roirand@adacore.com> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.6 X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00531.txt.bz2 On 2018-08-22 06:11, Xavier Roirand wrote: > Debugging a program under Darwin does not work: > > (gdb) start > Temporary breakpoint 1 at 0x100000fb4: file /tmp/helloworld.c, line 1. > Starting program: /private/tmp/helloworld > [New Thread 0x2903 of process 60326] > During startup program terminated with signal SIGTRAP, Trace/breakpoint > trap. > > Field signaled from darwin_thread_info is not initialized thus signal > sent to > the debuggee is considered as not sent by GDB whereas it should. > > This patch fixes this problem. > > gdb/ChangeLog: > > * darwin-nat.c (darwin_check_new_threads): Initialize signaled > field. > > Change-Id: I02052473f1f8d28106cc343f440fa784b110bbf5 > --- > gdb/darwin-nat.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c > index 9ad4a87..bbd2700 100644 > --- a/gdb/darwin-nat.c > +++ b/gdb/darwin-nat.c > @@ -341,6 +341,7 @@ darwin_check_new_threads (struct inferior *inf) > /* A thread was created. */ > darwin_thread_info *pti = new darwin_thread_info; > > + pti->signaled = 0; > pti->gdb_port = new_id; > pti->msg_state = DARWIN_RUNNING; Oh, good catch. Though instead, can we initialize the fields directly in the class declaration, so if we ever create darwin_thread_info at some other place, the object will be correctly initialized? In C++11, you can initialize the fields directly like this: unsigned char signaled = 0; I think we might as well initialize all the fields to a sensible value, and you could also change the "char" fields to "bool" at the same time. Thanks, Simon