• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisãodbf869c238f2c26ccac50347a4adddd7e985b162 (tree)
Hora2018-01-19 02:06:16
AutorYao Qi <yao.qi@lina...>
CommiterYao Qi

Mensagem de Log

Class reg_buffer

This patch adds a new class reg_buffer, and regcache inherits it. Class
reg_buffer is a very simple class, which has the buffer for register
contents and status only. It doesn't have any methods to set contents and
status, and it is expected that its children classes can inherit it and
add different access methods.

Another reason I keep class reg_buffer so simple is that I think
reg_buffer can be even reused in other classes which need to record the
registers contents and status, like frame cache for example.

gdb:

2017-11-27 Yao Qi <yao.qi@linaro.org>

* regcache.c (regcache::regcache): Call reg_buffer ctor.
(regcache::arch): Move it to reg_buffer::arch.
(regcache::register_buffer): Likewise.
(regcache::assert_regnum): Likewise.
(regcache::num_raw_registers): Likewise.
* regcache.h (reg_buffer): New class.
(regcache): Inherit reg_buffer.

Mudança Sumário

Diff

--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -181,14 +181,13 @@ regcache_register_size (const struct regcache *regcache, int n)
181181 return register_size (regcache->arch (), n);
182182 }
183183
184-regcache::regcache (gdbarch *gdbarch, const address_space *aspace_,
185- bool readonly_p_)
186- : m_aspace (aspace_), m_readonly_p (readonly_p_)
184+reg_buffer::reg_buffer (gdbarch *gdbarch, bool has_pseudo)
185+ : m_has_pseudo (has_pseudo)
187186 {
188187 gdb_assert (gdbarch != NULL);
189188 m_descr = regcache_descr (gdbarch);
190189
191- if (m_readonly_p)
190+ if (has_pseudo)
192191 {
193192 m_registers = XCNEWVEC (gdb_byte, m_descr->sizeof_cooked_registers);
194193 m_register_status = XCNEWVEC (signed char,
@@ -199,6 +198,16 @@ regcache::regcache (gdbarch *gdbarch, const address_space *aspace_,
199198 m_registers = XCNEWVEC (gdb_byte, m_descr->sizeof_raw_registers);
200199 m_register_status = XCNEWVEC (signed char, gdbarch_num_regs (gdbarch));
201200 }
201+}
202+
203+regcache::regcache (gdbarch *gdbarch, const address_space *aspace_,
204+ bool readonly_p_)
205+/* The register buffers. A read-only register cache can hold the
206+ full [0 .. gdbarch_num_regs + gdbarch_num_pseudo_regs) while a
207+ read/write register cache can only hold [0 .. gdbarch_num_regs). */
208+ : reg_buffer (gdbarch, readonly_p_),
209+ m_aspace (aspace_), m_readonly_p (readonly_p_)
210+{
202211 m_ptid = minus_one_ptid;
203212 }
204213
@@ -218,7 +227,7 @@ regcache::regcache (readonly_t, const regcache &src)
218227 }
219228
220229 gdbarch *
221-regcache::arch () const
230+reg_buffer::arch () const
222231 {
223232 return m_descr->gdbarch;
224233 }
@@ -267,7 +276,7 @@ private:
267276 /* Return a pointer to register REGNUM's buffer cache. */
268277
269278 gdb_byte *
270-regcache::register_buffer (int regnum) const
279+reg_buffer::register_buffer (int regnum) const
271280 {
272281 return m_registers + m_descr->register_offset[regnum];
273282 }
@@ -390,9 +399,13 @@ regcache::invalidate (int regnum)
390399 }
391400
392401 void
393-regcache::assert_regnum (int regnum) const
402+reg_buffer::assert_regnum (int regnum) const
394403 {
395- gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (arch ()));
404+ gdb_assert (regnum >= 0);
405+ if (m_has_pseudo)
406+ gdb_assert (regnum < m_descr->nr_cooked_registers);
407+ else
408+ gdb_assert (regnum < gdbarch_num_regs (arch ()));
396409 }
397410
398411 /* Global structure containing the current regcache. */
@@ -1272,7 +1285,7 @@ regcache_write_pc (struct regcache *regcache, CORE_ADDR pc)
12721285 }
12731286
12741287 int
1275-regcache::num_raw_registers () const
1288+reg_buffer::num_raw_registers () const
12761289 {
12771290 return gdbarch_num_regs (arch ());
12781291 }
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -227,9 +227,44 @@ typedef struct cached_reg
227227 gdb_byte *data;
228228 } cached_reg_t;
229229
230+/* Buffer of registers. */
231+
232+class reg_buffer
233+{
234+public:
235+ reg_buffer (gdbarch *gdbarch, bool has_pseudo);
236+
237+ DISABLE_COPY_AND_ASSIGN (reg_buffer);
238+
239+ /* Return regcache's architecture. */
240+ gdbarch *arch () const;
241+
242+ virtual ~reg_buffer ()
243+ {
244+ xfree (m_registers);
245+ xfree (m_register_status);
246+ }
247+
248+protected:
249+ /* Assert on the range of REGNUM. */
250+ void assert_regnum (int regnum) const;
251+
252+ int num_raw_registers () const;
253+
254+ gdb_byte *register_buffer (int regnum) const;
255+
256+ struct regcache_descr *m_descr;
257+
258+ bool m_has_pseudo;
259+ /* The register buffers. */
260+ gdb_byte *m_registers;
261+ /* Register cache status. */
262+ signed char *m_register_status;
263+};
264+
230265 /* The register cache for storing raw register values. */
231266
232-class regcache
267+class regcache : public reg_buffer
233268 {
234269 public:
235270 regcache (gdbarch *gdbarch)
@@ -244,15 +279,6 @@ public:
244279
245280 DISABLE_COPY_AND_ASSIGN (regcache);
246281
247- ~regcache ()
248- {
249- xfree (m_registers);
250- xfree (m_register_status);
251- }
252-
253- /* Return regcache's architecture. */
254- gdbarch *arch () const;
255-
256282 /* Return REGCACHE's address space. */
257283 const address_space *aspace () const
258284 {
@@ -339,14 +365,9 @@ public:
339365 static void regcache_thread_ptid_changed (ptid_t old_ptid, ptid_t new_ptid);
340366 protected:
341367 regcache (gdbarch *gdbarch, const address_space *aspace_, bool readonly_p_);
342-
343- int num_raw_registers () const;
344-
345368 static std::forward_list<regcache *> current_regcache;
346369
347370 private:
348- gdb_byte *register_buffer (int regnum) const;
349-
350371 void restore (struct regcache *src);
351372
352373 enum register_status xfer_part (int regnum, int offset, int len, void *in,
@@ -357,21 +378,10 @@ private:
357378 int regnum, const void *in_buf,
358379 void *out_buf, size_t size) const;
359380
360- /* Assert on the range of REGNUM. */
361- void assert_regnum (int regnum) const;
362-
363- struct regcache_descr *m_descr;
364-
365381 /* The address space of this register cache (for registers where it
366382 makes sense, like PC or SP). */
367383 const address_space * const m_aspace;
368384
369- /* The register buffers. A read-only register cache can hold the
370- full [0 .. gdbarch_num_regs + gdbarch_num_pseudo_regs) while a read/write
371- register cache can only hold [0 .. gdbarch_num_regs). */
372- gdb_byte *m_registers;
373- /* Register cache status. */
374- signed char *m_register_status;
375385 /* Is this a read-only cache? A read-only cache is used for saving
376386 the target's register state (e.g, across an inferior function
377387 call or just before forcing a function return). A read-only