Message ID | 1534932677-9496-6-git-send-email-roirand@adacore.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 61290 invoked by alias); 22 Aug 2018 10:11:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 61207 invoked by uid 89); 22 Aug 2018 10:11:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=H*r:sk:s10-v6s X-HELO: mail-wr1-f44.google.com Received: from mail-wr1-f44.google.com (HELO mail-wr1-f44.google.com) (209.85.221.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Aug 2018 10:11:38 +0000 Received: by mail-wr1-f44.google.com with SMTP id o37-v6so1136508wrf.6 for <gdb-patches@sourceware.org>; Wed, 22 Aug 2018 03:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IU5NyemBDvc+FM9v04Nm4OKBkFwAKYmLU94f5xqCxJU=; b=xDtKRuD/LYw2AdYndyf7YO1WcFHt+3UGTbJmdjLWfSkHX/YJqTIDhwuxOxB8H62oe6 oKuh62MfQ2har+pouml8zwTc0ZxLDD1OCdIKsAUyvk/eXHaK4sVLn66HJBE4Spp2tDEE EK0j0iaS2kSLKwEcQkK+z+kU2/36TkQ/404s/LFXe0Z9sgNWrk8g9ALaAKnjR0wDs0V9 nn3PxHpPowRybvf7idSBc2zYu6h4VERjb7Tg5W+UX2eIDYxAohCZCKMlrjmSFVLShjYD EpKO4r8SDS5mPT93Z/LfVVjuCsjIzNcdoLnkbvCEJeiLci/vXPXn4Z4uSy5NP2pqlw92 pfNg== Return-Path: <roirand@adacore.com> Received: from adacore.com ([46.18.100.10]) by smtp.gmail.com with ESMTPSA id s10-v6sm1466165wrw.35.2018.08.22.03.11.34 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 22 Aug 2018 03:11:35 -0700 (PDT) Received: by adacore.com (sSMTP sendmail emulation); Wed, 22 Aug 2018 12:11:33 +0200 From: Xavier Roirand <roirand@adacore.com> To: gdb-patches@sourceware.org Cc: brobecker@adacore.com, Xavier Roirand <roirand@adacore.com> Subject: [RFA 5/5] Darwin: fix SIGTRAP when debugging Date: Wed, 22 Aug 2018 12:11:17 +0200 Message-Id: <1534932677-9496-6-git-send-email-roirand@adacore.com> In-Reply-To: <1534932677-9496-1-git-send-email-roirand@adacore.com> References: <1534932677-9496-1-git-send-email-roirand@adacore.com> X-IsSubscribed: yes |
Commit Message
Xavier Roirand
Aug. 22, 2018, 10:11 a.m. UTC
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(+)
Comments
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
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;