Expect frame-begin annotation.
[deliverable/binutils-gdb.git] / gdb / gdbserver / proc-service.c
CommitLineData
0d62e5e8 1/* libthread_db helper functions for the remote server for GDB.
0050a760 2 Copyright (C) 2002, 2004, 2005, 2006
0d62e5e8
DJ
3 Free Software Foundation, Inc.
4
5 Contributed by MontaVista Software.
6
7 This file is part of GDB.
8
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.
13
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.
18
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
6f0f660e
EZ
21 Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */
0d62e5e8
DJ
23
24#include "server.h"
25
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. */
29
30#include "linux-low.h"
31
0050a760 32#include "gdb_proc_service.h"
0d62e5e8
DJ
33
34typedef struct ps_prochandle *gdb_ps_prochandle_t;
35typedef void *gdb_ps_read_buf_t;
36typedef const void *gdb_ps_write_buf_t;
37typedef size_t gdb_ps_size_t;
38
fd500816
DJ
39#ifdef HAVE_LINUX_REGSETS
40#define HAVE_REGSETS
41#endif
42
43#ifdef HAVE_REGSETS
0d62e5e8
DJ
44static struct regset_info *
45gregset_info(void)
46{
47 int i = 0;
48
49 while (target_regsets[i].size != -1)
50 {
51 if (target_regsets[i].type == GENERAL_REGS)
52 break;
53 i++;
54 }
55
56 return &target_regsets[i];
57}
0d62e5e8
DJ
58#endif
59
60/* Search for the symbol named NAME within the object named OBJ within
61 the target process PH. If the symbol is found the address of the
62 symbol is stored in SYM_ADDR. */
63
64ps_err_e
65ps_pglobal_lookup (gdb_ps_prochandle_t ph, const char *obj,
0050a760 66 const char *name, psaddr_t *sym_addr)
0d62e5e8
DJ
67{
68 CORE_ADDR addr;
69
70 if (look_up_one_symbol (name, &addr) == 0)
71 return PS_NOSYM;
72
0050a760 73 *sym_addr = (psaddr_t) (unsigned long) addr;
0d62e5e8
DJ
74 return PS_OK;
75}
76
77/* Read SIZE bytes from the target process PH at address ADDR and copy
78 them into BUF. */
79
80ps_err_e
0050a760 81ps_pdread (gdb_ps_prochandle_t ph, psaddr_t addr,
0d62e5e8
DJ
82 gdb_ps_read_buf_t buf, gdb_ps_size_t size)
83{
0050a760 84 read_inferior_memory ((unsigned long) addr, buf, size);
0d62e5e8
DJ
85 return PS_OK;
86}
87
88/* Write SIZE bytes from BUF into the target process PH at address ADDR. */
89
90ps_err_e
0050a760 91ps_pdwrite (gdb_ps_prochandle_t ph, psaddr_t addr,
0d62e5e8
DJ
92 gdb_ps_write_buf_t buf, gdb_ps_size_t size)
93{
0050a760 94 return write_inferior_memory ((unsigned long) addr, buf, size);
0d62e5e8
DJ
95}
96
97/* Get the general registers of LWP LWPID within the target process PH
98 and store them in GREGSET. */
99
100ps_err_e
101ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
102{
fd500816 103#ifdef HAVE_REGSETS
8643e2ad 104 struct process_info *process;
0d62e5e8 105 struct thread_info *reg_inferior, *save_inferior;
0d62e5e8 106
8643e2ad
DJ
107 process = (struct process_info *) find_inferior_id (&all_processes,
108 lwpid);
109 if (process == NULL)
0d62e5e8
DJ
110 return PS_ERR;
111
8643e2ad 112 reg_inferior = get_process_thread (process);
0d62e5e8
DJ
113 save_inferior = current_inferior;
114 current_inferior = reg_inferior;
115
fd500816
DJ
116 the_target->fetch_registers (0);
117 gregset_info()->fill_function (gregset);
0d62e5e8
DJ
118
119 current_inferior = save_inferior;
120 return PS_OK;
fd500816 121#else
0d62e5e8 122 return PS_ERR;
fd500816 123#endif
0d62e5e8
DJ
124}
125
126/* Set the general registers of LWP LWPID within the target process PH
127 from GREGSET. */
128
129ps_err_e
130ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prgregset_t gregset)
131{
fd500816 132 /* Unneeded. */
0d62e5e8
DJ
133 return PS_ERR;
134}
135
136/* Get the floating-point registers of LWP LWPID within the target
137 process PH and store them in FPREGSET. */
138
139ps_err_e
0050a760 140ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, void *fpregset)
0d62e5e8 141{
fd500816 142 /* Unneeded. */
0d62e5e8
DJ
143 return PS_ERR;
144}
145
146/* Set the floating-point registers of LWP LWPID within the target
147 process PH from FPREGSET. */
148
149ps_err_e
0050a760 150ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, void *fpregset)
0d62e5e8 151{
fd500816 152 /* Unneeded. */
0d62e5e8
DJ
153 return PS_ERR;
154}
155
156/* Return overall process id of the target PH. Special for GNU/Linux
157 -- not used on Solaris. */
158
159pid_t
160ps_getpid (gdb_ps_prochandle_t ph)
161{
162 return ph->pid;
163}
164
165
This page took 0.318718 seconds and 4 git commands to generate.