From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61232 invoked by alias); 28 Mar 2017 07:16:51 -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 61200 invoked by uid 89); 28 Mar 2017 07:16:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,MIME_BASE64_BLANKS,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=inherited, sal, Hx-languages-length:3409, Classes X-HELO: mga11.intel.com Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Mar 2017 07:16:46 +0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2017 00:16:46 -0700 X-ExtLoop1: 1 Received: from irsmsx152.ger.corp.intel.com ([163.33.192.66]) by fmsmga004.fm.intel.com with ESMTP; 28 Mar 2017 00:16:45 -0700 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.170]) by IRSMSX152.ger.corp.intel.com ([169.254.6.231]) with mapi id 14.03.0319.002; Tue, 28 Mar 2017 08:16:44 +0100 From: "Metzger, Markus T" To: Yao Qi CC: "gdb-patches@sourceware.org" , "Wiederhake, Tim" , "xdje42@gmail.com" , "Joel Brobecker" Subject: RE: GDB 8.0 release/branching 2017-03-20 update Date: Tue, 28 Mar 2017 07:16:00 -0000 Message-ID: References: <20170320201629.pbjzaqsnvs7dx7f2@adacore.com> <86zigevkv0.fsf@gmail.com> <86inn1utkp.fsf@gmail.com> <86inmzvrbx.fsf@gmail.com> <86shm2u47t.fsf@gmail.com> <86wpbbnf1f.fsf@gmail.com> <86shlyoggb.fsf@gmail.com> In-Reply-To: <86shlyoggb.fsf@gmail.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00473.txt.bz2 SGVsbG8gWWFvLA0KDQo+ID4gUmVjb3JkSW5zdHJ1Y3Rpb24gd2FudHMgdG8g c3RvcmUgcHRpZCBhbmQgaW5zbiMgYW5kIGNvbXB1dGUgcGMsIGRhdGEsIGFu ZA0KPiA+IGRpc2Fzc2VtYmxlZCBzdHJpbmcgZnJvbSB0aG9zZS4gIEl0IG1h eSBuZWVkIHRvIHJlYWQgbWVtb3J5IGZyb20gYmluYXJpZXMNCj4gPiB0aGF0 IGhhdmUgYWxyZWFkeSBiZWVuIHVubWFwcGVkLiAgQnV0IHdlIG9ubHkgd2Fu dCB0byByZWFkIG1lbW9yeSBpZiB3ZQ0KPiA+IHJlYWxseSBoYXZlIHRvLCBz byB3ZSBjYW4ndCBqdXN0IHN0b3JlIHRoZSBtZW1vcnkgaW4gdGhlIEluc3Ry dWN0aW9uIG9iamVjdC4NCj4gPg0KPiANCj4gVGhleSBhcmUgYWxsIGFib3V0 IGludGVybmFsIHJlcHJlc2VudGF0aW9uLCBhcmVuJ3QgdGhleT8gIExldCBt ZSBiZQ0KPiBjbGVhciwgImludGVybmFsIHJlcHJlc2VudGF0aW9uIiBpcyBh Ym91dCB0aGUgQyBjb2RlLCBub3QgcHl0aG9uIG9uZS4NCg0KQ29ycmVjdC4g IEkgYW0gb25seSB0YWxraW5nIGFib3V0IHRoZSBpbnRlcm5hbCByZXByZXNl bnRhdGlvbi4gIFRoaXMgd2FzIHRvIGNsYXJpZnkNCnRoYXQgd2UgbmVlZCB0 byBvdmVyd3JpdGUgYWxsIGluaGVyaXRlZCBmdW5jdGlvbnMgYW5kIHRoYXQg d2Ugd2lsbCBoYXZlIGEgZGlmZmVyZW50DQpzZXQgb2YgZGF0YSBtZW1iZXJz IGZvciBlYWNoIHZhcmlhbnQ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B3YXMgdGhh dCB0aGlzIHdvbid0IGJlIGVub3VnaCBhbmQgaXQgbG9va3MgbGlrZSB3ZQ0K YWdyZWUgb24gdGhpcy4NCg0KUmVnYXJkcywNCk1hcmt1cy4NCg0KSW50ZWwg RGV1dHNjaGxhbmQgR21iSApSZWdpc3RlcmVkIEFkZHJlc3M6IEFtIENhbXBl b24gMTAtMTIsIDg1NTc5IE5ldWJpYmVyZywgR2VybWFueQpUZWw6ICs0OSA4 OSA5OSA4ODUzLTAsIHd3dy5pbnRlbC5kZQpNYW5hZ2luZyBEaXJlY3RvcnM6 IENocmlzdGluIEVpc2Vuc2NobWlkLCBDaHJpc3RpYW4gTGFtcHJlY2h0ZXIK Q2hhaXJwZXJzb24gb2YgdGhlIFN1cGVydmlzb3J5IEJvYXJkOiBOaWNvbGUg TGF1ClJlZ2lzdGVyZWQgT2ZmaWNlOiBNdW5pY2gKQ29tbWVyY2lhbCBSZWdp c3RlcjogQW10c2dlcmljaHQgTXVlbmNoZW4gSFJCIDE4NjkyOAo= >From gdb-patches-return-137831-listarch-gdb-patches=sources.redhat.com@sourceware.org Tue Mar 28 08:24:50 2017 Return-Path: Delivered-To: listarch-gdb-patches@sources.redhat.com Received: (qmail 99036 invoked by alias); 28 Mar 2017 08:24:50 -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 Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 98966 invoked by uid 89); 28 Mar 2017 08:24:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=Nothing, evaluating, Actual, intercept X-HELO: mail-wr0-f173.google.com Received: from mail-wr0-f173.google.com (HELO mail-wr0-f173.google.com) (209.85.128.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Mar 2017 08:24:47 +0000 Received: by mail-wr0-f173.google.com with SMTP id u1so92420805wra.2 for ; Tue, 28 Mar 2017 01:24:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=4IifLMYYJydtlcnTkdo+sZhPmV8g+Ht7wx6+aEPwJc0=; b=hK22PsRPu86G7FlYjvQ4ffE4+gtmun4MlJaK2yLk8K7toG4WImpzEaSHHuK7lBlfbr OgexDvLoQYXJZKMbCLuEt3PR5/lo3K3SzHTDaDd5GN5W8woCVN6JjgQk6zzSY6duI2Sm ZIZ16BmAB+CSjASFKyp88+ppc+f4g1oZgRsmnlrXbEw9+LUCU+he4XY9BGXi8gNB8E+o zJQWFKINyHmBX8zVluZ7adh6WO+r7ycqmWeMb5AzeIkgwZrl94bTL02FmS6vhfD8Ke8j eM9F4I6lnvn0cJEWZ0a8ZHD8cVUWo8iOHRUHGS5r1abErDmaXIX+kD01Z1ToqyRzloxb EtTw== X-Gm-Message-State: AFeK/H1FIRJpAopkhhu7fVXb8hsoPe1DlUVONUCfH7CYQyuQrdHpQzRmLc0uc7Rm9Q4tSg== X-Received: by 10.28.7.13 with SMTP id 13mr13324246wmh.16.1490689486465; Tue, 28 Mar 2017 01:24:46 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com ([194.214.185.158]) by smtp.gmail.com with ESMTPSA id o52sm3835188wrb.51.2017.03.28.01.24.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Mar 2017 01:24:45 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 1/2] Add constructor and destructor to thread_info Date: Tue, 28 Mar 2017 08:24:00 -0000 Message-Id: <1490689483-16084-2-git-send-email-yao.qi@linaro.org> In-Reply-To: <1490689483-16084-1-git-send-email-yao.qi@linaro.org> References: <1490689483-16084-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00475.txt.bz2 Content-length: 9926 This patch adds constructor and destructor to thread_info. gdb: 2017-03-28 Yao Qi * gdbthread.h (struct thread_info): Declare constructor and destructor. Add some member initializers. * thread.c (free_thread): Remove. (init_thread_list): Call delete instead of free_thread. (new_thread): Call thread_info constructor. (thread_info::thread_info): New function. (thread_info::~thread_info): New function. (delete_thread_1): Call delete instead of free_thread. (make_cleanup_restore_current_thread): Move tp and frame to inner block. --- gdb/gdbthread.h | 48 ++++++++++++++++++++----------------- gdb/thread.c | 73 ++++++++++++++++++++++++++++++--------------------------- 2 files changed, 65 insertions(+), 56 deletions(-) diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 06ed78f..8ada8f7 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -179,7 +179,11 @@ typedef VEC (value_ptr) value_vec; struct thread_info { - struct thread_info *next; +public: + explicit thread_info (struct inferior *inf, ptid_t ptid); + ~thread_info (); + + struct thread_info *next = NULL; ptid_t ptid; /* "Actual process id"; In fact, this may be overloaded with kernel thread id, etc. */ @@ -226,13 +230,13 @@ struct thread_info /* The name of the thread, as specified by the user. This is NULL if the thread does not have a user-given name. */ - char *name; + char *name = NULL; /* Non-zero means the thread is executing. Note: this is different from saying that there is an active target and we are stopped at a breakpoint, for instance. This is a real indicator whether the thread is off and running. */ - int executing; + int executing = 0; /* Non-zero if this thread is resumed from infrun's perspective. Note that a thread can be marked both as not-executing and @@ -241,19 +245,19 @@ struct thread_info thread really run until that wait status has been processed, but we should not process that wait status if we didn't try to let the thread run. */ - int resumed; + int resumed = 0; /* Frontend view of the thread state. Note that the THREAD_RUNNING/ THREAD_STOPPED states are different from EXECUTING. When the thread is stopped internally while handling an internal event, like a software single-step breakpoint, EXECUTING will be false, but STATE will still be THREAD_RUNNING. */ - enum thread_state state; + enum thread_state state = THREAD_STOPPED; /* If this is > 0, then it means there's code out there that relies on this thread being listed. Don't delete it from the lists even if we detect it exiting. */ - int refcount; + int refcount = 0; /* State of GDB control of inferior thread execution. See `struct thread_control_state'. */ @@ -263,8 +267,8 @@ struct thread_info call. See `struct thread_suspend_state'. */ struct thread_suspend_state suspend; - int current_line; - struct symtab *current_symtab; + int current_line = 0; + struct symtab *current_symtab = 0; /* Internal stepping state. */ @@ -274,20 +278,20 @@ struct thread_info by proceed and keep_going, and among other things, it's used in adjust_pc_after_break to distinguish a hardware single-step SIGTRAP from a breakpoint SIGTRAP. */ - CORE_ADDR prev_pc; + CORE_ADDR prev_pc = 0; /* Did we set the thread stepping a breakpoint instruction? This is used in conjunction with PREV_PC to decide whether to adjust the PC. */ - int stepped_breakpoint; + int stepped_breakpoint = 0; /* Should we step over breakpoint next time keep_going is called? */ - int stepping_over_breakpoint; + int stepping_over_breakpoint = 0; /* Should we step over a watchpoint next time keep_going is called? This is needed on targets with non-continuable, non-steppable watchpoints. */ - int stepping_over_watchpoint; + int stepping_over_watchpoint = 0; /* Set to TRUE if we should finish single-stepping over a breakpoint after hitting the current step-resume breakpoint. The context here @@ -298,12 +302,12 @@ struct thread_info step_after_step_resume_breakpoint is set to TRUE at this moment in order to keep GDB in mind that there is still a breakpoint to step over when GDB gets back SIGTRAP from step_resume_breakpoint. */ - int step_after_step_resume_breakpoint; + int step_after_step_resume_breakpoint = 0; /* Pointer to the state machine manager object that handles what is left to do for the thread's execution command after the target stops. Several execution commands use it. */ - struct thread_fsm *thread_fsm; + struct thread_fsm *thread_fsm = NULL; /* This is used to remember when a fork or vfork event was caught by a catchpoint, and thus the event is to be followed at the next @@ -311,37 +315,37 @@ struct thread_info struct target_waitstatus pending_follow; /* True if this thread has been explicitly requested to stop. */ - int stop_requested; + int stop_requested = 0; /* The initiating frame of a nexting operation, used for deciding which exceptions to intercept. If it is null_frame_id no bp_longjmp or bp_exception but longjmp has been caught just for bp_longjmp_call_dummy. */ - struct frame_id initiating_frame; + struct frame_id initiating_frame = null_frame_id; /* Private data used by the target vector implementation. */ - struct private_thread_info *priv; + struct private_thread_info *priv = NULL; /* Function that is called to free PRIVATE. If this is NULL, then xfree will be called on PRIVATE. */ - void (*private_dtor) (struct private_thread_info *); + void (*private_dtor) (struct private_thread_info *) = NULL; /* Branch trace information for this thread. */ struct btrace_thread_info btrace; /* Flag which indicates that the stack temporaries should be stored while evaluating expressions. */ - int stack_temporaries_enabled; + int stack_temporaries_enabled = 0; /* Values that are stored as temporaries on stack while evaluating expressions. */ - value_vec *stack_temporaries; + value_vec *stack_temporaries = NULL; /* Step-over chain. A thread is in the step-over queue if these are non-NULL. If only a single thread is in the chain, then these fields point to self. */ - struct thread_info *step_over_prev; - struct thread_info *step_over_next; + struct thread_info *step_over_prev = NULL; + struct thread_info *step_over_next = NULL; }; /* Create an empty thread list, or empty the existing one. */ diff --git a/gdb/thread.c b/gdb/thread.c index 99fe424..28907c5 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -192,21 +192,6 @@ clear_thread_inferior_resources (struct thread_info *tp) thread_cancel_execution_command (tp); } -static void -free_thread (struct thread_info *tp) -{ - if (tp->priv) - { - if (tp->private_dtor) - tp->private_dtor (tp->priv); - else - xfree (tp->priv); - } - - xfree (tp->name); - xfree (tp); -} - void init_thread_list (void) { @@ -220,7 +205,8 @@ init_thread_list (void) for (tp = thread_list; tp; tp = tpnext) { tpnext = tp->next; - free_thread (tp); + delete tp; + } thread_list = NULL; @@ -233,16 +219,7 @@ init_thread_list (void) static struct thread_info * new_thread (struct inferior *inf, ptid_t ptid) { - struct thread_info *tp; - - gdb_assert (inf != NULL); - - tp = XCNEW (struct thread_info); - - tp->ptid = ptid; - tp->global_num = ++highest_thread_num; - tp->inf = inf; - tp->per_inf_num = ++inf->highest_thread_num; + struct thread_info *tp = new thread_info (inf, ptid); if (thread_list == NULL) thread_list = tp; @@ -255,11 +232,6 @@ new_thread (struct inferior *inf, ptid_t ptid) last->next = tp; } - /* Nothing to follow yet. */ - tp->pending_follow.kind = TARGET_WAITKIND_SPURIOUS; - tp->state = THREAD_STOPPED; - tp->suspend.waitstatus.kind = TARGET_WAITKIND_IGNORE; - return tp; } @@ -336,6 +308,38 @@ add_thread (ptid_t ptid) return add_thread_with_info (ptid, NULL); } +thread_info::thread_info (struct inferior *inf, ptid_t ptid) +{ + gdb_assert (inf != NULL); + + this->ptid = ptid; + this->global_num = ++highest_thread_num; + this->inf = inf; + this->per_inf_num = ++inf->highest_thread_num; + + /* Nothing to follow yet. */ + memset (&this->pending_follow, 0, sizeof (this->pending_follow)); + memset (&this->control, 0, sizeof (this->control)); + memset (&this->suspend, 0, sizeof (this->suspend)); + memset (&this->btrace, 0, sizeof (this->btrace)); + + this->pending_follow.kind = TARGET_WAITKIND_SPURIOUS; + this->suspend.waitstatus.kind = TARGET_WAITKIND_IGNORE; +} + +thread_info::~thread_info () +{ + if (this->priv) + { + if (this->private_dtor) + this->private_dtor (this->priv); + else + xfree (this->priv); + } + + xfree (this->name); +} + /* Add TP to the end of the step-over chain LIST_P. */ static void @@ -470,7 +474,7 @@ delete_thread_1 (ptid_t ptid, int silent) else thread_list = tp->next; - free_thread (tp); + delete tp; } /* Delete thread PTID and notify of thread exit. If this is @@ -1655,8 +1659,6 @@ set_thread_refcount (void *data) struct cleanup * make_cleanup_restore_current_thread (void) { - struct thread_info *tp; - struct frame_info *frame; struct current_thread_cleanup *old = XNEW (struct current_thread_cleanup); old->inferior_ptid = inferior_ptid; @@ -1668,6 +1670,9 @@ make_cleanup_restore_current_thread (void) if (!ptid_equal (inferior_ptid, null_ptid)) { + struct thread_info *tp; + struct frame_info *frame; + old->was_stopped = is_stopped (inferior_ptid); if (old->was_stopped && target_has_registers -- 1.9.1