* [review] Make windows_thread_info::name a unique_xmalloc_ptr
@ 2019-10-29 17:58 Tom Tromey (Code Review)
2019-10-31 19:06 ` Simon Marchi (Code Review)
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-29 17:58 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/410
......................................................................
Make windows_thread_info::name a unique_xmalloc_ptr
This changes windows_thread_info::name to be a unique_xmalloc_ptr,
removing some manual memory management.
gdb/ChangeLog
2019-10-29 Tom Tromey <tromey@adacore.com>
* windows-nat.c (handle_exception)
(windows_nat_target::thread_name): Update.
* nat/windows-nat.h (windows_thread_info): Remove destructor.
<name>: Now unique_xmalloc_ptr.
Change-Id: Ieb950249ddaf58ecc8faf98cc2b464d86c53fde3
---
M gdb/ChangeLog
M gdb/nat/windows-nat.h
M gdb/windows-nat.c
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c83fb0e..92f77fc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2019-10-29 Tom Tromey <tromey@adacore.com>
+ * windows-nat.c (handle_exception)
+ (windows_nat_target::thread_name): Update.
+ * nat/windows-nat.h (windows_thread_info): Remove destructor.
+ <name>: Now unique_xmalloc_ptr.
+
+2019-10-29 Tom Tromey <tromey@adacore.com>
+
* windows-nat.c (thread_rec)
(windows_nat_target::fetch_registers): Update.
* nat/windows-nat.h (struct windows_thread_info) <suspended>:
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index 0cfc071..06c6486 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -30,11 +30,6 @@
{
}
- ~windows_thread_info ()
- {
- xfree (name);
- }
-
DISABLE_COPY_AND_ASSIGN (windows_thread_info);
/* The Win32 thread identifier. */
@@ -68,7 +63,7 @@
bool reload_context = false;
/* The name of the thread, allocated by xmalloc. */
- char *name = nullptr;
+ gdb::unique_xmalloc_ptr<char> name;
};
#endif
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 75d61cf..12a69bb 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1261,8 +1261,7 @@
if (thread_name_len > 0)
{
thread_name.get ()[thread_name_len - 1] = '\0';
- xfree (named_thread->name);
- named_thread->name = thread_name.release ();
+ named_thread->name = std::move (thread_name);
}
}
ourstatus->value.sig = GDB_SIGNAL_TRAP;
@@ -3000,7 +2999,7 @@
const char *
windows_nat_target::thread_name (struct thread_info *thr)
{
- return thread_rec (thr->ptid.tid (), 0)->name;
+ return thread_rec (thr->ptid.tid (), 0)->name.get ();
}
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ieb950249ddaf58ecc8faf98cc2b464d86c53fde3
Gerrit-Change-Number: 410
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange
^ permalink raw reply [flat|nested] 4+ messages in thread
* [review] Make windows_thread_info::name a unique_xmalloc_ptr
2019-10-29 17:58 [review] Make windows_thread_info::name a unique_xmalloc_ptr Tom Tromey (Code Review)
@ 2019-10-31 19:06 ` Simon Marchi (Code Review)
2019-11-26 17:11 ` [review v2] " Tom Tromey (Code Review)
2019-11-29 18:01 ` Pedro Alves (Code Review)
2 siblings, 0 replies; 4+ messages in thread
From: Simon Marchi (Code Review) @ 2019-10-31 19:06 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
Simon Marchi has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/410
......................................................................
Patch Set 1: Code-Review+2
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ieb950249ddaf58ecc8faf98cc2b464d86c53fde3
Gerrit-Change-Number: 410
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Comment-Date: Thu, 31 Oct 2019 19:06:13 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 4+ messages in thread
* [review v2] Make windows_thread_info::name a unique_xmalloc_ptr
2019-10-29 17:58 [review] Make windows_thread_info::name a unique_xmalloc_ptr Tom Tromey (Code Review)
2019-10-31 19:06 ` Simon Marchi (Code Review)
@ 2019-11-26 17:11 ` Tom Tromey (Code Review)
2019-11-29 18:01 ` Pedro Alves (Code Review)
2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-26 17:11 UTC (permalink / raw)
To: Simon Marchi, gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/410
......................................................................
Make windows_thread_info::name a unique_xmalloc_ptr
This changes windows_thread_info::name to be a unique_xmalloc_ptr,
removing some manual memory management.
gdb/ChangeLog
2019-11-26 Tom Tromey <tromey@adacore.com>
* windows-nat.c (handle_exception)
(windows_nat_target::thread_name): Update.
* nat/windows-nat.h (windows_thread_info): Remove destructor.
<name>: Now unique_xmalloc_ptr.
Change-Id: Ieb950249ddaf58ecc8faf98cc2b464d86c53fde3
---
M gdb/ChangeLog
M gdb/nat/windows-nat.h
M gdb/windows-nat.c
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e48f650..621f890 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2019-11-26 Tom Tromey <tromey@adacore.com>
+ * windows-nat.c (handle_exception)
+ (windows_nat_target::thread_name): Update.
+ * nat/windows-nat.h (windows_thread_info): Remove destructor.
+ <name>: Now unique_xmalloc_ptr.
+
+2019-11-26 Tom Tromey <tromey@adacore.com>
+
* windows-nat.c (thread_rec)
(windows_nat_target::fetch_registers): Update.
* nat/windows-nat.h (struct windows_thread_info) <suspended>:
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index e5d7e63..db21ca7 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -30,11 +30,6 @@
{
}
- ~windows_thread_info ()
- {
- xfree (name);
- }
-
DISABLE_COPY_AND_ASSIGN (windows_thread_info);
/* The Win32 thread identifier. */
@@ -69,7 +64,7 @@
bool reload_context = false;
/* The name of the thread, allocated by xmalloc. */
- char *name = nullptr;
+ gdb::unique_xmalloc_ptr<char> name;
};
#endif
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 4898fba..f283495 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1261,8 +1261,7 @@
if (thread_name_len > 0)
{
thread_name.get ()[thread_name_len - 1] = '\0';
- xfree (named_thread->name);
- named_thread->name = thread_name.release ();
+ named_thread->name = std::move (thread_name);
}
}
ourstatus->value.sig = GDB_SIGNAL_TRAP;
@@ -3001,7 +3000,7 @@
const char *
windows_nat_target::thread_name (struct thread_info *thr)
{
- return thread_rec (thr->ptid.tid (), 0)->name;
+ return thread_rec (thr->ptid.tid (), 0)->name.get ();
}
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ieb950249ddaf58ecc8faf98cc2b464d86c53fde3
Gerrit-Change-Number: 410
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-MessageType: newpatchset
^ permalink raw reply [flat|nested] 4+ messages in thread
* [review v2] Make windows_thread_info::name a unique_xmalloc_ptr
2019-10-29 17:58 [review] Make windows_thread_info::name a unique_xmalloc_ptr Tom Tromey (Code Review)
2019-10-31 19:06 ` Simon Marchi (Code Review)
2019-11-26 17:11 ` [review v2] " Tom Tromey (Code Review)
@ 2019-11-29 18:01 ` Pedro Alves (Code Review)
2 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves (Code Review) @ 2019-11-29 18:01 UTC (permalink / raw)
To: Tom Tromey, gdb-patches; +Cc: Simon Marchi
Pedro Alves has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/410
......................................................................
Patch Set 2: Code-Review+2
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: Ieb950249ddaf58ecc8faf98cc2b464d86c53fde3
Gerrit-Change-Number: 410
Gerrit-PatchSet: 2
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Reviewer: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Comment-Date: Fri, 29 Nov 2019 18:01:46 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-29 18:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-29 17:58 [review] Make windows_thread_info::name a unique_xmalloc_ptr Tom Tromey (Code Review)
2019-10-31 19:06 ` Simon Marchi (Code Review)
2019-11-26 17:11 ` [review v2] " Tom Tromey (Code Review)
2019-11-29 18:01 ` Pedro Alves (Code Review)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).