Remove BR2_DEPRECATED
[buildroot-gz.git] / package / gdb / 7.9.1 / 0004-xtensa-implement-NPTL-helpers.patch
blobe7bc74ea53a92ada6cb4ebdf92896f9e4f804b12
1 From d4eb69fc4b50f9a0babd70b28d0601b40f31bd0f Mon Sep 17 00:00:00 2001
2 From: Max Filippov <jcmvbkbc@gmail.com>
3 Date: Thu, 2 Jul 2015 15:10:58 +0300
4 Subject: [PATCH] xtensa: implement NPTL helpers
6 These changes allow debugging multithreaded NPTL xtensa applications.
8 2015-08-20 Max Filippov <jcmvbkbc@gmail.com>
9 gdb/gdbserver/
10 * configure.srv (xtensa*-*-linux*): Add srv_linux_thread_db=yes.
11 * linux-xtensa-low.c (arch/xtensa.h gdb_proc_service.h): New
12 #includes.
13 (ps_get_thread_area): New function.
15 2015-08-20 Max Filippov <jcmvbkbc@gmail.com>
16 gdb/
17 * arch/xtensa.h: New file.
18 * xtensa-linux-nat.c (gdb_proc_service.h): New #include.
19 (ps_get_thread_area): New function.
20 * xtensa-linux-tdep.c (xtensa_linux_init_abi): Add call to
21 set_gdbarch_fetch_tls_load_module_address to enable TLS support.
22 * xtensa-tdep.c (osabi.h): New #include.
23 (xtensa_gdbarch_init): Call gdbarch_init_osabi to register
24 xtensa-specific hooks.
25 * xtensa-tdep.h (struct xtensa_elf_gregset_t): Add threadptr
26 member and move the structure to arch/xtensa.h.
28 Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
29 ---
30 Backported from: 40045d91812b25c88c8275b8c08d27c234b68ba8
31 Changes to ChangeLog files are dropped.
33 gdb/arch/xtensa.h | 46 ++++++++++++++++++++++++++++++++++++++++
34 gdb/gdbserver/configure.srv | 1 +
35 gdb/gdbserver/linux-xtensa-low.c | 21 ++++++++++++++++++
36 gdb/xtensa-linux-nat.c | 22 ++++++++++++++++++
37 gdb/xtensa-linux-tdep.c | 4 ++++
38 gdb/xtensa-tdep.c | 4 ++++
39 gdb/xtensa-tdep.h | 24 ++------------------
40 7 files changed, 100 insertions(+), 22 deletions(-)
41 create mode 100644 gdb/arch/xtensa.h
43 diff --git a/gdb/arch/xtensa.h b/gdb/arch/xtensa.h
44 new file mode 100644
45 index 0000000..fe96584
46 --- /dev/null
47 +++ b/gdb/arch/xtensa.h
48 @@ -0,0 +1,46 @@
49 +/* Common Target-dependent code for the Xtensa port of GDB, the GNU debugger.
51 + Copyright (C) 2003-2015 Free Software Foundation, Inc.
53 + This file is part of GDB.
55 + This program is free software; you can redistribute it and/or modify
56 + it under the terms of the GNU General Public License as published by
57 + the Free Software Foundation; either version 3 of the License, or
58 + (at your option) any later version.
60 + This program is distributed in the hope that it will be useful,
61 + but WITHOUT ANY WARRANTY; without even the implied warranty of
62 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63 + GNU General Public License for more details.
65 + You should have received a copy of the GNU General Public License
66 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
68 +#ifndef XTENSA_H
69 +#define XTENSA_H
71 +/* Xtensa ELF core file register set representation ('.reg' section).
72 + Copied from target-side ELF header <xtensa/elf.h>. */
74 +typedef uint32_t xtensa_elf_greg_t;
76 +typedef struct
78 + xtensa_elf_greg_t pc;
79 + xtensa_elf_greg_t ps;
80 + xtensa_elf_greg_t lbeg;
81 + xtensa_elf_greg_t lend;
82 + xtensa_elf_greg_t lcount;
83 + xtensa_elf_greg_t sar;
84 + xtensa_elf_greg_t windowstart;
85 + xtensa_elf_greg_t windowbase;
86 + xtensa_elf_greg_t threadptr;
87 + xtensa_elf_greg_t reserved[7+48];
88 + xtensa_elf_greg_t ar[64];
89 +} xtensa_elf_gregset_t;
91 +#define XTENSA_ELF_NGREG (sizeof (xtensa_elf_gregset_t) \
92 + / sizeof (xtensa_elf_greg_t))
94 +#endif
95 diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv
96 index 0b18d1d..320c26a 100644
97 --- a/gdb/gdbserver/configure.srv
98 +++ b/gdb/gdbserver/configure.srv
99 @@ -352,6 +352,7 @@ case "${target}" in
100 xtensa*-*-linux*) srv_regobj=reg-xtensa.o
101 srv_tgtobj="$srv_linux_obj linux-xtensa-low.o"
102 srv_linux_regsets=yes
103 + srv_linux_thread_db=yes
105 tilegx-*-linux*) srv_regobj=reg-tilegx.o
106 srv_regobj="${srv_regobj} reg-tilegx32.o"
107 diff --git a/gdb/gdbserver/linux-xtensa-low.c b/gdb/gdbserver/linux-xtensa-low.c
108 index 4daccee..debe467 100644
109 --- a/gdb/gdbserver/linux-xtensa-low.c
110 +++ b/gdb/gdbserver/linux-xtensa-low.c
111 @@ -26,6 +26,8 @@ extern const struct target_desc *tdesc_xtensa;
113 #include <asm/ptrace.h>
114 #include <xtensa-config.h>
115 +#include "arch/xtensa.h"
116 +#include "gdb_proc_service.h"
118 #include "xtensa-xtregs.c"
120 @@ -179,6 +181,25 @@ xtensa_breakpoint_at (CORE_ADDR where)
121 xtensa_breakpoint, xtensa_breakpoint_len) == 0;
124 +/* Called by libthread_db. */
126 +ps_err_e
127 +ps_get_thread_area (const struct ps_prochandle *ph,
128 + lwpid_t lwpid, int idx, void **base)
130 + xtensa_elf_gregset_t regs;
132 + if (ptrace (PTRACE_GETREGS, lwpid, NULL, &regs) != 0)
133 + return PS_ERR;
135 + /* IDX is the bias from the thread pointer to the beginning of the
136 + thread descriptor. It has to be subtracted due to implementation
137 + quirks in libthread_db. */
138 + *base = (void *) ((char *) regs.threadptr - idx);
140 + return PS_OK;
143 static struct regsets_info xtensa_regsets_info =
145 xtensa_regsets, /* regsets */
146 diff --git a/gdb/xtensa-linux-nat.c b/gdb/xtensa-linux-nat.c
147 index 77ad3e0..5538d5b 100644
148 --- a/gdb/xtensa-linux-nat.c
149 +++ b/gdb/xtensa-linux-nat.c
150 @@ -37,6 +37,9 @@
151 #include "gregset.h"
152 #include "xtensa-tdep.h"
154 +/* Defines ps_err_e, struct ps_prochandle. */
155 +#include "gdb_proc_service.h"
157 /* Extended register set depends on hardware configs.
158 Keeping these definitions separately allows to introduce
159 hardware-specific overlays. */
160 @@ -280,6 +283,25 @@ xtensa_linux_store_inferior_registers (struct target_ops *ops,
161 store_xtregs (regcache, regnum);
164 +/* Called by libthread_db. */
166 +ps_err_e
167 +ps_get_thread_area (const struct ps_prochandle *ph,
168 + lwpid_t lwpid, int idx, void **base)
170 + xtensa_elf_gregset_t regs;
172 + if (ptrace (PTRACE_GETREGS, lwpid, NULL, &regs) != 0)
173 + return PS_ERR;
175 + /* IDX is the bias from the thread pointer to the beginning of the
176 + thread descriptor. It has to be subtracted due to implementation
177 + quirks in libthread_db. */
178 + *base = (void *) ((char *) regs.threadptr - idx);
180 + return PS_OK;
183 void _initialize_xtensa_linux_nat (void);
185 void
186 diff --git a/gdb/xtensa-linux-tdep.c b/gdb/xtensa-linux-tdep.c
187 index 61ea9b0..99e0d3e 100644
188 --- a/gdb/xtensa-linux-tdep.c
189 +++ b/gdb/xtensa-linux-tdep.c
190 @@ -106,6 +106,10 @@ xtensa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
191 xtensa_linux_gdb_signal_from_target);
192 set_gdbarch_gdb_signal_to_target (gdbarch,
193 xtensa_linux_gdb_signal_to_target);
195 + /* Enable TLS support. */
196 + set_gdbarch_fetch_tls_load_module_address (gdbarch,
197 + svr4_fetch_objfile_link_map);
200 /* Provide a prototype to silence -Wmissing-prototypes. */
201 diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
202 index 55e7d98..4b693ed 100644
203 --- a/gdb/xtensa-tdep.c
204 +++ b/gdb/xtensa-tdep.c
205 @@ -28,6 +28,7 @@
206 #include "value.h"
207 #include "dis-asm.h"
208 #include "inferior.h"
209 +#include "osabi.h"
210 #include "floatformat.h"
211 #include "regcache.h"
212 #include "reggroups.h"
213 @@ -3273,6 +3274,9 @@ xtensa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
214 set_solib_svr4_fetch_link_map_offsets
215 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
217 + /* Hook in the ABI-specific overrides, if they have been registered. */
218 + gdbarch_init_osabi (info, gdbarch);
220 return gdbarch;
223 diff --git a/gdb/xtensa-tdep.h b/gdb/xtensa-tdep.h
224 index caa2988..5b28cab 100644
225 --- a/gdb/xtensa-tdep.h
226 +++ b/gdb/xtensa-tdep.h
227 @@ -18,6 +18,8 @@
228 along with this program. If not, see <http://www.gnu.org/licenses/>. */
231 +#include "arch/xtensa.h"
233 /* XTENSA_TDEP_VERSION can/should be changed along with XTENSA_CONFIG_VERSION
234 whenever the "tdep" structure changes in an incompatible way. */
236 @@ -81,28 +83,6 @@ typedef enum
237 } xtensa_target_flags_t;
240 -/* Xtensa ELF core file register set representation ('.reg' section).
241 - Copied from target-side ELF header <xtensa/elf.h>. */
243 -typedef uint32_t xtensa_elf_greg_t;
245 -typedef struct
247 - xtensa_elf_greg_t pc;
248 - xtensa_elf_greg_t ps;
249 - xtensa_elf_greg_t lbeg;
250 - xtensa_elf_greg_t lend;
251 - xtensa_elf_greg_t lcount;
252 - xtensa_elf_greg_t sar;
253 - xtensa_elf_greg_t windowstart;
254 - xtensa_elf_greg_t windowbase;
255 - xtensa_elf_greg_t reserved[8+48];
256 - xtensa_elf_greg_t ar[64];
257 -} xtensa_elf_gregset_t;
259 -#define XTENSA_ELF_NGREG (sizeof (xtensa_elf_gregset_t) \
260 - / sizeof (xtensa_elf_greg_t))
262 /* Mask. */
264 typedef struct
266 1.8.1.4