aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbthread.h
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2017-03-29 16:56:31 +0100
committerYao Qi <yao.qi@linaro.org>2017-03-29 16:56:31 +0100
commit1231656410996d2cc271486adc743a0fafe2ab4d (patch)
tree911ae8b65ae5aa44079ce9cf4e979d6fdd4189fe /gdb/gdbthread.h
parent52be03fd13a26ecda4f27c451a434f19eded0ca6 (diff)
downloadgdb-1231656410996d2cc271486adc743a0fafe2ab4d.zip
gdb-1231656410996d2cc271486adc743a0fafe2ab4d.tar.gz
gdb-1231656410996d2cc271486adc743a0fafe2ab4d.tar.bz2
Add constructor and destructor to thread_info
This patch adds constructor and destructor to thread_info. gdb: 2017-03-29 Yao Qi <yao.qi@linaro.org> * gdbthread.h (struct thread_info): Declare constructor and destructor. Add some in-class 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.
Diffstat (limited to 'gdb/gdbthread.h')
-rw-r--r--gdb/gdbthread.h54
1 files changed, 29 insertions, 25 deletions
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 06ed78f..9a16fe6 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 (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,30 +245,30 @@ 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'. */
- struct thread_control_state control;
+ thread_control_state control {};
/* State of inferior thread to restore after GDB is done with an inferior
call. See `struct thread_suspend_state'. */
- struct thread_suspend_state suspend;
+ thread_suspend_state suspend {};
- int current_line;
- struct symtab *current_symtab;
+ int current_line = 0;
+ struct symtab *current_symtab = NULL;
/* 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;
+ 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. */