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