+2020-04-08 Tom Tromey <tromey@adacore.com>
+
+ * windows-nat.c (windows_add_thread): Use new.
+ (windows_init_thread_list, windows_delete_thread): Use delete.
+ (get_windows_debug_event): Update.
+ * nat/windows-nat.h (struct windows_thread_info): Add constructor,
+ destructor, and initializers.
+
2020-04-08 Tom Tromey <tromey@adacore.com>
* windows-nat.c (struct windows_thread_info): Remove.
each thread. */
struct windows_thread_info
{
+ windows_thread_info (DWORD tid_, HANDLE h_, CORE_ADDR tlb)
+ : tid (tid_),
+ h (h_),
+ thread_local_base (tlb)
+ {
+ }
+
+ ~windows_thread_info ()
+ {
+ xfree (name);
+ }
+
+ DISABLE_COPY_AND_ASSIGN (windows_thread_info);
+
/* The Win32 thread identifier. */
DWORD tid;
CORE_ADDR thread_local_base;
/* Non zero if SuspendThread was called on this thread. */
- int suspended;
+ int suspended = 0;
#ifdef _WIN32_WCE
/* The context as retrieved right after suspending the thread. */
- CONTEXT base_context;
+ CONTEXT base_context {};
#endif
/* The context of the thread, including any manipulations. */
union
{
- CONTEXT context;
+ CONTEXT context {};
#ifdef __x86_64__
WOW64_CONTEXT wow64_context;
#endif
/* Whether debug registers changed since we last set CONTEXT back to
the thread. */
- int debug_registers_changed;
+ int debug_registers_changed = 0;
/* Nonzero if CONTEXT is invalidated and must be re-read from the
inferior thread. */
- int reload_context;
+ int reload_context = 0;
/* The name of the thread, allocated by xmalloc. */
- char *name;
+ char *name = nullptr;
};
#endif
if ((th = thread_rec (id, FALSE)))
return th;
- th = XCNEW (windows_thread_info);
- th->tid = id;
- th->h = h;
- th->thread_local_base = (CORE_ADDR) (uintptr_t) tlb;
+ CORE_ADDR base = (CORE_ADDR) (uintptr_t) tlb;
#ifdef __x86_64__
/* For WOW64 processes, this is actually the pointer to the 64bit TIB,
and the 32bit TIB is exactly 2 pages after it. */
if (wow64_process)
- th->thread_local_base += 0x2000;
+ base += 0x2000;
#endif
+ th = new windows_thread_info (id, h, base);
thread_list.push_back (th);
/* Add this new thread to the list of threads.
init_thread_list ();
for (windows_thread_info *here : thread_list)
- xfree (here);
+ delete here;
thread_list.clear ();
}
if (iter != thread_list.end ())
{
- xfree ((*iter)->name);
- xfree (*iter);
+ delete *iter;
thread_list.erase (iter);
}
}
BOOL debug_event;
DWORD continue_status, event_code;
windows_thread_info *th;
- static windows_thread_info dummy_thread_info;
+ static windows_thread_info dummy_thread_info (0, 0, 0);
DWORD thread_id = 0;
last_sig = GDB_SIGNAL_0;
+2020-04-08 Tom Tromey <tromey@adacore.com>
+
+ * win32-low.c (child_add_thread): Use new.
+ (delete_thread_info): Use delete.
+
2020-04-08 Tom Tromey <tromey@adacore.com>
* win32-low.h (struct windows_thread_info): Remove.
if ((th = thread_rec (ptid, FALSE)))
return th;
- th = XCNEW (windows_thread_info);
- th->tid = tid;
- th->h = h;
- th->thread_local_base = (CORE_ADDR) (uintptr_t) tlb;
+ th = new windows_thread_info (tid, h, (CORE_ADDR) (uintptr_t) tlb);
add_thread (ptid, th);
remove_thread (thread);
CloseHandle (th->h);
- free (th);
+ delete th;
}
/* Delete a thread from the list of threads. */