1 /* GNU/Linux/MIPS specific low level interface, for the remote server for GDB.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "linux-low.h"
22 #include "nat/gdb_ptrace.h"
25 #include "nat/mips-linux-watch.h"
26 #include "gdb_proc_service.h"
28 /* Linux target op definitions for the MIPS architecture. */
30 class mips_target
: public linux_process_target
34 const regs_info
*get_regs_info () override
;
38 void low_arch_setup () override
;
40 bool low_cannot_fetch_register (int regno
) override
;
42 bool low_cannot_store_register (int regno
) override
;
45 /* The singleton target ops object. */
47 static mips_target the_mips_target
;
49 /* Defined in auto-generated file mips-linux.c. */
50 void init_registers_mips_linux (void);
51 extern const struct target_desc
*tdesc_mips_linux
;
53 /* Defined in auto-generated file mips-dsp-linux.c. */
54 void init_registers_mips_dsp_linux (void);
55 extern const struct target_desc
*tdesc_mips_dsp_linux
;
57 /* Defined in auto-generated file mips64-linux.c. */
58 void init_registers_mips64_linux (void);
59 extern const struct target_desc
*tdesc_mips64_linux
;
61 /* Defined in auto-generated file mips64-dsp-linux.c. */
62 void init_registers_mips64_dsp_linux (void);
63 extern const struct target_desc
*tdesc_mips64_dsp_linux
;
66 #define tdesc_mips_linux tdesc_mips64_linux
67 #define tdesc_mips_dsp_linux tdesc_mips64_dsp_linux
70 #ifndef PTRACE_GET_THREAD_AREA
71 #define PTRACE_GET_THREAD_AREA 25
78 #define mips_num_regs 73
79 #define mips_dsp_num_regs 80
81 #include <asm/ptrace.h>
85 #define DSP_CONTROL 77
92 /* Deliberately signed, for proper sign extension. */
97 /* Return the ptrace ``address'' of register REGNO. */
99 #define mips_base_regs \
100 -1, 1, 2, 3, 4, 5, 6, 7, \
101 8, 9, 10, 11, 12, 13, 14, 15, \
102 16, 17, 18, 19, 20, 21, 22, 23, \
103 24, 25, 26, 27, 28, 29, 30, 31, \
105 -1, MMLO, MMHI, BADVADDR, CAUSE, PC, \
107 FPR_BASE, FPR_BASE + 1, FPR_BASE + 2, FPR_BASE + 3, \
108 FPR_BASE + 4, FPR_BASE + 5, FPR_BASE + 6, FPR_BASE + 7, \
109 FPR_BASE + 8, FPR_BASE + 9, FPR_BASE + 10, FPR_BASE + 11, \
110 FPR_BASE + 12, FPR_BASE + 13, FPR_BASE + 14, FPR_BASE + 15, \
111 FPR_BASE + 16, FPR_BASE + 17, FPR_BASE + 18, FPR_BASE + 19, \
112 FPR_BASE + 20, FPR_BASE + 21, FPR_BASE + 22, FPR_BASE + 23, \
113 FPR_BASE + 24, FPR_BASE + 25, FPR_BASE + 26, FPR_BASE + 27, \
114 FPR_BASE + 28, FPR_BASE + 29, FPR_BASE + 30, FPR_BASE + 31, \
117 #define mips_dsp_regs \
118 DSP_BASE, DSP_BASE + 1, DSP_BASE + 2, DSP_BASE + 3, \
119 DSP_BASE + 4, DSP_BASE + 5, \
122 static int mips_regmap
[mips_num_regs
] = {
127 static int mips_dsp_regmap
[mips_dsp_num_regs
] = {
133 /* DSP registers are not in any regset and can only be accessed
136 static unsigned char mips_dsp_regset_bitmap
[(mips_dsp_num_regs
+ 7) / 8] = {
137 0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x80
140 static int have_dsp
= -1;
142 /* Try peeking at an arbitrarily chosen DSP register and pick the available
143 user register set accordingly. */
145 static const struct target_desc
*
146 mips_read_description (void)
150 int pid
= lwpid_of (current_thread
);
153 ptrace (PTRACE_PEEKUSER
, pid
, DSP_CONTROL
, 0);
163 perror_with_name ("ptrace");
168 return have_dsp
? tdesc_mips_dsp_linux
: tdesc_mips_linux
;
172 mips_target::low_arch_setup ()
174 current_process ()->tdesc
= mips_read_description ();
177 /* Per-process arch-specific data we want to keep. */
179 struct arch_process_info
181 /* -1 if the kernel and/or CPU do not support watch registers.
182 1 if watch_readback is valid and we can read style, num_valid
184 0 if we need to read the watch_readback. */
186 int watch_readback_valid
;
188 /* Cached watch register read values. */
190 struct pt_watch_regs watch_readback
;
192 /* Current watchpoint requests for this process. */
194 struct mips_watchpoint
*current_watches
;
196 /* The current set of watch register values for writing the
199 struct pt_watch_regs watch_mirror
;
202 /* Per-thread arch-specific data we want to keep. */
206 /* Non-zero if our copy differs from what's recorded in the thread. */
207 int watch_registers_changed
;
210 /* From mips-linux-nat.c. */
212 /* Pseudo registers can not be read. ptrace does not provide a way to
213 read (or set) PS_REGNUM, and there's no point in reading or setting
214 ZERO_REGNUM, it's always 0. We also can not set BADVADDR, CAUSE,
215 or FCRIR via ptrace(). */
218 mips_target::low_cannot_fetch_register (int regno
)
220 const struct target_desc
*tdesc
;
222 if (get_regs_info ()->usrregs
->regmap
[regno
] == -1)
225 tdesc
= current_process ()->tdesc
;
227 /* On n32 we can't access 64-bit registers via PTRACE_PEEKUSR. */
228 if (register_size (tdesc
, regno
) > sizeof (PTRACE_XFER_TYPE
))
231 if (find_regno (tdesc
, "r0") == regno
)
238 mips_target::low_cannot_store_register (int regno
)
240 const struct target_desc
*tdesc
;
242 if (get_regs_info ()->usrregs
->regmap
[regno
] == -1)
245 tdesc
= current_process ()->tdesc
;
247 /* On n32 we can't access 64-bit registers via PTRACE_POKEUSR. */
248 if (register_size (tdesc
, regno
) > sizeof (PTRACE_XFER_TYPE
))
251 if (find_regno (tdesc
, "r0") == regno
)
254 if (find_regno (tdesc
, "cause") == regno
)
257 if (find_regno (tdesc
, "badvaddr") == regno
)
260 if (find_regno (tdesc
, "fir") == regno
)
267 mips_fetch_register (struct regcache
*regcache
, int regno
)
269 const struct target_desc
*tdesc
= current_process ()->tdesc
;
271 if (find_regno (tdesc
, "r0") == regno
)
273 supply_register_zeroed (regcache
, regno
);
281 mips_get_pc (struct regcache
*regcache
)
283 union mips_register pc
;
284 collect_register_by_name (regcache
, "pc", pc
.buf
);
285 return register_size (regcache
->tdesc
, 0) == 4 ? pc
.reg32
: pc
.reg64
;
289 mips_set_pc (struct regcache
*regcache
, CORE_ADDR pc
)
291 union mips_register newpc
;
292 if (register_size (regcache
->tdesc
, 0) == 4)
297 supply_register_by_name (regcache
, "pc", newpc
.buf
);
300 /* Correct in either endianness. */
301 static const unsigned int mips_breakpoint
= 0x0005000d;
302 #define mips_breakpoint_len 4
304 /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
306 static const gdb_byte
*
307 mips_sw_breakpoint_from_kind (int kind
, int *size
)
309 *size
= mips_breakpoint_len
;
310 return (const gdb_byte
*) &mips_breakpoint
;
314 mips_breakpoint_at (CORE_ADDR where
)
318 the_target
->read_memory (where
, (unsigned char *) &insn
, 4);
319 if (insn
== mips_breakpoint
)
322 /* If necessary, recognize more trap instructions here. GDB only uses the
327 /* Mark the watch registers of lwp, represented by ENTRY, as changed. */
330 update_watch_registers_callback (thread_info
*thread
)
332 struct lwp_info
*lwp
= get_thread_lwp (thread
);
334 /* The actual update is done later just before resuming the lwp,
335 we just mark that the registers need updating. */
336 lwp
->arch_private
->watch_registers_changed
= 1;
338 /* If the lwp isn't stopped, force it to momentarily pause, so
339 we can update its watch registers. */
341 linux_stop_lwp (lwp
);
344 /* This is the implementation of linux_target_ops method
347 static struct arch_process_info
*
348 mips_linux_new_process (void)
350 struct arch_process_info
*info
= XCNEW (struct arch_process_info
);
355 /* This is the implementation of linux_target_ops method
359 mips_linux_delete_process (struct arch_process_info
*info
)
364 /* This is the implementation of linux_target_ops method new_thread.
365 Mark the watch registers as changed, so the threads' copies will
369 mips_linux_new_thread (struct lwp_info
*lwp
)
371 struct arch_lwp_info
*info
= XCNEW (struct arch_lwp_info
);
373 info
->watch_registers_changed
= 1;
375 lwp
->arch_private
= info
;
378 /* Function to call when a thread is being deleted. */
381 mips_linux_delete_thread (struct arch_lwp_info
*arch_lwp
)
386 /* Create a new mips_watchpoint and add it to the list. */
389 mips_add_watchpoint (struct arch_process_info
*priv
, CORE_ADDR addr
, int len
,
390 enum target_hw_bp_type watch_type
)
392 struct mips_watchpoint
*new_watch
;
393 struct mips_watchpoint
**pw
;
395 new_watch
= XNEW (struct mips_watchpoint
);
396 new_watch
->addr
= addr
;
397 new_watch
->len
= len
;
398 new_watch
->type
= watch_type
;
399 new_watch
->next
= NULL
;
401 pw
= &priv
->current_watches
;
407 /* Hook to call when a new fork is attached. */
410 mips_linux_new_fork (struct process_info
*parent
,
411 struct process_info
*child
)
413 struct arch_process_info
*parent_private
;
414 struct arch_process_info
*child_private
;
415 struct mips_watchpoint
*wp
;
417 /* These are allocated by linux_add_process. */
418 gdb_assert (parent
->priv
!= NULL
419 && parent
->priv
->arch_private
!= NULL
);
420 gdb_assert (child
->priv
!= NULL
421 && child
->priv
->arch_private
!= NULL
);
423 /* Linux kernel before 2.6.33 commit
424 72f674d203cd230426437cdcf7dd6f681dad8b0d
425 will inherit hardware debug registers from parent
426 on fork/vfork/clone. Newer Linux kernels create such tasks with
427 zeroed debug registers.
429 GDB core assumes the child inherits the watchpoints/hw
430 breakpoints of the parent, and will remove them all from the
431 forked off process. Copy the debug registers mirrors into the
432 new process so that all breakpoints and watchpoints can be
433 removed together. The debug registers mirror will become zeroed
434 in the end before detaching the forked off process, thus making
435 this compatible with older Linux kernels too. */
437 parent_private
= parent
->priv
->arch_private
;
438 child_private
= child
->priv
->arch_private
;
440 child_private
->watch_readback_valid
= parent_private
->watch_readback_valid
;
441 child_private
->watch_readback
= parent_private
->watch_readback
;
443 for (wp
= parent_private
->current_watches
; wp
!= NULL
; wp
= wp
->next
)
444 mips_add_watchpoint (child_private
, wp
->addr
, wp
->len
, wp
->type
);
446 child_private
->watch_mirror
= parent_private
->watch_mirror
;
448 /* This is the implementation of linux_target_ops method
449 prepare_to_resume. If the watch regs have changed, update the
453 mips_linux_prepare_to_resume (struct lwp_info
*lwp
)
455 ptid_t ptid
= ptid_of (get_lwp_thread (lwp
));
456 struct process_info
*proc
= find_process_pid (ptid
.pid ());
457 struct arch_process_info
*priv
= proc
->priv
->arch_private
;
459 if (lwp
->arch_private
->watch_registers_changed
)
461 /* Only update the watch registers if we have set or unset a
462 watchpoint already. */
463 if (mips_linux_watch_get_num_valid (&priv
->watch_mirror
) > 0)
465 /* Write the mirrored watch register values. */
466 int tid
= ptid
.lwp ();
468 if (-1 == ptrace (PTRACE_SET_WATCH_REGS
, tid
,
469 &priv
->watch_mirror
, NULL
))
470 perror_with_name ("Couldn't write watch register");
473 lwp
->arch_private
->watch_registers_changed
= 0;
478 mips_supports_z_point_type (char z_type
)
482 case Z_PACKET_WRITE_WP
:
483 case Z_PACKET_READ_WP
:
484 case Z_PACKET_ACCESS_WP
:
491 /* This is the implementation of linux_target_ops method
495 mips_insert_point (enum raw_bkpt_type type
, CORE_ADDR addr
,
496 int len
, struct raw_breakpoint
*bp
)
498 struct process_info
*proc
= current_process ();
499 struct arch_process_info
*priv
= proc
->priv
->arch_private
;
500 struct pt_watch_regs regs
;
502 enum target_hw_bp_type watch_type
;
505 lwpid
= lwpid_of (current_thread
);
506 if (!mips_linux_read_watch_registers (lwpid
,
507 &priv
->watch_readback
,
508 &priv
->watch_readback_valid
,
515 regs
= priv
->watch_readback
;
516 /* Add the current watches. */
517 mips_linux_watch_populate_regs (priv
->current_watches
, ®s
);
519 /* Now try to add the new watch. */
520 watch_type
= raw_bkpt_type_to_target_hw_bp_type (type
);
521 irw
= mips_linux_watch_type_to_irw (watch_type
);
522 if (!mips_linux_watch_try_one_watch (®s
, addr
, len
, irw
))
525 /* It fit. Stick it on the end of the list. */
526 mips_add_watchpoint (priv
, addr
, len
, watch_type
);
528 priv
->watch_mirror
= regs
;
530 /* Only update the threads of this process. */
531 for_each_thread (proc
->pid
, update_watch_registers_callback
);
536 /* This is the implementation of linux_target_ops method
540 mips_remove_point (enum raw_bkpt_type type
, CORE_ADDR addr
,
541 int len
, struct raw_breakpoint
*bp
)
543 struct process_info
*proc
= current_process ();
544 struct arch_process_info
*priv
= proc
->priv
->arch_private
;
547 enum target_hw_bp_type watch_type
;
549 struct mips_watchpoint
**pw
;
550 struct mips_watchpoint
*w
;
552 /* Search for a known watch that matches. Then unlink and free it. */
553 watch_type
= raw_bkpt_type_to_target_hw_bp_type (type
);
555 pw
= &priv
->current_watches
;
558 if (w
->addr
== addr
&& w
->len
== len
&& w
->type
== watch_type
)
569 return -1; /* We don't know about it, fail doing nothing. */
571 /* At this point watch_readback is known to be valid because we
572 could not have added the watch without reading it. */
573 gdb_assert (priv
->watch_readback_valid
== 1);
575 priv
->watch_mirror
= priv
->watch_readback
;
576 mips_linux_watch_populate_regs (priv
->current_watches
,
577 &priv
->watch_mirror
);
579 /* Only update the threads of this process. */
580 for_each_thread (proc
->pid
, update_watch_registers_callback
);
585 /* This is the implementation of linux_target_ops method
586 stopped_by_watchpoint. The watchhi R and W bits indicate
587 the watch register triggered. */
590 mips_stopped_by_watchpoint (void)
592 struct process_info
*proc
= current_process ();
593 struct arch_process_info
*priv
= proc
->priv
->arch_private
;
596 long lwpid
= lwpid_of (current_thread
);
598 if (!mips_linux_read_watch_registers (lwpid
,
599 &priv
->watch_readback
,
600 &priv
->watch_readback_valid
,
604 num_valid
= mips_linux_watch_get_num_valid (&priv
->watch_readback
);
606 for (n
= 0; n
< MAX_DEBUG_REGISTER
&& n
< num_valid
; n
++)
607 if (mips_linux_watch_get_watchhi (&priv
->watch_readback
, n
)
614 /* This is the implementation of linux_target_ops method
615 stopped_data_address. */
618 mips_stopped_data_address (void)
620 struct process_info
*proc
= current_process ();
621 struct arch_process_info
*priv
= proc
->priv
->arch_private
;
624 long lwpid
= lwpid_of (current_thread
);
626 /* On MIPS we don't know the low order 3 bits of the data address.
627 GDB does not support remote targets that can't report the
628 watchpoint address. So, make our best guess; return the starting
629 address of a watchpoint request which overlaps the one that
632 if (!mips_linux_read_watch_registers (lwpid
,
633 &priv
->watch_readback
,
634 &priv
->watch_readback_valid
,
638 num_valid
= mips_linux_watch_get_num_valid (&priv
->watch_readback
);
640 for (n
= 0; n
< MAX_DEBUG_REGISTER
&& n
< num_valid
; n
++)
641 if (mips_linux_watch_get_watchhi (&priv
->watch_readback
, n
)
644 CORE_ADDR t_low
, t_hi
;
646 struct mips_watchpoint
*watch
;
648 t_low
= mips_linux_watch_get_watchlo (&priv
->watch_readback
, n
);
649 t_irw
= t_low
& IRW_MASK
;
650 t_hi
= (mips_linux_watch_get_watchhi (&priv
->watch_readback
, n
)
652 t_low
&= ~(CORE_ADDR
)t_hi
;
654 for (watch
= priv
->current_watches
;
658 CORE_ADDR addr
= watch
->addr
;
659 CORE_ADDR last_byte
= addr
+ watch
->len
- 1;
661 if ((t_irw
& mips_linux_watch_type_to_irw (watch
->type
)) == 0)
663 /* Different type. */
666 /* Check for overlap of even a single byte. */
667 if (last_byte
>= t_low
&& addr
<= t_low
+ t_hi
)
672 /* Shouldn't happen. */
676 /* Fetch the thread-local storage pointer for libthread_db. */
679 ps_get_thread_area (struct ps_prochandle
*ph
,
680 lwpid_t lwpid
, int idx
, void **base
)
682 if (ptrace (PTRACE_GET_THREAD_AREA
, lwpid
, NULL
, base
) != 0)
685 /* IDX is the bias from the thread pointer to the beginning of the
686 thread descriptor. It has to be subtracted due to implementation
687 quirks in libthread_db. */
688 *base
= (void *) ((char *)*base
- idx
);
694 mips_collect_register (struct regcache
*regcache
,
695 int use_64bit
, int regno
, union mips_register
*reg
)
697 union mips_register tmp_reg
;
701 collect_register (regcache
, regno
, &tmp_reg
.reg64
);
706 collect_register (regcache
, regno
, &tmp_reg
.reg32
);
707 reg
->reg64
= tmp_reg
.reg32
;
712 mips_supply_register (struct regcache
*regcache
,
713 int use_64bit
, int regno
, const union mips_register
*reg
)
717 /* For big-endian 32-bit targets, ignore the high four bytes of each
719 if (__BYTE_ORDER
== __BIG_ENDIAN
&& !use_64bit
)
722 supply_register (regcache
, regno
, reg
->buf
+ offset
);
725 #ifdef HAVE_PTRACE_GETREGS
728 mips_collect_register_32bit (struct regcache
*regcache
,
729 int use_64bit
, int regno
, unsigned char *buf
)
731 union mips_register tmp_reg
;
734 mips_collect_register (regcache
, use_64bit
, regno
, &tmp_reg
);
735 reg32
= tmp_reg
.reg64
;
736 memcpy (buf
, ®32
, 4);
740 mips_supply_register_32bit (struct regcache
*regcache
,
741 int use_64bit
, int regno
, const unsigned char *buf
)
743 union mips_register tmp_reg
;
746 memcpy (®32
, buf
, 4);
747 tmp_reg
.reg64
= reg32
;
748 mips_supply_register (regcache
, use_64bit
, regno
, &tmp_reg
);
752 mips_fill_gregset (struct regcache
*regcache
, void *buf
)
754 union mips_register
*regset
= (union mips_register
*) buf
;
756 const struct target_desc
*tdesc
= regcache
->tdesc
;
758 use_64bit
= (register_size (tdesc
, 0) == 8);
760 for (i
= 1; i
< 32; i
++)
761 mips_collect_register (regcache
, use_64bit
, i
, regset
+ i
);
763 mips_collect_register (regcache
, use_64bit
,
764 find_regno (tdesc
, "lo"), regset
+ 32);
765 mips_collect_register (regcache
, use_64bit
,
766 find_regno (tdesc
, "hi"), regset
+ 33);
767 mips_collect_register (regcache
, use_64bit
,
768 find_regno (tdesc
, "pc"), regset
+ 34);
769 mips_collect_register (regcache
, use_64bit
,
770 find_regno (tdesc
, "badvaddr"), regset
+ 35);
771 mips_collect_register (regcache
, use_64bit
,
772 find_regno (tdesc
, "status"), regset
+ 36);
773 mips_collect_register (regcache
, use_64bit
,
774 find_regno (tdesc
, "cause"), regset
+ 37);
776 mips_collect_register (regcache
, use_64bit
,
777 find_regno (tdesc
, "restart"), regset
+ 0);
781 mips_store_gregset (struct regcache
*regcache
, const void *buf
)
783 const union mips_register
*regset
= (const union mips_register
*) buf
;
786 use_64bit
= (register_size (regcache
->tdesc
, 0) == 8);
788 supply_register_by_name_zeroed (regcache
, "r0");
790 for (i
= 1; i
< 32; i
++)
791 mips_supply_register (regcache
, use_64bit
, i
, regset
+ i
);
793 mips_supply_register (regcache
, use_64bit
,
794 find_regno (regcache
->tdesc
, "lo"), regset
+ 32);
795 mips_supply_register (regcache
, use_64bit
,
796 find_regno (regcache
->tdesc
, "hi"), regset
+ 33);
797 mips_supply_register (regcache
, use_64bit
,
798 find_regno (regcache
->tdesc
, "pc"), regset
+ 34);
799 mips_supply_register (regcache
, use_64bit
,
800 find_regno (regcache
->tdesc
, "badvaddr"), regset
+ 35);
801 mips_supply_register (regcache
, use_64bit
,
802 find_regno (regcache
->tdesc
, "status"), regset
+ 36);
803 mips_supply_register (regcache
, use_64bit
,
804 find_regno (regcache
->tdesc
, "cause"), regset
+ 37);
806 mips_supply_register (regcache
, use_64bit
,
807 find_regno (regcache
->tdesc
, "restart"), regset
+ 0);
811 mips_fill_fpregset (struct regcache
*regcache
, void *buf
)
813 union mips_register
*regset
= (union mips_register
*) buf
;
814 int i
, use_64bit
, first_fp
, big_endian
;
816 use_64bit
= (register_size (regcache
->tdesc
, 0) == 8);
817 first_fp
= find_regno (regcache
->tdesc
, "f0");
818 big_endian
= (__BYTE_ORDER
== __BIG_ENDIAN
);
820 /* See GDB for a discussion of this peculiar layout. */
821 for (i
= 0; i
< 32; i
++)
823 collect_register (regcache
, first_fp
+ i
, regset
[i
].buf
);
825 collect_register (regcache
, first_fp
+ i
,
826 regset
[i
& ~1].buf
+ 4 * (big_endian
!= (i
& 1)));
828 mips_collect_register_32bit (regcache
, use_64bit
,
829 find_regno (regcache
->tdesc
, "fcsr"), regset
[32].buf
);
830 mips_collect_register_32bit (regcache
, use_64bit
,
831 find_regno (regcache
->tdesc
, "fir"),
836 mips_store_fpregset (struct regcache
*regcache
, const void *buf
)
838 const union mips_register
*regset
= (const union mips_register
*) buf
;
839 int i
, use_64bit
, first_fp
, big_endian
;
841 use_64bit
= (register_size (regcache
->tdesc
, 0) == 8);
842 first_fp
= find_regno (regcache
->tdesc
, "f0");
843 big_endian
= (__BYTE_ORDER
== __BIG_ENDIAN
);
845 /* See GDB for a discussion of this peculiar layout. */
846 for (i
= 0; i
< 32; i
++)
848 supply_register (regcache
, first_fp
+ i
, regset
[i
].buf
);
850 supply_register (regcache
, first_fp
+ i
,
851 regset
[i
& ~1].buf
+ 4 * (big_endian
!= (i
& 1)));
853 mips_supply_register_32bit (regcache
, use_64bit
,
854 find_regno (regcache
->tdesc
, "fcsr"),
856 mips_supply_register_32bit (regcache
, use_64bit
,
857 find_regno (regcache
->tdesc
, "fir"),
860 #endif /* HAVE_PTRACE_GETREGS */
862 /* Take care of 32-bit registers with 64-bit ptrace, POKEUSER side. */
865 mips_collect_ptrace_register (struct regcache
*regcache
,
866 int regno
, char *buf
)
868 int use_64bit
= sizeof (PTRACE_XFER_TYPE
) == 8;
870 if (use_64bit
&& register_size (regcache
->tdesc
, regno
) == 4)
872 union mips_register reg
;
874 mips_collect_register (regcache
, 0, regno
, ®
);
875 memcpy (buf
, ®
, sizeof (reg
));
878 collect_register (regcache
, regno
, buf
);
881 /* Take care of 32-bit registers with 64-bit ptrace, PEEKUSER side. */
884 mips_supply_ptrace_register (struct regcache
*regcache
,
885 int regno
, const char *buf
)
887 int use_64bit
= sizeof (PTRACE_XFER_TYPE
) == 8;
889 if (use_64bit
&& register_size (regcache
->tdesc
, regno
) == 4)
891 union mips_register reg
;
893 memcpy (®
, buf
, sizeof (reg
));
894 mips_supply_register (regcache
, 0, regno
, ®
);
897 supply_register (regcache
, regno
, buf
);
900 static struct regset_info mips_regsets
[] = {
901 #ifdef HAVE_PTRACE_GETREGS
902 { PTRACE_GETREGS
, PTRACE_SETREGS
, 0, 38 * 8, GENERAL_REGS
,
903 mips_fill_gregset
, mips_store_gregset
},
904 { PTRACE_GETFPREGS
, PTRACE_SETFPREGS
, 0, 33 * 8, FP_REGS
,
905 mips_fill_fpregset
, mips_store_fpregset
},
906 #endif /* HAVE_PTRACE_GETREGS */
910 static struct regsets_info mips_regsets_info
=
912 mips_regsets
, /* regsets */
914 NULL
, /* disabled_regsets */
917 static struct usrregs_info mips_dsp_usrregs_info
=
923 static struct usrregs_info mips_usrregs_info
=
929 static struct regs_info dsp_regs_info
=
931 mips_dsp_regset_bitmap
,
932 &mips_dsp_usrregs_info
,
936 static struct regs_info myregs_info
=
938 NULL
, /* regset_bitmap */
944 mips_target::get_regs_info ()
947 return &dsp_regs_info
;
952 struct linux_target_ops the_low_target
= {
956 NULL
, /* breakpoint_kind_from_pc */
957 mips_sw_breakpoint_from_kind
,
958 NULL
, /* get_next_pcs */
961 mips_supports_z_point_type
,
964 mips_stopped_by_watchpoint
,
965 mips_stopped_data_address
,
966 mips_collect_ptrace_register
,
967 mips_supply_ptrace_register
,
968 NULL
, /* siginfo_fixup */
969 mips_linux_new_process
,
970 mips_linux_delete_process
,
971 mips_linux_new_thread
,
972 mips_linux_delete_thread
,
974 mips_linux_prepare_to_resume
977 /* The linux target ops object. */
979 linux_process_target
*the_linux_target
= &the_mips_target
;
982 initialize_low_arch (void)
984 /* Initialize the Linux target descriptions. */
985 init_registers_mips_linux ();
986 init_registers_mips_dsp_linux ();
987 init_registers_mips64_linux ();
988 init_registers_mips64_dsp_linux ();
990 initialize_regsets_info (&mips_regsets_info
);