[20/26] gdbserver: make some regcache fields private
Commit Message
Some fields of the regcache struct are used for internal state
tracking. Prevent direct access to them from outside by making them
private.
---
gdbserver/regcache.h | 6 ++++++
1 file changed, 6 insertions(+)
Comments
On 2023-02-28 06:28, Tankut Baris Aktemur via Gdb-patches wrote:
> Some fields of the regcache struct are used for internal state
> tracking. Prevent direct access to them from outside by making them
> private.
This is a good step, but it would be nice to:
- rename private fields to prefix them with `m_`. When accessing
fields that are not prefixed with `m_`, I like to use `this->`,
otherwise it's not obvious what you are acessing. With the prefix
though, I don't think it's necessary, as the naming makes it obvious.
It then makes the code a bit more concise.
- reorder members of the class to be somewhat in standard order. I
don't think we have a strict rule about this, but it's typically:
constructor, destructor, public methods, public fields, private
methods, private fields.
I don't mind if this is done by editing the patches in this series, or
as a change on top, if it's easier.
Simon
@@ -36,6 +36,8 @@ struct regcache : public reg_buffer_common
/* Back-link to the thread to which this regcache belongs. */
thread_info *thread = nullptr;
+private:
+
/* Whether the REGISTERS buffer's contents are fetched. If false,
we haven't fetched the registers from the target yet. Note that
this register cache is _not_ pass-through, unlike GDB's. Also,
@@ -49,6 +51,8 @@ struct regcache : public reg_buffer_common
/* See gdbsupport/common-regcache.h. */
enum register_status *register_status = nullptr;
+public:
+
/* Constructors. */
regcache () = default;
regcache (const target_desc *tdesc);
@@ -59,6 +63,8 @@ struct regcache : public reg_buffer_common
virtual ~regcache ();
#endif
+public:
+
/* Init the regcache data. */
void initialize (const target_desc *tdesc, unsigned char *regbuf);