#include "gdbsupport/function-view.h"
#include "gdbsupport/intrusive_list.h"
+#include <memory>
struct btrace_target_info;
struct regcache;
: id (id), m_process (process), m_target_data (target_data)
{}
- ~thread_info ()
- {
- delete m_regcache;
- }
-
/* Return the process owning this thread. */
process_info *process () const
{ return m_process; }
struct regcache *regcache ()
- { return m_regcache; }
+ { return m_regcache.get (); }
- void set_regcache (struct regcache *regcache)
- { m_regcache = regcache; }
+ void set_regcache (std::unique_ptr<struct regcache> regcache)
+ { m_regcache = std::move (regcache); }
void *target_data ()
{ return m_target_data; }
private:
process_info *m_process;
- struct regcache *m_regcache = nullptr;
+ std::unique_ptr<struct regcache> m_regcache = nullptr;
void *m_target_data;
};
gdb_assert (proc->tdesc != NULL);
- regcache = new struct regcache (proc->tdesc);
- thread->set_regcache (regcache);
+ thread->set_regcache (std::make_unique<struct regcache> (proc->tdesc));
+ regcache = thread->regcache ();
}
if (fetch && !regcache->registers_fetched)
if (regcache != NULL)
{
regcache_invalidate_thread (thread);
- delete regcache;
thread->set_regcache (nullptr);
}
}