1 /* GNU/Linux/ARM specific low level interface, for the remote server for GDB.
2 Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
24 #include "linux-low.h"
26 #include <sys/ptrace.h>
28 #include "gdb_proc_service.h"
30 #ifndef PTRACE_GET_THREAD_AREA
31 #define PTRACE_GET_THREAD_AREA 22
38 #define arm_num_regs 26
40 static int arm_regmap
[] = {
41 0, 4, 8, 12, 16, 20, 24, 28,
42 32, 36, 40, 44, 48, 52, 56, 60,
43 -1, -1, -1, -1, -1, -1, -1, -1, -1,
48 arm_cannot_store_register (int regno
)
50 return (regno
>= arm_num_regs
);
54 arm_cannot_fetch_register (int regno
)
56 return (regno
>= arm_num_regs
);
59 extern int debug_threads
;
65 collect_register_by_name ("pc", &pc
);
67 fprintf (stderr
, "stop pc is %08lx\n", pc
);
72 arm_set_pc (CORE_ADDR pc
)
74 unsigned long newpc
= pc
;
75 supply_register_by_name ("pc", &newpc
);
78 /* Correct in either endianness. We do not support Thumb yet. */
79 static const unsigned long arm_breakpoint
= 0xef9f0001;
80 #define arm_breakpoint_len 4
82 /* For new EABI binaries. We recognize it regardless of which ABI
83 is used for gdbserver, so single threaded debugging should work
84 OK, but for multi-threaded debugging we only insert the current
85 ABI's breakpoint instruction. For now at least. */
86 static const unsigned long arm_eabi_breakpoint
= 0xe7f001f0;
89 arm_breakpoint_at (CORE_ADDR where
)
93 (*the_target
->read_memory
) (where
, (unsigned char *) &insn
, 4);
94 if (insn
== arm_breakpoint
)
97 if (insn
== arm_eabi_breakpoint
)
100 /* If necessary, recognize more trap instructions here. GDB only uses the
106 /* We only place breakpoints in empty marker functions, and thread locking
107 is outside of the function. So rather than importing software single-step,
108 we can just run until exit. */
113 collect_register_by_name ("lr", &pc
);
117 /* Fetch the thread-local storage pointer for libthread_db. */
120 ps_get_thread_area (const struct ps_prochandle
*ph
,
121 lwpid_t lwpid
, int idx
, void **base
)
123 if (ptrace (PTRACE_GET_THREAD_AREA
, lwpid
, NULL
, base
) != 0)
126 /* IDX is the bias from the thread pointer to the beginning of the
127 thread descriptor. It has to be subtracted due to implementation
128 quirks in libthread_db. */
129 *base
= (void *) ((char *)*base
- idx
);
134 struct linux_target_ops the_low_target
= {
137 arm_cannot_fetch_register
,
138 arm_cannot_store_register
,
142 (const unsigned char *) &arm_breakpoint
,
144 (const unsigned char *) &arm_eabi_breakpoint
,