1 /* libthread_db helper functions for the remote server for GDB.
3 Free Software Foundation, Inc.
5 Contributed by MontaVista Software.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
26 /* This file is currently tied to GNU/Linux. It should scale well to
27 another libthread_db implementation, with the approriate gdbserver
28 hooks, but for now this means we can use GNU/Linux's target data. */
30 #include "linux-low.h"
32 /* Correct for all GNU/Linux targets (for quite some time). */
33 #define GDB_GREGSET_T elf_gregset_t
34 #define GDB_FPREGSET_T elf_fpregset_t
36 #ifndef HAVE_ELF_FPREGSET_T
37 /* Make sure we have said types. Not all platforms bring in <linux/elf.h>
38 via <sys/procfs.h>. */
39 #ifdef HAVE_LINUX_ELF_H
40 #include <linux/elf.h>
44 #include "../gdb_proc_service.h"
46 typedef struct ps_prochandle
*gdb_ps_prochandle_t
;
47 typedef void *gdb_ps_read_buf_t
;
48 typedef const void *gdb_ps_write_buf_t
;
49 typedef size_t gdb_ps_size_t
;
51 /* FIXME redo this right */
53 #ifndef HAVE_LINUX_REGSETS
54 #error HAVE_LINUX_REGSETS required!
56 static struct regset_info
*
61 while (target_regsets
[i
].size
!= -1)
63 if (target_regsets
[i
].type
== GENERAL_REGS
)
68 return &target_regsets
[i
];
71 static struct regset_info
*
76 while (target_regsets
[i
].size
!= -1)
78 if (target_regsets
[i
].type
== FP_REGS
)
83 return &target_regsets
[i
];
88 /* Search for the symbol named NAME within the object named OBJ within
89 the target process PH. If the symbol is found the address of the
90 symbol is stored in SYM_ADDR. */
93 ps_pglobal_lookup (gdb_ps_prochandle_t ph
, const char *obj
,
94 const char *name
, paddr_t
*sym_addr
)
98 if (look_up_one_symbol (name
, &addr
) == 0)
101 *sym_addr
= (paddr_t
) (unsigned long) addr
;
105 /* Read SIZE bytes from the target process PH at address ADDR and copy
109 ps_pdread (gdb_ps_prochandle_t ph
, paddr_t addr
,
110 gdb_ps_read_buf_t buf
, gdb_ps_size_t size
)
112 read_inferior_memory (addr
, buf
, size
);
116 /* Write SIZE bytes from BUF into the target process PH at address ADDR. */
119 ps_pdwrite (gdb_ps_prochandle_t ph
, paddr_t addr
,
120 gdb_ps_write_buf_t buf
, gdb_ps_size_t size
)
122 return write_inferior_memory (addr
, buf
, size
);
125 /* Get the general registers of LWP LWPID within the target process PH
126 and store them in GREGSET. */
129 ps_lgetregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
, prgregset_t gregset
)
132 struct thread_info
*reg_inferior
, *save_inferior
;
135 reg_inferior
= (struct thread_info
*) find_inferior_id (&all_threads
,
137 if (reg_inferior
== NULL
)
140 save_inferior
= current_inferior
;
141 current_inferior
= reg_inferior
;
143 regcache
= new_register_cache ();
144 the_target
->fetch_registers (0, regcache
);
145 gregset_info()->fill_function (gregset
, regcache
);
146 free_register_cache (regcache
);
148 current_inferior
= save_inferior
;
155 /* Set the general registers of LWP LWPID within the target process PH
159 ps_lsetregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
, const prgregset_t gregset
)
162 struct thread_info
*reg_inferior
, *save_inferior
;
165 reg_inferior
= (struct thread_info
*) find_inferior_id (&all_threads
, lwpid
);
166 if (reg_inferior
== NULL
)
169 save_inferior
= current_inferior
;
170 current_inferior
= reg_inferior
;
172 regcache
= new_register_cache ();
173 gregset_info()->store_function (gregset
, regcache
);
174 the_target
->store_registers (0, regcache
);
175 free_register_cache (regcache
);
177 current_inferior
= save_inferior
;
185 /* Get the floating-point registers of LWP LWPID within the target
186 process PH and store them in FPREGSET. */
189 ps_lgetfpregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
,
190 gdb_prfpregset_t
*fpregset
)
193 struct thread_info
*reg_inferior
, *save_inferior
;
196 reg_inferior
= (struct thread_info
*) find_inferior_id (&all_threads
, lwpid
);
197 if (reg_inferior
== NULL
)
200 save_inferior
= current_inferior
;
201 current_inferior
= reg_inferior
;
203 regcache
= new_register_cache ();
204 the_target
->fetch_registers (0, regcache
);
205 fpregset_info()->fill_function (fpregset
, regcache
);
206 free_register_cache (regcache
);
208 current_inferior
= save_inferior
;
216 /* Set the floating-point registers of LWP LWPID within the target
217 process PH from FPREGSET. */
220 ps_lsetfpregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
,
221 const gdb_prfpregset_t
*fpregset
)
224 struct thread_info
*reg_inferior
, *save_inferior
;
227 reg_inferior
= (struct thread_info
*) find_inferior_id (&all_threads
, lwpid
);
228 if (reg_inferior
== NULL
)
231 save_inferior
= current_inferior
;
232 current_inferior
= reg_inferior
;
234 regcache
= new_register_cache ();
235 fpregset_info()->store_function (fpregset
, regcache
);
236 the_target
->store_registers (0, regcache
);
237 free_register_cache (regcache
);
239 current_inferior
= save_inferior
;
247 /* Return overall process id of the target PH. Special for GNU/Linux
248 -- not used on Solaris. */
251 ps_getpid (gdb_ps_prochandle_t ph
)
This page took 0.035561 seconds and 4 git commands to generate.