1 /* GNU/Linux/ARM specific low level interface, for the remote server for GDB.
2 Copyright (C) 1995-2015 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"
23 /* Don't include elf.h if linux/elf.h got included by gdb_proc_service.h.
24 On Bionic elf.h and linux/elf.h have conflicting definitions. */
28 #include "nat/gdb_ptrace.h"
31 /* Defined in auto-generated files. */
32 void init_registers_arm (void);
33 extern const struct target_desc
*tdesc_arm
;
35 void init_registers_arm_with_iwmmxt (void);
36 extern const struct target_desc
*tdesc_arm_with_iwmmxt
;
38 void init_registers_arm_with_vfpv2 (void);
39 extern const struct target_desc
*tdesc_arm_with_vfpv2
;
41 void init_registers_arm_with_vfpv3 (void);
42 extern const struct target_desc
*tdesc_arm_with_vfpv3
;
44 void init_registers_arm_with_neon (void);
45 extern const struct target_desc
*tdesc_arm_with_neon
;
47 #ifndef PTRACE_GET_THREAD_AREA
48 #define PTRACE_GET_THREAD_AREA 22
51 #ifndef PTRACE_GETWMMXREGS
52 # define PTRACE_GETWMMXREGS 18
53 # define PTRACE_SETWMMXREGS 19
56 #ifndef PTRACE_GETVFPREGS
57 # define PTRACE_GETVFPREGS 27
58 # define PTRACE_SETVFPREGS 28
61 #ifndef PTRACE_GETHBPREGS
62 #define PTRACE_GETHBPREGS 29
63 #define PTRACE_SETHBPREGS 30
66 /* Information describing the hardware breakpoint capabilities. */
70 unsigned char max_wp_length
;
71 unsigned char wp_count
;
72 unsigned char bp_count
;
75 /* Enum describing the different types of ARM hardware break-/watch-points. */
84 /* Type describing an ARM Hardware Breakpoint Control register value. */
85 typedef unsigned int arm_hwbp_control_t
;
87 /* Structure used to keep track of hardware break-/watch-points. */
88 struct arm_linux_hw_breakpoint
90 /* Address to break on, or being watched. */
92 /* Control register for break-/watch- point. */
93 arm_hwbp_control_t control
;
96 /* Since we cannot dynamically allocate subfields of arch_process_info,
97 assume a maximum number of supported break-/watchpoints. */
101 /* Per-process arch-specific data we want to keep. */
102 struct arch_process_info
104 /* Hardware breakpoints for this process. */
105 struct arm_linux_hw_breakpoint bpts
[MAX_BPTS
];
106 /* Hardware watchpoints for this process. */
107 struct arm_linux_hw_breakpoint wpts
[MAX_WPTS
];
110 /* Per-thread arch-specific data we want to keep. */
113 /* Non-zero if our copy differs from what's recorded in the thread. */
114 char bpts_changed
[MAX_BPTS
];
115 char wpts_changed
[MAX_WPTS
];
116 /* Cached stopped data address. */
117 CORE_ADDR stopped_data_address
;
120 static unsigned long arm_hwcap
;
122 /* These are in <asm/elf.h> in current kernels. */
124 #define HWCAP_IWMMXT 512
125 #define HWCAP_NEON 4096
126 #define HWCAP_VFPv3 8192
127 #define HWCAP_VFPv3D16 16384
129 #ifdef HAVE_SYS_REG_H
133 #define arm_num_regs 26
135 static int arm_regmap
[] = {
136 0, 4, 8, 12, 16, 20, 24, 28,
137 32, 36, 40, 44, 48, 52, 56, 60,
138 -1, -1, -1, -1, -1, -1, -1, -1, -1,
143 arm_cannot_store_register (int regno
)
145 return (regno
>= arm_num_regs
);
149 arm_cannot_fetch_register (int regno
)
151 return (regno
>= arm_num_regs
);
155 arm_fill_gregset (struct regcache
*regcache
, void *buf
)
158 uint32_t *regs
= buf
;
160 for (i
= ARM_A1_REGNUM
; i
<= ARM_PC_REGNUM
; i
++)
161 collect_register (regcache
, i
, ®s
[i
]);
163 collect_register (regcache
, ARM_PS_REGNUM
, ®s
[16]);
167 arm_store_gregset (struct regcache
*regcache
, const void *buf
)
171 const uint32_t *regs
= buf
;
173 memset (zerobuf
, 0, 8);
174 for (i
= ARM_A1_REGNUM
; i
<= ARM_PC_REGNUM
; i
++)
175 supply_register (regcache
, i
, ®s
[i
]);
177 for (; i
< ARM_PS_REGNUM
; i
++)
178 supply_register (regcache
, i
, zerobuf
);
180 supply_register (regcache
, ARM_PS_REGNUM
, ®s
[16]);
184 arm_fill_wmmxregset (struct regcache
*regcache
, void *buf
)
188 if (!(arm_hwcap
& HWCAP_IWMMXT
))
191 for (i
= 0; i
< 16; i
++)
192 collect_register (regcache
, arm_num_regs
+ i
, (char *) buf
+ i
* 8);
194 /* We only have access to wcssf, wcasf, and wcgr0-wcgr3. */
195 for (i
= 0; i
< 6; i
++)
196 collect_register (regcache
, arm_num_regs
+ i
+ 16,
197 (char *) buf
+ 16 * 8 + i
* 4);
201 arm_store_wmmxregset (struct regcache
*regcache
, const void *buf
)
205 if (!(arm_hwcap
& HWCAP_IWMMXT
))
208 for (i
= 0; i
< 16; i
++)
209 supply_register (regcache
, arm_num_regs
+ i
, (char *) buf
+ i
* 8);
211 /* We only have access to wcssf, wcasf, and wcgr0-wcgr3. */
212 for (i
= 0; i
< 6; i
++)
213 supply_register (regcache
, arm_num_regs
+ i
+ 16,
214 (char *) buf
+ 16 * 8 + i
* 4);
218 arm_fill_vfpregset (struct regcache
*regcache
, void *buf
)
222 if (!(arm_hwcap
& HWCAP_VFP
))
225 if ((arm_hwcap
& (HWCAP_VFPv3
| HWCAP_VFPv3D16
)) == HWCAP_VFPv3
)
230 base
= find_regno (regcache
->tdesc
, "d0");
231 for (i
= 0; i
< num
; i
++)
232 collect_register (regcache
, base
+ i
, (char *) buf
+ i
* 8);
234 collect_register_by_name (regcache
, "fpscr", (char *) buf
+ 32 * 8);
238 arm_store_vfpregset (struct regcache
*regcache
, const void *buf
)
242 if (!(arm_hwcap
& HWCAP_VFP
))
245 if ((arm_hwcap
& (HWCAP_VFPv3
| HWCAP_VFPv3D16
)) == HWCAP_VFPv3
)
250 base
= find_regno (regcache
->tdesc
, "d0");
251 for (i
= 0; i
< num
; i
++)
252 supply_register (regcache
, base
+ i
, (char *) buf
+ i
* 8);
254 supply_register_by_name (regcache
, "fpscr", (char *) buf
+ 32 * 8);
257 extern int debug_threads
;
260 arm_get_pc (struct regcache
*regcache
)
263 collect_register_by_name (regcache
, "pc", &pc
);
265 debug_printf ("stop pc is %08lx\n", pc
);
270 arm_set_pc (struct regcache
*regcache
, CORE_ADDR pc
)
272 unsigned long newpc
= pc
;
273 supply_register_by_name (regcache
, "pc", &newpc
);
276 /* Correct in either endianness. */
277 static const unsigned long arm_breakpoint
= 0xef9f0001;
278 #define arm_breakpoint_len 4
279 static const unsigned short thumb_breakpoint
= 0xde01;
280 static const unsigned short thumb2_breakpoint
[] = { 0xf7f0, 0xa000 };
282 /* For new EABI binaries. We recognize it regardless of which ABI
283 is used for gdbserver, so single threaded debugging should work
284 OK, but for multi-threaded debugging we only insert the current
285 ABI's breakpoint instruction. For now at least. */
286 static const unsigned long arm_eabi_breakpoint
= 0xe7f001f0;
289 arm_breakpoint_at (CORE_ADDR where
)
291 struct regcache
*regcache
= get_thread_regcache (current_thread
, 1);
294 collect_register_by_name (regcache
, "cpsr", &cpsr
);
301 (*the_target
->read_memory
) (where
, (unsigned char *) &insn
, 2);
302 if (insn
== thumb_breakpoint
)
305 if (insn
== thumb2_breakpoint
[0])
307 (*the_target
->read_memory
) (where
+ 2, (unsigned char *) &insn
, 2);
308 if (insn
== thumb2_breakpoint
[1])
317 (*the_target
->read_memory
) (where
, (unsigned char *) &insn
, 4);
318 if (insn
== arm_breakpoint
)
321 if (insn
== arm_eabi_breakpoint
)
328 /* We only place breakpoints in empty marker functions, and thread locking
329 is outside of the function. So rather than importing software single-step,
330 we can just run until exit. */
332 arm_reinsert_addr (void)
334 struct regcache
*regcache
= get_thread_regcache (current_thread
, 1);
336 collect_register_by_name (regcache
, "lr", &pc
);
340 /* Fetch the thread-local storage pointer for libthread_db. */
343 ps_get_thread_area (const struct ps_prochandle
*ph
,
344 lwpid_t lwpid
, int idx
, void **base
)
346 if (ptrace (PTRACE_GET_THREAD_AREA
, lwpid
, NULL
, base
) != 0)
349 /* IDX is the bias from the thread pointer to the beginning of the
350 thread descriptor. It has to be subtracted due to implementation
351 quirks in libthread_db. */
352 *base
= (void *) ((char *)*base
- idx
);
358 /* Query Hardware Breakpoint information for the target we are attached to
359 (using PID as ptrace argument) and set up arm_linux_hwbp_cap. */
361 arm_linux_init_hwbp_cap (int pid
)
365 if (ptrace (PTRACE_GETHBPREGS
, pid
, 0, &val
) < 0)
368 arm_linux_hwbp_cap
.arch
= (unsigned char)((val
>> 24) & 0xff);
369 if (arm_linux_hwbp_cap
.arch
== 0)
372 arm_linux_hwbp_cap
.max_wp_length
= (unsigned char)((val
>> 16) & 0xff);
373 arm_linux_hwbp_cap
.wp_count
= (unsigned char)((val
>> 8) & 0xff);
374 arm_linux_hwbp_cap
.bp_count
= (unsigned char)(val
& 0xff);
376 if (arm_linux_hwbp_cap
.wp_count
> MAX_WPTS
)
377 internal_error (__FILE__
, __LINE__
, "Unsupported number of watchpoints");
378 if (arm_linux_hwbp_cap
.bp_count
> MAX_BPTS
)
379 internal_error (__FILE__
, __LINE__
, "Unsupported number of breakpoints");
382 /* How many hardware breakpoints are available? */
384 arm_linux_get_hw_breakpoint_count (void)
386 return arm_linux_hwbp_cap
.bp_count
;
389 /* How many hardware watchpoints are available? */
391 arm_linux_get_hw_watchpoint_count (void)
393 return arm_linux_hwbp_cap
.wp_count
;
396 /* Maximum length of area watched by hardware watchpoint. */
398 arm_linux_get_hw_watchpoint_max_length (void)
400 return arm_linux_hwbp_cap
.max_wp_length
;
403 /* Initialize an ARM hardware break-/watch-point control register value.
404 BYTE_ADDRESS_SELECT is the mask of bytes to trigger on; HWBP_TYPE is the
405 type of break-/watch-point; ENABLE indicates whether the point is enabled.
407 static arm_hwbp_control_t
408 arm_hwbp_control_initialize (unsigned byte_address_select
,
409 arm_hwbp_type hwbp_type
,
412 gdb_assert ((byte_address_select
& ~0xffU
) == 0);
413 gdb_assert (hwbp_type
!= arm_hwbp_break
414 || ((byte_address_select
& 0xfU
) != 0));
416 return (byte_address_select
<< 5) | (hwbp_type
<< 3) | (3 << 1) | enable
;
419 /* Does the breakpoint control value CONTROL have the enable bit set? */
421 arm_hwbp_control_is_enabled (arm_hwbp_control_t control
)
423 return control
& 0x1;
426 /* Is the breakpoint control value CONTROL initialized? */
428 arm_hwbp_control_is_initialized (arm_hwbp_control_t control
)
433 /* Change a breakpoint control word so that it is in the disabled state. */
434 static arm_hwbp_control_t
435 arm_hwbp_control_disable (arm_hwbp_control_t control
)
437 return control
& ~0x1;
440 /* Are two break-/watch-points equal? */
442 arm_linux_hw_breakpoint_equal (const struct arm_linux_hw_breakpoint
*p1
,
443 const struct arm_linux_hw_breakpoint
*p2
)
445 return p1
->address
== p2
->address
&& p1
->control
== p2
->control
;
448 /* Convert a raw breakpoint type to an enum arm_hwbp_type. */
451 raw_bkpt_type_to_arm_hwbp_type (enum raw_bkpt_type raw_type
)
455 case raw_bkpt_type_hw
:
456 return arm_hwbp_break
;
457 case raw_bkpt_type_write_wp
:
458 return arm_hwbp_store
;
459 case raw_bkpt_type_read_wp
:
460 return arm_hwbp_load
;
461 case raw_bkpt_type_access_wp
:
462 return arm_hwbp_access
;
464 gdb_assert_not_reached ("unhandled raw type");
468 /* Initialize the hardware breakpoint structure P for a breakpoint or
469 watchpoint at ADDR to LEN. The type of watchpoint is given in TYPE.
470 Returns -1 if TYPE is unsupported, or -2 if the particular combination
471 of ADDR and LEN cannot be implemented. Otherwise, returns 0 if TYPE
472 represents a breakpoint and 1 if type represents a watchpoint. */
474 arm_linux_hw_point_initialize (enum raw_bkpt_type raw_type
, CORE_ADDR addr
,
475 int len
, struct arm_linux_hw_breakpoint
*p
)
477 arm_hwbp_type hwbp_type
;
480 hwbp_type
= raw_bkpt_type_to_arm_hwbp_type (raw_type
);
482 if (hwbp_type
== arm_hwbp_break
)
484 /* For breakpoints, the length field encodes the mode. */
487 case 2: /* 16-bit Thumb mode breakpoint */
488 case 3: /* 32-bit Thumb mode breakpoint */
492 case 4: /* 32-bit ARM mode breakpoint */
503 CORE_ADDR max_wp_length
= arm_linux_get_hw_watchpoint_max_length ();
504 CORE_ADDR aligned_addr
;
506 /* Can not set watchpoints for zero or negative lengths. */
509 /* The current ptrace interface can only handle watchpoints that are a
511 if ((len
& (len
- 1)) != 0)
514 /* Test that the range [ADDR, ADDR + LEN) fits into the largest address
515 range covered by a watchpoint. */
516 aligned_addr
= addr
& ~(max_wp_length
- 1);
517 if (aligned_addr
+ max_wp_length
< addr
+ len
)
520 mask
= (1 << len
) - 1;
523 p
->address
= (unsigned int) addr
;
524 p
->control
= arm_hwbp_control_initialize (mask
, hwbp_type
, 1);
526 return hwbp_type
!= arm_hwbp_break
;
529 /* Callback to mark a watch-/breakpoint to be updated in all threads of
530 the current process. */
532 struct update_registers_data
539 update_registers_callback (struct inferior_list_entry
*entry
, void *arg
)
541 struct thread_info
*thread
= (struct thread_info
*) entry
;
542 struct lwp_info
*lwp
= get_thread_lwp (thread
);
543 struct update_registers_data
*data
= (struct update_registers_data
*) arg
;
545 /* Only update the threads of the current process. */
546 if (pid_of (thread
) == pid_of (current_thread
))
548 /* The actual update is done later just before resuming the lwp,
549 we just mark that the registers need updating. */
551 lwp
->arch_private
->wpts_changed
[data
->i
] = 1;
553 lwp
->arch_private
->bpts_changed
[data
->i
] = 1;
555 /* If the lwp isn't stopped, force it to momentarily pause, so
556 we can update its breakpoint registers. */
558 linux_stop_lwp (lwp
);
565 arm_supports_z_point_type (char z_type
)
570 case Z_PACKET_WRITE_WP
:
571 case Z_PACKET_READ_WP
:
572 case Z_PACKET_ACCESS_WP
:
575 /* Leave the handling of sw breakpoints with the gdb client. */
580 /* Insert hardware break-/watchpoint. */
582 arm_insert_point (enum raw_bkpt_type type
, CORE_ADDR addr
,
583 int len
, struct raw_breakpoint
*bp
)
585 struct process_info
*proc
= current_process ();
586 struct arm_linux_hw_breakpoint p
, *pts
;
589 watch
= arm_linux_hw_point_initialize (type
, addr
, len
, &p
);
593 return watch
== -1 ? 1 : -1;
598 count
= arm_linux_get_hw_watchpoint_count ();
599 pts
= proc
->priv
->arch_private
->wpts
;
603 count
= arm_linux_get_hw_breakpoint_count ();
604 pts
= proc
->priv
->arch_private
->bpts
;
607 for (i
= 0; i
< count
; i
++)
608 if (!arm_hwbp_control_is_enabled (pts
[i
].control
))
610 struct update_registers_data data
= { watch
, i
};
612 find_inferior (&all_threads
, update_registers_callback
, &data
);
616 /* We're out of watchpoints. */
620 /* Remove hardware break-/watchpoint. */
622 arm_remove_point (enum raw_bkpt_type type
, CORE_ADDR addr
,
623 int len
, struct raw_breakpoint
*bp
)
625 struct process_info
*proc
= current_process ();
626 struct arm_linux_hw_breakpoint p
, *pts
;
629 watch
= arm_linux_hw_point_initialize (type
, addr
, len
, &p
);
638 count
= arm_linux_get_hw_watchpoint_count ();
639 pts
= proc
->priv
->arch_private
->wpts
;
643 count
= arm_linux_get_hw_breakpoint_count ();
644 pts
= proc
->priv
->arch_private
->bpts
;
647 for (i
= 0; i
< count
; i
++)
648 if (arm_linux_hw_breakpoint_equal (&p
, pts
+ i
))
650 struct update_registers_data data
= { watch
, i
};
651 pts
[i
].control
= arm_hwbp_control_disable (pts
[i
].control
);
652 find_inferior (&all_threads
, update_registers_callback
, &data
);
656 /* No watchpoint matched. */
660 /* Return whether current thread is stopped due to a watchpoint. */
662 arm_stopped_by_watchpoint (void)
664 struct lwp_info
*lwp
= get_thread_lwp (current_thread
);
667 /* We must be able to set hardware watchpoints. */
668 if (arm_linux_get_hw_watchpoint_count () == 0)
671 /* Retrieve siginfo. */
673 ptrace (PTRACE_GETSIGINFO
, lwpid_of (current_thread
), 0, &siginfo
);
677 /* This must be a hardware breakpoint. */
678 if (siginfo
.si_signo
!= SIGTRAP
679 || (siginfo
.si_code
& 0xffff) != 0x0004 /* TRAP_HWBKPT */)
682 /* If we are in a positive slot then we're looking at a breakpoint and not
684 if (siginfo
.si_errno
>= 0)
687 /* Cache stopped data address for use by arm_stopped_data_address. */
688 lwp
->arch_private
->stopped_data_address
689 = (CORE_ADDR
) (uintptr_t) siginfo
.si_addr
;
694 /* Return data address that triggered watchpoint. Called only if
695 arm_stopped_by_watchpoint returned true. */
697 arm_stopped_data_address (void)
699 struct lwp_info
*lwp
= get_thread_lwp (current_thread
);
700 return lwp
->arch_private
->stopped_data_address
;
703 /* Called when a new process is created. */
704 static struct arch_process_info
*
705 arm_new_process (void)
707 struct arch_process_info
*info
= xcalloc (1, sizeof (*info
));
711 /* Called when a new thread is detected. */
713 arm_new_thread (struct lwp_info
*lwp
)
715 struct arch_lwp_info
*info
= xcalloc (1, sizeof (*info
));
718 for (i
= 0; i
< MAX_BPTS
; i
++)
719 info
->bpts_changed
[i
] = 1;
720 for (i
= 0; i
< MAX_WPTS
; i
++)
721 info
->wpts_changed
[i
] = 1;
723 lwp
->arch_private
= info
;
727 arm_new_fork (struct process_info
*parent
, struct process_info
*child
)
729 struct arch_process_info
*parent_proc_info
= parent
->priv
->arch_private
;
730 struct arch_process_info
*child_proc_info
= child
->priv
->arch_private
;
731 struct lwp_info
*child_lwp
;
732 struct arch_lwp_info
*child_lwp_info
;
735 /* These are allocated by linux_add_process. */
736 gdb_assert (parent
->priv
!= NULL
737 && parent
->priv
->arch_private
!= NULL
);
738 gdb_assert (child
->priv
!= NULL
739 && child
->priv
->arch_private
!= NULL
);
741 /* Linux kernel before 2.6.33 commit
742 72f674d203cd230426437cdcf7dd6f681dad8b0d
743 will inherit hardware debug registers from parent
744 on fork/vfork/clone. Newer Linux kernels create such tasks with
745 zeroed debug registers.
747 GDB core assumes the child inherits the watchpoints/hw
748 breakpoints of the parent, and will remove them all from the
749 forked off process. Copy the debug registers mirrors into the
750 new process so that all breakpoints and watchpoints can be
751 removed together. The debug registers mirror will become zeroed
752 in the end before detaching the forked off process, thus making
753 this compatible with older Linux kernels too. */
755 *child_proc_info
= *parent_proc_info
;
757 /* Mark all the hardware breakpoints and watchpoints as changed to
758 make sure that the registers will be updated. */
759 child_lwp
= find_lwp_pid (ptid_of (child
));
760 child_lwp_info
= child_lwp
->arch_private
;
761 for (i
= 0; i
< MAX_BPTS
; i
++)
762 child_lwp_info
->bpts_changed
[i
] = 1;
763 for (i
= 0; i
< MAX_WPTS
; i
++)
764 child_lwp_info
->wpts_changed
[i
] = 1;
767 /* Called when resuming a thread.
768 If the debug regs have changed, update the thread's copies. */
770 arm_prepare_to_resume (struct lwp_info
*lwp
)
772 struct thread_info
*thread
= get_lwp_thread (lwp
);
773 int pid
= lwpid_of (thread
);
774 struct process_info
*proc
= find_process_pid (pid_of (thread
));
775 struct arch_process_info
*proc_info
= proc
->priv
->arch_private
;
776 struct arch_lwp_info
*lwp_info
= lwp
->arch_private
;
779 for (i
= 0; i
< arm_linux_get_hw_breakpoint_count (); i
++)
780 if (lwp_info
->bpts_changed
[i
])
784 if (arm_hwbp_control_is_enabled (proc_info
->bpts
[i
].control
))
785 if (ptrace (PTRACE_SETHBPREGS
, pid
,
786 (PTRACE_TYPE_ARG3
) ((i
<< 1) + 1),
787 &proc_info
->bpts
[i
].address
) < 0)
788 perror_with_name ("Unexpected error setting breakpoint address");
790 if (arm_hwbp_control_is_initialized (proc_info
->bpts
[i
].control
))
791 if (ptrace (PTRACE_SETHBPREGS
, pid
,
792 (PTRACE_TYPE_ARG3
) ((i
<< 1) + 2),
793 &proc_info
->bpts
[i
].control
) < 0)
794 perror_with_name ("Unexpected error setting breakpoint");
796 lwp_info
->bpts_changed
[i
] = 0;
799 for (i
= 0; i
< arm_linux_get_hw_watchpoint_count (); i
++)
800 if (lwp_info
->wpts_changed
[i
])
804 if (arm_hwbp_control_is_enabled (proc_info
->wpts
[i
].control
))
805 if (ptrace (PTRACE_SETHBPREGS
, pid
,
806 (PTRACE_TYPE_ARG3
) -((i
<< 1) + 1),
807 &proc_info
->wpts
[i
].address
) < 0)
808 perror_with_name ("Unexpected error setting watchpoint address");
810 if (arm_hwbp_control_is_initialized (proc_info
->wpts
[i
].control
))
811 if (ptrace (PTRACE_SETHBPREGS
, pid
,
812 (PTRACE_TYPE_ARG3
) -((i
<< 1) + 2),
813 &proc_info
->wpts
[i
].control
) < 0)
814 perror_with_name ("Unexpected error setting watchpoint");
816 lwp_info
->wpts_changed
[i
] = 0;
822 arm_get_hwcap (unsigned long *valp
)
824 unsigned char *data
= alloca (8);
827 while ((*the_target
->read_auxv
) (offset
, data
, 8) == 8)
829 unsigned int *data_p
= (unsigned int *)data
;
830 if (data_p
[0] == AT_HWCAP
)
843 static const struct target_desc
*
844 arm_read_description (void)
846 int pid
= lwpid_of (current_thread
);
848 /* Query hardware watchpoint/breakpoint capabilities. */
849 arm_linux_init_hwbp_cap (pid
);
852 if (arm_get_hwcap (&arm_hwcap
) == 0)
855 if (arm_hwcap
& HWCAP_IWMMXT
)
856 return tdesc_arm_with_iwmmxt
;
858 if (arm_hwcap
& HWCAP_VFP
)
860 const struct target_desc
*result
;
863 /* NEON implies either no VFP, or VFPv3-D32. We only support
865 if (arm_hwcap
& HWCAP_NEON
)
866 result
= tdesc_arm_with_neon
;
867 else if ((arm_hwcap
& (HWCAP_VFPv3
| HWCAP_VFPv3D16
)) == HWCAP_VFPv3
)
868 result
= tdesc_arm_with_vfpv3
;
870 result
= tdesc_arm_with_vfpv2
;
872 /* Now make sure that the kernel supports reading these
873 registers. Support was added in 2.6.30. */
875 buf
= xmalloc (32 * 8 + 4);
876 if (ptrace (PTRACE_GETVFPREGS
, pid
, 0, buf
) < 0
887 /* The default configuration uses legacy FPA registers, probably
893 arm_arch_setup (void)
895 current_process ()->tdesc
= arm_read_description ();
898 static struct regset_info arm_regsets
[] = {
899 { PTRACE_GETREGS
, PTRACE_SETREGS
, 0, 18 * 4,
901 arm_fill_gregset
, arm_store_gregset
},
902 { PTRACE_GETWMMXREGS
, PTRACE_SETWMMXREGS
, 0, 16 * 8 + 6 * 4,
904 arm_fill_wmmxregset
, arm_store_wmmxregset
},
905 { PTRACE_GETVFPREGS
, PTRACE_SETVFPREGS
, 0, 32 * 8 + 4,
907 arm_fill_vfpregset
, arm_store_vfpregset
},
908 { 0, 0, 0, -1, -1, NULL
, NULL
}
911 static struct regsets_info arm_regsets_info
=
913 arm_regsets
, /* regsets */
915 NULL
, /* disabled_regsets */
918 static struct usrregs_info arm_usrregs_info
=
924 static struct regs_info regs_info
=
926 NULL
, /* regset_bitmap */
931 static const struct regs_info
*
937 struct linux_target_ops the_low_target
= {
940 arm_cannot_fetch_register
,
941 arm_cannot_store_register
,
942 NULL
, /* fetch_register */
946 /* Define an ARM-mode breakpoint; we only set breakpoints in the C
947 library, which is most likely to be ARM. If the kernel supports
948 clone events, we will never insert a breakpoint, so even a Thumb
949 C library will work; so will mixing EABI/non-EABI gdbserver and
952 (const unsigned char *) &arm_breakpoint
,
954 (const unsigned char *) &arm_eabi_breakpoint
,
960 arm_supports_z_point_type
,
963 arm_stopped_by_watchpoint
,
964 arm_stopped_data_address
,
965 NULL
, /* collect_ptrace_register */
966 NULL
, /* supply_ptrace_register */
967 NULL
, /* siginfo_fixup */
971 arm_prepare_to_resume
,
975 initialize_low_arch (void)
977 /* Initialize the Linux target descriptions. */
978 init_registers_arm ();
979 init_registers_arm_with_iwmmxt ();
980 init_registers_arm_with_vfpv2 ();
981 init_registers_arm_with_vfpv3 ();
982 init_registers_arm_with_neon ();
984 initialize_regsets_info (&arm_regsets_info
);