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
;
41 /* The singleton target ops object. */
43 static mips_target the_mips_target
;
45 /* Defined in auto-generated file mips-linux.c. */
46 void init_registers_mips_linux (void);
47 extern const struct target_desc
*tdesc_mips_linux
;
49 /* Defined in auto-generated file mips-dsp-linux.c. */
50 void init_registers_mips_dsp_linux (void);
51 extern const struct target_desc
*tdesc_mips_dsp_linux
;
53 /* Defined in auto-generated file mips64-linux.c. */
54 void init_registers_mips64_linux (void);
55 extern const struct target_desc
*tdesc_mips64_linux
;
57 /* Defined in auto-generated file mips64-dsp-linux.c. */
58 void init_registers_mips64_dsp_linux (void);
59 extern const struct target_desc
*tdesc_mips64_dsp_linux
;
62 #define tdesc_mips_linux tdesc_mips64_linux
63 #define tdesc_mips_dsp_linux tdesc_mips64_dsp_linux
66 #ifndef PTRACE_GET_THREAD_AREA
67 #define PTRACE_GET_THREAD_AREA 25
74 #define mips_num_regs 73
75 #define mips_dsp_num_regs 80
77 #include <asm/ptrace.h>
81 #define DSP_CONTROL 77
88 /* Deliberately signed, for proper sign extension. */
93 /* Return the ptrace ``address'' of register REGNO. */
95 #define mips_base_regs \
96 -1, 1, 2, 3, 4, 5, 6, 7, \
97 8, 9, 10, 11, 12, 13, 14, 15, \
98 16, 17, 18, 19, 20, 21, 22, 23, \
99 24, 25, 26, 27, 28, 29, 30, 31, \
101 -1, MMLO, MMHI, BADVADDR, CAUSE, PC, \
103 FPR_BASE, FPR_BASE + 1, FPR_BASE + 2, FPR_BASE + 3, \
104 FPR_BASE + 4, FPR_BASE + 5, FPR_BASE + 6, FPR_BASE + 7, \
105 FPR_BASE + 8, FPR_BASE + 9, FPR_BASE + 10, FPR_BASE + 11, \
106 FPR_BASE + 12, FPR_BASE + 13, FPR_BASE + 14, FPR_BASE + 15, \
107 FPR_BASE + 16, FPR_BASE + 17, FPR_BASE + 18, FPR_BASE + 19, \
108 FPR_BASE + 20, FPR_BASE + 21, FPR_BASE + 22, FPR_BASE + 23, \
109 FPR_BASE + 24, FPR_BASE + 25, FPR_BASE + 26, FPR_BASE + 27, \
110 FPR_BASE + 28, FPR_BASE + 29, FPR_BASE + 30, FPR_BASE + 31, \
113 #define mips_dsp_regs \
114 DSP_BASE, DSP_BASE + 1, DSP_BASE + 2, DSP_BASE + 3, \
115 DSP_BASE + 4, DSP_BASE + 5, \
118 static int mips_regmap
[mips_num_regs
] = {
123 static int mips_dsp_regmap
[mips_dsp_num_regs
] = {
129 /* DSP registers are not in any regset and can only be accessed
132 static unsigned char mips_dsp_regset_bitmap
[(mips_dsp_num_regs
+ 7) / 8] = {
133 0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x80
136 static int have_dsp
= -1;
138 /* Try peeking at an arbitrarily chosen DSP register and pick the available
139 user register set accordingly. */
141 static const struct target_desc
*
142 mips_read_description (void)
146 int pid
= lwpid_of (current_thread
);
149 ptrace (PTRACE_PEEKUSER
, pid
, DSP_CONTROL
, 0);
159 perror_with_name ("ptrace");
164 return have_dsp
? tdesc_mips_dsp_linux
: tdesc_mips_linux
;
168 mips_target::low_arch_setup ()
170 current_process ()->tdesc
= mips_read_description ();
173 static struct usrregs_info
*
174 get_usrregs_info (void)
176 const struct regs_info
*regs_info
= the_linux_target
->get_regs_info ();
178 return regs_info
->usrregs
;
181 /* Per-process arch-specific data we want to keep. */
183 struct arch_process_info
185 /* -1 if the kernel and/or CPU do not support watch registers.
186 1 if watch_readback is valid and we can read style, num_valid
188 0 if we need to read the watch_readback. */
190 int watch_readback_valid
;
192 /* Cached watch register read values. */
194 struct pt_watch_regs watch_readback
;
196 /* Current watchpoint requests for this process. */
198 struct mips_watchpoint
*current_watches
;
200 /* The current set of watch register values for writing the
203 struct pt_watch_regs watch_mirror
;
206 /* Per-thread arch-specific data we want to keep. */
210 /* Non-zero if our copy differs from what's recorded in the thread. */
211 int watch_registers_changed
;
214 /* From mips-linux-nat.c. */
216 /* Pseudo registers can not be read. ptrace does not provide a way to
217 read (or set) PS_REGNUM, and there's no point in reading or setting
218 ZERO_REGNUM, it's always 0. We also can not set BADVADDR, CAUSE,
219 or FCRIR via ptrace(). */
222 mips_cannot_fetch_register (int regno
)
224 const struct target_desc
*tdesc
;
226 if (get_usrregs_info ()->regmap
[regno
] == -1)
229 tdesc
= current_process ()->tdesc
;
231 /* On n32 we can't access 64-bit registers via PTRACE_PEEKUSR. */
232 if (register_size (tdesc
, regno
) > sizeof (PTRACE_XFER_TYPE
))
235 if (find_regno (tdesc
, "r0") == regno
)
242 mips_cannot_store_register (int regno
)
244 const struct target_desc
*tdesc
;
246 if (get_usrregs_info ()->regmap
[regno
] == -1)
249 tdesc
= current_process ()->tdesc
;
251 /* On n32 we can't access 64-bit registers via PTRACE_POKEUSR. */
252 if (register_size (tdesc
, regno
) > sizeof (PTRACE_XFER_TYPE
))
255 if (find_regno (tdesc
, "r0") == regno
)
258 if (find_regno (tdesc
, "cause") == regno
)
261 if (find_regno (tdesc
, "badvaddr") == regno
)
264 if (find_regno (tdesc
, "fir") == regno
)
271 mips_fetch_register (struct regcache
*regcache
, int regno
)
273 const struct target_desc
*tdesc
= current_process ()->tdesc
;
275 if (find_regno (tdesc
, "r0") == regno
)
277 supply_register_zeroed (regcache
, regno
);
285 mips_get_pc (struct regcache
*regcache
)
287 union mips_register pc
;
288 collect_register_by_name (regcache
, "pc", pc
.buf
);
289 return register_size (regcache
->tdesc
, 0) == 4 ? pc
.reg32
: pc
.reg64
;
293 mips_set_pc (struct regcache
*regcache
, CORE_ADDR pc
)
295 union mips_register newpc
;
296 if (register_size (regcache
->tdesc
, 0) == 4)
301 supply_register_by_name (regcache
, "pc", newpc
.buf
);
304 /* Correct in either endianness. */
305 static const unsigned int mips_breakpoint
= 0x0005000d;
306 #define mips_breakpoint_len 4
308 /* Implementation of linux_target_ops method "sw_breakpoint_from_kind". */
310 static const gdb_byte
*
311 mips_sw_breakpoint_from_kind (int kind
, int *size
)
313 *size
= mips_breakpoint_len
;
314 return (const gdb_byte
*) &mips_breakpoint
;
318 mips_breakpoint_at (CORE_ADDR where
)
322 the_target
->read_memory (where
, (unsigned char *) &insn
, 4);
323 if (insn
== mips_breakpoint
)
326 /* If necessary, recognize more trap instructions here. GDB only uses the
331 /* Mark the watch registers of lwp, represented by ENTRY, as changed. */
334 update_watch_registers_callback (thread_info
*thread
)
336 struct lwp_info
*lwp
= get_thread_lwp (thread
);
338 /* The actual update is done later just before resuming the lwp,
339 we just mark that the registers need updating. */
340 lwp
->arch_private
->watch_registers_changed
= 1;
342 /* If the lwp isn't stopped, force it to momentarily pause, so
343 we can update its watch registers. */
345 linux_stop_lwp (lwp
);
348 /* This is the implementation of linux_target_ops method
351 static struct arch_process_info
*
352 mips_linux_new_process (void)
354 struct arch_process_info
*info
= XCNEW (struct arch_process_info
);
359 /* This is the implementation of linux_target_ops method
363 mips_linux_delete_process (struct arch_process_info
*info
)
368 /* This is the implementation of linux_target_ops method new_thread.
369 Mark the watch registers as changed, so the threads' copies will
373 mips_linux_new_thread (struct lwp_info
*lwp
)
375 struct arch_lwp_info
*info
= XCNEW (struct arch_lwp_info
);
377 info
->watch_registers_changed
= 1;
379 lwp
->arch_private
= info
;
382 /* Function to call when a thread is being deleted. */
385 mips_linux_delete_thread (struct arch_lwp_info
*arch_lwp
)
390 /* Create a new mips_watchpoint and add it to the list. */
393 mips_add_watchpoint (struct arch_process_info
*priv
, CORE_ADDR addr
, int len
,
394 enum target_hw_bp_type watch_type
)
396 struct mips_watchpoint
*new_watch
;
397 struct mips_watchpoint
**pw
;
399 new_watch
= XNEW (struct mips_watchpoint
);
400 new_watch
->addr
= addr
;
401 new_watch
->len
= len
;
402 new_watch
->type
= watch_type
;
403 new_watch
->next
= NULL
;
405 pw
= &priv
->current_watches
;
411 /* Hook to call when a new fork is attached. */
414 mips_linux_new_fork (struct process_info
*parent
,
415 struct process_info
*child
)
417 struct arch_process_info
*parent_private
;
418 struct arch_process_info
*child_private
;
419 struct mips_watchpoint
*wp
;
421 /* These are allocated by linux_add_process. */
422 gdb_assert (parent
->priv
!= NULL
423 && parent
->priv
->arch_private
!= NULL
);
424 gdb_assert (child
->priv
!= NULL
425 && child
->priv
->arch_private
!= NULL
);
427 /* Linux kernel before 2.6.33 commit
428 72f674d203cd230426437cdcf7dd6f681dad8b0d
429 will inherit hardware debug registers from parent
430 on fork/vfork/clone. Newer Linux kernels create such tasks with
431 zeroed debug registers.
433 GDB core assumes the child inherits the watchpoints/hw
434 breakpoints of the parent, and will remove them all from the
435 forked off process. Copy the debug registers mirrors into the
436 new process so that all breakpoints and watchpoints can be
437 removed together. The debug registers mirror will become zeroed
438 in the end before detaching the forked off process, thus making
439 this compatible with older Linux kernels too. */
441 parent_private
= parent
->priv
->arch_private
;
442 child_private
= child
->priv
->arch_private
;
444 child_private
->watch_readback_valid
= parent_private
->watch_readback_valid
;
445 child_private
->watch_readback
= parent_private
->watch_readback
;
447 for (wp
= parent_private
->current_watches
; wp
!= NULL
; wp
= wp
->next
)
448 mips_add_watchpoint (child_private
, wp
->addr
, wp
->len
, wp
->type
);
450 child_private
->watch_mirror
= parent_private
->watch_mirror
;
452 /* This is the implementation of linux_target_ops method
453 prepare_to_resume. If the watch regs have changed, update the
457 mips_linux_prepare_to_resume (struct lwp_info
*lwp
)
459 ptid_t ptid
= ptid_of (get_lwp_thread (lwp
));
460 struct process_info
*proc
= find_process_pid (ptid
.pid ());
461 struct arch_process_info
*priv
= proc
->priv
->arch_private
;
463 if (lwp
->arch_private
->watch_registers_changed
)
465 /* Only update the watch registers if we have set or unset a
466 watchpoint already. */
467 if (mips_linux_watch_get_num_valid (&priv
->watch_mirror
) > 0)
469 /* Write the mirrored watch register values. */
470 int tid
= ptid
.lwp ();
472 if (-1 == ptrace (PTRACE_SET_WATCH_REGS
, tid
,
473 &priv
->watch_mirror
, NULL
))
474 perror_with_name ("Couldn't write watch register");
477 lwp
->arch_private
->watch_registers_changed
= 0;
482 mips_supports_z_point_type (char z_type
)
486 case Z_PACKET_WRITE_WP
:
487 case Z_PACKET_READ_WP
:
488 case Z_PACKET_ACCESS_WP
:
495 /* This is the implementation of linux_target_ops method
499 mips_insert_point (enum raw_bkpt_type type
, CORE_ADDR addr
,
500 int len
, struct raw_breakpoint
*bp
)
502 struct process_info
*proc
= current_process ();
503 struct arch_process_info
*priv
= proc
->priv
->arch_private
;
504 struct pt_watch_regs regs
;
506 enum target_hw_bp_type watch_type
;
509 lwpid
= lwpid_of (current_thread
);
510 if (!mips_linux_read_watch_registers (lwpid
,
511 &priv
->watch_readback
,
512 &priv
->watch_readback_valid
,
519 regs
= priv
->watch_readback
;
520 /* Add the current watches. */
521 mips_linux_watch_populate_regs (priv
->current_watches
, ®s
);
523 /* Now try to add the new watch. */
524 watch_type
= raw_bkpt_type_to_target_hw_bp_type (type
);
525 irw
= mips_linux_watch_type_to_irw (watch_type
);
526 if (!mips_linux_watch_try_one_watch (®s
, addr
, len
, irw
))
529 /* It fit. Stick it on the end of the list. */
530 mips_add_watchpoint (priv
, addr
, len
, watch_type
);
532 priv
->watch_mirror
= regs
;
534 /* Only update the threads of this process. */
535 for_each_thread (proc
->pid
, update_watch_registers_callback
);
540 /* This is the implementation of linux_target_ops method
544 mips_remove_point (enum raw_bkpt_type type
, CORE_ADDR addr
,
545 int len
, struct raw_breakpoint
*bp
)
547 struct process_info
*proc
= current_process ();
548 struct arch_process_info
*priv
= proc
->priv
->arch_private
;
551 enum target_hw_bp_type watch_type
;
553 struct mips_watchpoint
**pw
;
554 struct mips_watchpoint
*w
;
556 /* Search for a known watch that matches. Then unlink and free it. */
557 watch_type
= raw_bkpt_type_to_target_hw_bp_type (type
);
559 pw
= &priv
->current_watches
;
562 if (w
->addr
== addr
&& w
->len
== len
&& w
->type
== watch_type
)
573 return -1; /* We don't know about it, fail doing nothing. */
575 /* At this point watch_readback is known to be valid because we
576 could not have added the watch without reading it. */
577 gdb_assert (priv
->watch_readback_valid
== 1);
579 priv
->watch_mirror
= priv
->watch_readback
;
580 mips_linux_watch_populate_regs (priv
->current_watches
,
581 &priv
->watch_mirror
);
583 /* Only update the threads of this process. */
584 for_each_thread (proc
->pid
, update_watch_registers_callback
);
589 /* This is the implementation of linux_target_ops method
590 stopped_by_watchpoint. The watchhi R and W bits indicate
591 the watch register triggered. */
594 mips_stopped_by_watchpoint (void)
596 struct process_info
*proc
= current_process ();
597 struct arch_process_info
*priv
= proc
->priv
->arch_private
;
600 long lwpid
= lwpid_of (current_thread
);
602 if (!mips_linux_read_watch_registers (lwpid
,
603 &priv
->watch_readback
,
604 &priv
->watch_readback_valid
,
608 num_valid
= mips_linux_watch_get_num_valid (&priv
->watch_readback
);
610 for (n
= 0; n
< MAX_DEBUG_REGISTER
&& n
< num_valid
; n
++)
611 if (mips_linux_watch_get_watchhi (&priv
->watch_readback
, n
)
618 /* This is the implementation of linux_target_ops method
619 stopped_data_address. */
622 mips_stopped_data_address (void)
624 struct process_info
*proc
= current_process ();
625 struct arch_process_info
*priv
= proc
->priv
->arch_private
;
628 long lwpid
= lwpid_of (current_thread
);
630 /* On MIPS we don't know the low order 3 bits of the data address.
631 GDB does not support remote targets that can't report the
632 watchpoint address. So, make our best guess; return the starting
633 address of a watchpoint request which overlaps the one that
636 if (!mips_linux_read_watch_registers (lwpid
,
637 &priv
->watch_readback
,
638 &priv
->watch_readback_valid
,
642 num_valid
= mips_linux_watch_get_num_valid (&priv
->watch_readback
);
644 for (n
= 0; n
< MAX_DEBUG_REGISTER
&& n
< num_valid
; n
++)
645 if (mips_linux_watch_get_watchhi (&priv
->watch_readback
, n
)
648 CORE_ADDR t_low
, t_hi
;
650 struct mips_watchpoint
*watch
;
652 t_low
= mips_linux_watch_get_watchlo (&priv
->watch_readback
, n
);
653 t_irw
= t_low
& IRW_MASK
;
654 t_hi
= (mips_linux_watch_get_watchhi (&priv
->watch_readback
, n
)
656 t_low
&= ~(CORE_ADDR
)t_hi
;
658 for (watch
= priv
->current_watches
;
662 CORE_ADDR addr
= watch
->addr
;
663 CORE_ADDR last_byte
= addr
+ watch
->len
- 1;
665 if ((t_irw
& mips_linux_watch_type_to_irw (watch
->type
)) == 0)
667 /* Different type. */
670 /* Check for overlap of even a single byte. */
671 if (last_byte
>= t_low
&& addr
<= t_low
+ t_hi
)
676 /* Shouldn't happen. */
680 /* Fetch the thread-local storage pointer for libthread_db. */
683 ps_get_thread_area (struct ps_prochandle
*ph
,
684 lwpid_t lwpid
, int idx
, void **base
)
686 if (ptrace (PTRACE_GET_THREAD_AREA
, lwpid
, NULL
, base
) != 0)
689 /* IDX is the bias from the thread pointer to the beginning of the
690 thread descriptor. It has to be subtracted due to implementation
691 quirks in libthread_db. */
692 *base
= (void *) ((char *)*base
- idx
);
698 mips_collect_register (struct regcache
*regcache
,
699 int use_64bit
, int regno
, union mips_register
*reg
)
701 union mips_register tmp_reg
;
705 collect_register (regcache
, regno
, &tmp_reg
.reg64
);
710 collect_register (regcache
, regno
, &tmp_reg
.reg32
);
711 reg
->reg64
= tmp_reg
.reg32
;
716 mips_supply_register (struct regcache
*regcache
,
717 int use_64bit
, int regno
, const union mips_register
*reg
)
721 /* For big-endian 32-bit targets, ignore the high four bytes of each
723 if (__BYTE_ORDER
== __BIG_ENDIAN
&& !use_64bit
)
726 supply_register (regcache
, regno
, reg
->buf
+ offset
);
729 #ifdef HAVE_PTRACE_GETREGS
732 mips_collect_register_32bit (struct regcache
*regcache
,
733 int use_64bit
, int regno
, unsigned char *buf
)
735 union mips_register tmp_reg
;
738 mips_collect_register (regcache
, use_64bit
, regno
, &tmp_reg
);
739 reg32
= tmp_reg
.reg64
;
740 memcpy (buf
, ®32
, 4);
744 mips_supply_register_32bit (struct regcache
*regcache
,
745 int use_64bit
, int regno
, const unsigned char *buf
)
747 union mips_register tmp_reg
;
750 memcpy (®32
, buf
, 4);
751 tmp_reg
.reg64
= reg32
;
752 mips_supply_register (regcache
, use_64bit
, regno
, &tmp_reg
);
756 mips_fill_gregset (struct regcache
*regcache
, void *buf
)
758 union mips_register
*regset
= (union mips_register
*) buf
;
760 const struct target_desc
*tdesc
= regcache
->tdesc
;
762 use_64bit
= (register_size (tdesc
, 0) == 8);
764 for (i
= 1; i
< 32; i
++)
765 mips_collect_register (regcache
, use_64bit
, i
, regset
+ i
);
767 mips_collect_register (regcache
, use_64bit
,
768 find_regno (tdesc
, "lo"), regset
+ 32);
769 mips_collect_register (regcache
, use_64bit
,
770 find_regno (tdesc
, "hi"), regset
+ 33);
771 mips_collect_register (regcache
, use_64bit
,
772 find_regno (tdesc
, "pc"), regset
+ 34);
773 mips_collect_register (regcache
, use_64bit
,
774 find_regno (tdesc
, "badvaddr"), regset
+ 35);
775 mips_collect_register (regcache
, use_64bit
,
776 find_regno (tdesc
, "status"), regset
+ 36);
777 mips_collect_register (regcache
, use_64bit
,
778 find_regno (tdesc
, "cause"), regset
+ 37);
780 mips_collect_register (regcache
, use_64bit
,
781 find_regno (tdesc
, "restart"), regset
+ 0);
785 mips_store_gregset (struct regcache
*regcache
, const void *buf
)
787 const union mips_register
*regset
= (const union mips_register
*) buf
;
790 use_64bit
= (register_size (regcache
->tdesc
, 0) == 8);
792 supply_register_by_name_zeroed (regcache
, "r0");
794 for (i
= 1; i
< 32; i
++)
795 mips_supply_register (regcache
, use_64bit
, i
, regset
+ i
);
797 mips_supply_register (regcache
, use_64bit
,
798 find_regno (regcache
->tdesc
, "lo"), regset
+ 32);
799 mips_supply_register (regcache
, use_64bit
,
800 find_regno (regcache
->tdesc
, "hi"), regset
+ 33);
801 mips_supply_register (regcache
, use_64bit
,
802 find_regno (regcache
->tdesc
, "pc"), regset
+ 34);
803 mips_supply_register (regcache
, use_64bit
,
804 find_regno (regcache
->tdesc
, "badvaddr"), regset
+ 35);
805 mips_supply_register (regcache
, use_64bit
,
806 find_regno (regcache
->tdesc
, "status"), regset
+ 36);
807 mips_supply_register (regcache
, use_64bit
,
808 find_regno (regcache
->tdesc
, "cause"), regset
+ 37);
810 mips_supply_register (regcache
, use_64bit
,
811 find_regno (regcache
->tdesc
, "restart"), regset
+ 0);
815 mips_fill_fpregset (struct regcache
*regcache
, void *buf
)
817 union mips_register
*regset
= (union mips_register
*) buf
;
818 int i
, use_64bit
, first_fp
, big_endian
;
820 use_64bit
= (register_size (regcache
->tdesc
, 0) == 8);
821 first_fp
= find_regno (regcache
->tdesc
, "f0");
822 big_endian
= (__BYTE_ORDER
== __BIG_ENDIAN
);
824 /* See GDB for a discussion of this peculiar layout. */
825 for (i
= 0; i
< 32; i
++)
827 collect_register (regcache
, first_fp
+ i
, regset
[i
].buf
);
829 collect_register (regcache
, first_fp
+ i
,
830 regset
[i
& ~1].buf
+ 4 * (big_endian
!= (i
& 1)));
832 mips_collect_register_32bit (regcache
, use_64bit
,
833 find_regno (regcache
->tdesc
, "fcsr"), regset
[32].buf
);
834 mips_collect_register_32bit (regcache
, use_64bit
,
835 find_regno (regcache
->tdesc
, "fir"),
840 mips_store_fpregset (struct regcache
*regcache
, const void *buf
)
842 const union mips_register
*regset
= (const union mips_register
*) buf
;
843 int i
, use_64bit
, first_fp
, big_endian
;
845 use_64bit
= (register_size (regcache
->tdesc
, 0) == 8);
846 first_fp
= find_regno (regcache
->tdesc
, "f0");
847 big_endian
= (__BYTE_ORDER
== __BIG_ENDIAN
);
849 /* See GDB for a discussion of this peculiar layout. */
850 for (i
= 0; i
< 32; i
++)
852 supply_register (regcache
, first_fp
+ i
, regset
[i
].buf
);
854 supply_register (regcache
, first_fp
+ i
,
855 regset
[i
& ~1].buf
+ 4 * (big_endian
!= (i
& 1)));
857 mips_supply_register_32bit (regcache
, use_64bit
,
858 find_regno (regcache
->tdesc
, "fcsr"),
860 mips_supply_register_32bit (regcache
, use_64bit
,
861 find_regno (regcache
->tdesc
, "fir"),
864 #endif /* HAVE_PTRACE_GETREGS */
866 /* Take care of 32-bit registers with 64-bit ptrace, POKEUSER side. */
869 mips_collect_ptrace_register (struct regcache
*regcache
,
870 int regno
, char *buf
)
872 int use_64bit
= sizeof (PTRACE_XFER_TYPE
) == 8;
874 if (use_64bit
&& register_size (regcache
->tdesc
, regno
) == 4)
876 union mips_register reg
;
878 mips_collect_register (regcache
, 0, regno
, ®
);
879 memcpy (buf
, ®
, sizeof (reg
));
882 collect_register (regcache
, regno
, buf
);
885 /* Take care of 32-bit registers with 64-bit ptrace, PEEKUSER side. */
888 mips_supply_ptrace_register (struct regcache
*regcache
,
889 int regno
, const char *buf
)
891 int use_64bit
= sizeof (PTRACE_XFER_TYPE
) == 8;
893 if (use_64bit
&& register_size (regcache
->tdesc
, regno
) == 4)
895 union mips_register reg
;
897 memcpy (®
, buf
, sizeof (reg
));
898 mips_supply_register (regcache
, 0, regno
, ®
);
901 supply_register (regcache
, regno
, buf
);
904 static struct regset_info mips_regsets
[] = {
905 #ifdef HAVE_PTRACE_GETREGS
906 { PTRACE_GETREGS
, PTRACE_SETREGS
, 0, 38 * 8, GENERAL_REGS
,
907 mips_fill_gregset
, mips_store_gregset
},
908 { PTRACE_GETFPREGS
, PTRACE_SETFPREGS
, 0, 33 * 8, FP_REGS
,
909 mips_fill_fpregset
, mips_store_fpregset
},
910 #endif /* HAVE_PTRACE_GETREGS */
914 static struct regsets_info mips_regsets_info
=
916 mips_regsets
, /* regsets */
918 NULL
, /* disabled_regsets */
921 static struct usrregs_info mips_dsp_usrregs_info
=
927 static struct usrregs_info mips_usrregs_info
=
933 static struct regs_info dsp_regs_info
=
935 mips_dsp_regset_bitmap
,
936 &mips_dsp_usrregs_info
,
940 static struct regs_info myregs_info
=
942 NULL
, /* regset_bitmap */
948 mips_target::get_regs_info ()
951 return &dsp_regs_info
;
956 struct linux_target_ops the_low_target
= {
957 mips_cannot_fetch_register
,
958 mips_cannot_store_register
,
962 NULL
, /* breakpoint_kind_from_pc */
963 mips_sw_breakpoint_from_kind
,
964 NULL
, /* get_next_pcs */
967 mips_supports_z_point_type
,
970 mips_stopped_by_watchpoint
,
971 mips_stopped_data_address
,
972 mips_collect_ptrace_register
,
973 mips_supply_ptrace_register
,
974 NULL
, /* siginfo_fixup */
975 mips_linux_new_process
,
976 mips_linux_delete_process
,
977 mips_linux_new_thread
,
978 mips_linux_delete_thread
,
980 mips_linux_prepare_to_resume
983 /* The linux target ops object. */
985 linux_process_target
*the_linux_target
= &the_mips_target
;
988 initialize_low_arch (void)
990 /* Initialize the Linux target descriptions. */
991 init_registers_mips_linux ();
992 init_registers_mips_dsp_linux ();
993 init_registers_mips64_linux ();
994 init_registers_mips64_dsp_linux ();
996 initialize_regsets_info (&mips_regsets_info
);