This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/4] Create private_inferior class hierarchy
On 2017-11-23 09:09, Pedro Alves wrote:
On 11/22/2017 04:41 PM, Simon Marchi wrote:
diff --git a/gdb/darwin-nat-info.c b/gdb/darwin-nat-info.c
index 44782bf..feab181 100644
--- a/gdb/darwin-nat-info.c
+++ b/gdb/darwin-nat-info.c
@@ -118,7 +118,11 @@ get_task_from_args (const char *args)
{
if (ptid_equal (inferior_ptid, null_ptid))
printf_unfiltered (_("No inferior running\n"));
- return current_inferior ()->priv->task;
+
+ darwin_inferior *priv
+ = (darwin_inferior *) current_inferior ()->priv.get ();
+
How about adding a function like this:
static darwin_inferior *
get_darwin_inferior (inferior *inf)
{
return static_cast<darwin_inferior *> (inf->priv.get ());
}
and then using it throughout instead of the casts.
Good idea.
+/* Get the remote private inferior data associated to INF. */
+
+static remote_inferior *get_remote_inferior (inferior *inf)
Ah, you've added something like it to remote.c
Missing line break before get_, though.
Oops, thanks.
+{
+ if (inf->priv == NULL)
+ inf->priv.reset (new remote_inferior);
+
+ return (remote_inferior *) inf->priv.get ();
static_cast would ensure that remote_inferior actually
inherits private_inferior.
Didn't know static_cast checked that, cool! I'll use that.
Simon