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,
3 2006, 2007 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
23 #include "linux-low.h"
25 #include <sys/ptrace.h>
27 #include "gdb_proc_service.h"
29 #ifndef PTRACE_GET_THREAD_AREA
30 #define PTRACE_GET_THREAD_AREA 22
37 #define arm_num_regs 26
39 static int arm_regmap
[] = {
40 0, 4, 8, 12, 16, 20, 24, 28,
41 32, 36, 40, 44, 48, 52, 56, 60,
42 -1, -1, -1, -1, -1, -1, -1, -1, -1,
47 arm_cannot_store_register (int regno
)
49 return (regno
>= arm_num_regs
);
53 arm_cannot_fetch_register (int regno
)
55 return (regno
>= arm_num_regs
);
58 extern int debug_threads
;
64 collect_register_by_name ("pc", &pc
);
66 fprintf (stderr
, "stop pc is %08lx\n", pc
);
71 arm_set_pc (CORE_ADDR pc
)
73 unsigned long newpc
= pc
;
74 supply_register_by_name ("pc", &newpc
);
77 /* Correct in either endianness. We do not support Thumb yet. */
78 static const unsigned long arm_breakpoint
= 0xef9f0001;
79 #define arm_breakpoint_len 4
81 /* For new EABI binaries. We recognize it regardless of which ABI
82 is used for gdbserver, so single threaded debugging should work
83 OK, but for multi-threaded debugging we only insert the current
84 ABI's breakpoint instruction. For now at least. */
85 static const unsigned long arm_eabi_breakpoint
= 0xe7f001f0;
88 arm_breakpoint_at (CORE_ADDR where
)
92 (*the_target
->read_memory
) (where
, (unsigned char *) &insn
, 4);
93 if (insn
== arm_breakpoint
)
96 if (insn
== arm_eabi_breakpoint
)
99 /* If necessary, recognize more trap instructions here. GDB only uses the
105 /* We only place breakpoints in empty marker functions, and thread locking
106 is outside of the function. So rather than importing software single-step,
107 we can just run until exit. */
112 collect_register_by_name ("lr", &pc
);
116 /* Fetch the thread-local storage pointer for libthread_db. */
119 ps_get_thread_area (const struct ps_prochandle
*ph
,
120 lwpid_t lwpid
, int idx
, void **base
)
122 if (ptrace (PTRACE_GET_THREAD_AREA
, lwpid
, NULL
, base
) != 0)
125 /* IDX is the bias from the thread pointer to the beginning of the
126 thread descriptor. It has to be subtracted due to implementation
127 quirks in libthread_db. */
128 *base
= (void *) ((char *)*base
- idx
);
133 struct linux_target_ops the_low_target
= {
136 arm_cannot_fetch_register
,
137 arm_cannot_store_register
,
141 (const unsigned char *) &arm_breakpoint
,
143 (const unsigned char *) &arm_eabi_breakpoint
,