1 /* libthread_db helper functions for the remote server for GDB.
2 Copyright (C) 2002-2013 Free Software Foundation, Inc.
4 Contributed by MontaVista Software.
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 3 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, see <http://www.gnu.org/licenses/>. */
23 /* This file is currently tied to GNU/Linux. It should scale well to
24 another libthread_db implementation, with the approriate gdbserver
25 hooks, but for now this means we can use GNU/Linux's target data. */
27 #include "linux-low.h"
29 #include "gdb_proc_service.h"
31 typedef struct ps_prochandle
*gdb_ps_prochandle_t
;
32 typedef void *gdb_ps_read_buf_t
;
33 typedef const void *gdb_ps_write_buf_t
;
34 typedef size_t gdb_ps_size_t
;
36 #ifdef HAVE_LINUX_REGSETS
41 static struct regset_info
*
46 while (target_regsets
[i
].size
!= -1)
48 if (target_regsets
[i
].type
== GENERAL_REGS
)
53 return &target_regsets
[i
];
57 /* Search for the symbol named NAME within the object named OBJ within
58 the target process PH. If the symbol is found the address of the
59 symbol is stored in SYM_ADDR. */
62 ps_pglobal_lookup (gdb_ps_prochandle_t ph
, const char *obj
,
63 const char *name
, psaddr_t
*sym_addr
)
67 if (thread_db_look_up_one_symbol (name
, &addr
) == 0)
70 *sym_addr
= (psaddr_t
) (unsigned long) addr
;
74 /* Read SIZE bytes from the target process PH at address ADDR and copy
78 ps_pdread (gdb_ps_prochandle_t ph
, psaddr_t addr
,
79 gdb_ps_read_buf_t buf
, gdb_ps_size_t size
)
81 read_inferior_memory ((unsigned long) addr
, buf
, size
);
85 /* Write SIZE bytes from BUF into the target process PH at address ADDR. */
88 ps_pdwrite (gdb_ps_prochandle_t ph
, psaddr_t addr
,
89 gdb_ps_write_buf_t buf
, gdb_ps_size_t size
)
91 return write_inferior_memory ((unsigned long) addr
, buf
, size
);
94 /* Get the general registers of LWP LWPID within the target process PH
95 and store them in GREGSET. */
98 ps_lgetregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
, prgregset_t gregset
)
101 struct lwp_info
*lwp
;
102 struct thread_info
*reg_inferior
, *save_inferior
;
103 struct regcache
*regcache
;
105 lwp
= find_lwp_pid (pid_to_ptid (lwpid
));
109 reg_inferior
= get_lwp_thread (lwp
);
110 save_inferior
= current_inferior
;
111 current_inferior
= reg_inferior
;
112 regcache
= get_thread_regcache (current_inferior
, 1);
113 gregset_info ()->fill_function (regcache
, gregset
);
115 current_inferior
= save_inferior
;
122 /* Set the general registers of LWP LWPID within the target process PH
126 ps_lsetregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
, const prgregset_t gregset
)
132 /* Get the floating-point registers of LWP LWPID within the target
133 process PH and store them in FPREGSET. */
136 ps_lgetfpregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
, void *fpregset
)
142 /* Set the floating-point registers of LWP LWPID within the target
143 process PH from FPREGSET. */
146 ps_lsetfpregs (gdb_ps_prochandle_t ph
, lwpid_t lwpid
, void *fpregset
)
152 /* Return overall process id of the target PH. Special for GNU/Linux
153 -- not used on Solaris. */
156 ps_getpid (gdb_ps_prochandle_t ph
)
158 return pid_of (get_thread_lwp (current_inferior
));
This page took 0.032776 seconds and 4 git commands to generate.