diff options
author | Tom Tromey <tromey@adacore.com> | 2023-07-11 09:54:01 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-07-14 10:52:56 -0600 |
commit | cb26e4bbedbc9149507b0f59c2f137d9e213e8c9 (patch) | |
tree | f923428a64e74c4096073a97976642c5dbeb8ae4 /gdb/inferior.h | |
parent | eeaffa60ebbfdbcdca3aa2deb1ac97c57460225d (diff) | |
download | gdb-cb26e4bbedbc9149507b0f59c2f137d9e213e8c9.zip gdb-cb26e4bbedbc9149507b0f59c2f137d9e213e8c9.tar.gz gdb-cb26e4bbedbc9149507b0f59c2f137d9e213e8c9.tar.bz2 |
Introduce scoped_restore_current_inferior_for_memory
This introduces a new class,
scoped_restore_current_inferior_for_memory, and arranges to use it in
a few places. This class is intended to handle setting up and
restoring the various globals that are needed to read or write memory
-- but without invalidating the frame cache.
I wasn't able to test the change to aix-thread.c.
Approved-By: Pedro Alves <pedro@palves.net>
Diffstat (limited to 'gdb/inferior.h')
-rw-r--r-- | gdb/inferior.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gdb/inferior.h b/gdb/inferior.h index caa8e4d..be76c45 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -761,6 +761,35 @@ private: inferior *m_saved_inf; }; +/* When reading memory from an inferior, the global inferior_ptid must + also be set. This class arranges to save and restore the necessary + state for reading or writing memory, but without invalidating the + frame cache. */ + +class scoped_restore_current_inferior_for_memory +{ +public: + + /* Save the current globals and switch to the given inferior and the + inferior's program space. PTID must name a thread in INF, it is + used as the new inferior_ptid. */ + scoped_restore_current_inferior_for_memory (inferior *inf, ptid_t ptid) + : m_save_ptid (&inferior_ptid) + { + set_current_inferior (inf); + set_current_program_space (inf->pspace); + inferior_ptid = ptid; + } + + DISABLE_COPY_AND_ASSIGN (scoped_restore_current_inferior_for_memory); + +private: + + scoped_restore_current_inferior m_save_inferior; + scoped_restore_current_program_space m_save_progspace; + scoped_restore_tmpl<ptid_t> m_save_ptid; +}; + /* Traverse all inferiors. */ |