OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gdb-7.2/] [gdb/] [gdbserver/] [target.h] - Blame information for rev 835

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 330 jeremybenn
/* Target operations for the remote server for GDB.
2
   Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
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 3 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, see <http://www.gnu.org/licenses/>.  */
21
 
22
#ifndef TARGET_H
23
#define TARGET_H
24
 
25
struct emit_ops;
26
 
27
/* Ways to "resume" a thread.  */
28
 
29
enum resume_kind
30
{
31
  /* Thread should continue.  */
32
  resume_continue,
33
 
34
  /* Thread should single-step.  */
35
  resume_step,
36
 
37
  /* Thread should be stopped.  */
38
  resume_stop
39
};
40
 
41
/* This structure describes how to resume a particular thread (or all
42
   threads) based on the client's request.  If thread is -1, then this
43
   entry applies to all threads.  These are passed around as an
44
   array.  */
45
 
46
struct thread_resume
47
{
48
  ptid_t thread;
49
 
50
  /* How to "resume".  */
51
  enum resume_kind kind;
52
 
53
  /* If non-zero, send this signal when we resume, or to stop the
54
     thread.  If stopping a thread, and this is 0, the target should
55
     stop the thread however it best decides to (e.g., SIGSTOP on
56
     linux; SuspendThread on win32).  */
57
  int sig;
58
};
59
 
60
/* Generally, what has the program done?  */
61
enum target_waitkind
62
  {
63
    /* The program has exited.  The exit status is in
64
       value.integer.  */
65
    TARGET_WAITKIND_EXITED,
66
 
67
    /* The program has stopped with a signal.  Which signal is in
68
       value.sig.  */
69
    TARGET_WAITKIND_STOPPED,
70
 
71
    /* The program has terminated with a signal.  Which signal is in
72
       value.sig.  */
73
    TARGET_WAITKIND_SIGNALLED,
74
 
75
    /* The program is letting us know that it dynamically loaded
76
       something.  */
77
    TARGET_WAITKIND_LOADED,
78
 
79
    /* The program has exec'ed a new executable file.  The new file's
80
       pathname is pointed to by value.execd_pathname.  */
81
    TARGET_WAITKIND_EXECD,
82
 
83
    /* Nothing of interest to GDB happened, but we stopped anyway.  */
84
    TARGET_WAITKIND_SPURIOUS,
85
 
86
    /* An event has occurred, but we should wait again.  In this case,
87
       we want to go back to the event loop and wait there for another
88
       event from the inferior.  */
89
    TARGET_WAITKIND_IGNORE
90
  };
91
 
92
struct target_waitstatus
93
  {
94
    enum target_waitkind kind;
95
 
96
    /* Forked child pid, execd pathname, exit status or signal number.  */
97
    union
98
      {
99
        int integer;
100
        enum target_signal sig;
101
        ptid_t related_pid;
102
        char *execd_pathname;
103
      }
104
    value;
105
  };
106
 
107
/* Options that can be passed to target_ops->wait.  */
108
 
109
#define TARGET_WNOHANG 1
110
 
111
struct target_ops
112
{
113
  /* Start a new process.
114
 
115
     PROGRAM is a path to the program to execute.
116
     ARGS is a standard NULL-terminated array of arguments,
117
     to be passed to the inferior as ``argv''.
118
 
119
     Returns the new PID on success, -1 on failure.  Registers the new
120
     process with the process list.  */
121
 
122
  int (*create_inferior) (char *program, char **args);
123
 
124
  /* Attach to a running process.
125
 
126
     PID is the process ID to attach to, specified by the user
127
     or a higher layer.
128
 
129
     Returns -1 if attaching is unsupported, 0 on success, and calls
130
     error() otherwise.  */
131
 
132
  int (*attach) (unsigned long pid);
133
 
134
  /* Kill inferior PID.  Return -1 on failure, and 0 on success.  */
135
 
136
  int (*kill) (int pid);
137
 
138
  /* Detach from inferior PID. Return -1 on failure, and 0 on
139
     success.  */
140
 
141
  int (*detach) (int pid);
142
 
143
  /* The inferior process has died.  Do what is right.  */
144
 
145
  void (*mourn) (struct process_info *proc);
146
 
147
  /* Wait for inferior PID to exit.  */
148
  void (*join) (int pid);
149
 
150
  /* Return 1 iff the thread with process ID PID is alive.  */
151
 
152
  int (*thread_alive) (ptid_t pid);
153
 
154
  /* Resume the inferior process.  */
155
 
156
  void (*resume) (struct thread_resume *resume_info, size_t n);
157
 
158
  /* Wait for the inferior process or thread to change state.  Store
159
     status through argument pointer STATUS.
160
 
161
     PTID = -1 to wait for any pid to do something, PTID(pid,0,0) to
162
     wait for any thread of process pid to do something.  Return ptid
163
     of child, or -1 in case of error; store status through argument
164
     pointer STATUS.  OPTIONS is a bit set of options defined as
165
     TARGET_W* above.  If options contains TARGET_WNOHANG and there's
166
     no child stop to report, return is
167
     null_ptid/TARGET_WAITKIND_IGNORE.  */
168
 
169
  ptid_t (*wait) (ptid_t ptid, struct target_waitstatus *status, int options);
170
 
171
  /* Fetch registers from the inferior process.
172
 
173
     If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO.  */
174
 
175
  void (*fetch_registers) (struct regcache *regcache, int regno);
176
 
177
  /* Store registers to the inferior process.
178
 
179
     If REGNO is -1, store all registers; otherwise, store at least REGNO.  */
180
 
181
  void (*store_registers) (struct regcache *regcache, int regno);
182
 
183
  /* Read memory from the inferior process.  This should generally be
184
     called through read_inferior_memory, which handles breakpoint shadowing.
185
 
186
     Read LEN bytes at MEMADDR into a buffer at MYADDR.
187
 
188
     Returns 0 on success and errno on failure.  */
189
 
190
  int (*read_memory) (CORE_ADDR memaddr, unsigned char *myaddr, int len);
191
 
192
  /* Write memory to the inferior process.  This should generally be
193
     called through write_inferior_memory, which handles breakpoint shadowing.
194
 
195
     Write LEN bytes from the buffer at MYADDR to MEMADDR.
196
 
197
     Returns 0 on success and errno on failure.  */
198
 
199
  int (*write_memory) (CORE_ADDR memaddr, const unsigned char *myaddr,
200
                       int len);
201
 
202
  /* Query GDB for the values of any symbols we're interested in.
203
     This function is called whenever we receive a "qSymbols::"
204
     query, which corresponds to every time more symbols (might)
205
     become available.  NULL if we aren't interested in any
206
     symbols.  */
207
 
208
  void (*look_up_symbols) (void);
209
 
210
  /* Send an interrupt request to the inferior process,
211
     however is appropriate.  */
212
 
213
  void (*request_interrupt) (void);
214
 
215
  /* Read auxiliary vector data from the inferior process.
216
 
217
     Read LEN bytes at OFFSET into a buffer at MYADDR.  */
218
 
219
  int (*read_auxv) (CORE_ADDR offset, unsigned char *myaddr,
220
                    unsigned int len);
221
 
222
  /* Insert and remove a break or watchpoint.
223
     Returns 0 on success, -1 on failure and 1 on unsupported.
224
     The type is coded as follows:
225
       '0' - software-breakpoint
226
       '1' - hardware-breakpoint
227
       '2' - write watchpoint
228
       '3' - read watchpoint
229
       '4' - access watchpoint  */
230
 
231
  int (*insert_point) (char type, CORE_ADDR addr, int len);
232
  int (*remove_point) (char type, CORE_ADDR addr, int len);
233
 
234
  /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise.  */
235
 
236
  int (*stopped_by_watchpoint) (void);
237
 
238
  /* Returns the address associated with the watchpoint that hit, if any;
239
     returns 0 otherwise.  */
240
 
241
  CORE_ADDR (*stopped_data_address) (void);
242
 
243
  /* Reports the text, data offsets of the executable.  This is
244
     needed for uclinux where the executable is relocated during load
245
     time.  */
246
 
247
  int (*read_offsets) (CORE_ADDR *text, CORE_ADDR *data);
248
 
249
  /* Fetch the address associated with a specific thread local storage
250
     area, determined by the specified THREAD, OFFSET, and LOAD_MODULE.
251
     Stores it in *ADDRESS and returns zero on success; otherwise returns
252
     an error code.  A return value of -1 means this system does not
253
     support the operation.  */
254
 
255
  int (*get_tls_address) (struct thread_info *thread, CORE_ADDR offset,
256
                          CORE_ADDR load_module, CORE_ADDR *address);
257
 
258
   /* Read/Write from/to spufs using qXfer packets.  */
259
  int (*qxfer_spu) (const char *annex, unsigned char *readbuf,
260
                    unsigned const char *writebuf, CORE_ADDR offset, int len);
261
 
262
  /* Fill BUF with an hostio error packet representing the last hostio
263
     error.  */
264
  void (*hostio_last_error) (char *buf);
265
 
266
  /* Read/Write OS data using qXfer packets.  */
267
  int (*qxfer_osdata) (const char *annex, unsigned char *readbuf,
268
                       unsigned const char *writebuf, CORE_ADDR offset,
269
                       int len);
270
 
271
  /* Read/Write extra signal info.  */
272
  int (*qxfer_siginfo) (const char *annex, unsigned char *readbuf,
273
                        unsigned const char *writebuf,
274
                        CORE_ADDR offset, int len);
275
 
276
  int (*supports_non_stop) (void);
277
 
278
  /* Enables async target events.  Returns the previous enable
279
     state.  */
280
  int (*async) (int enable);
281
 
282
  /* Switch to non-stop (1) or all-stop (0) mode.  Return 0 on
283
     success, -1 otherwise.  */
284
  int (*start_non_stop) (int);
285
 
286
  /* Returns true if the target supports multi-process debugging.  */
287
  int (*supports_multi_process) (void);
288
 
289
  /* If not NULL, target-specific routine to process monitor command.
290
     Returns 1 if handled, or 0 to perform default processing.  */
291
  int (*handle_monitor_command) (char *);
292
 
293
  /* Returns the core given a thread, or -1 if not known.  */
294
  int (*core_of_thread) (ptid_t);
295
 
296
  /* Target specific qSupported support.  */
297
  void (*process_qsupported) (const char *);
298
 
299
  /* Return 1 if the target supports tracepoints, 0 (or leave the
300
     callback NULL) otherwise.  */
301
  int (*supports_tracepoints) (void);
302
 
303
  /* Read PC from REGCACHE.  */
304
  CORE_ADDR (*read_pc) (struct regcache *regcache);
305
 
306
  /* Write PC to REGCACHE.  */
307
  void (*write_pc) (struct regcache *regcache, CORE_ADDR pc);
308
 
309
  /* Return true if THREAD is known to be stopped now.  */
310
  int (*thread_stopped) (struct thread_info *thread);
311
 
312
  /* Read Thread Information Block address.  */
313
  int (*get_tib_address) (ptid_t ptid, CORE_ADDR *address);
314
 
315
  /* Pause all threads.  If FREEZE, arrange for any resume attempt be
316
     be ignored until an unpause_all call unfreezes threads again.
317
     There can be nested calls to pause_all, so a freeze counter
318
     should be maintained.  */
319
  void (*pause_all) (int freeze);
320
 
321
  /* Unpause all threads.  Threads that hadn't been resumed by the
322
     client should be left stopped.  Basically a pause/unpause call
323
     pair should not end up resuming threads that were stopped before
324
     the pause call.  */
325
  void (*unpause_all) (int unfreeze);
326
 
327
  /* Cancel all pending breakpoints hits in all threads.  */
328
  void (*cancel_breakpoints) (void);
329
 
330
  /* Stabilize all threads.  That is, force them out of jump pads.  */
331
  void (*stabilize_threads) (void);
332
 
333
  /* Install a fast tracepoint jump pad.  TPOINT is the address of the
334
     tracepoint internal object as used by the IPA agent.  TPADDR is
335
     the address of tracepoint.  COLLECTOR is address of the function
336
     the jump pad redirects to.  LOCKADDR is the address of the jump
337
     pad lock object.  ORIG_SIZE is the size in bytes of the
338
     instruction at TPADDR.  JUMP_ENTRY points to the address of the
339
     jump pad entry, and on return holds the address past the end of
340
     the created jump pad. JJUMP_PAD_INSN is a buffer containing a
341
     copy of the instruction at TPADDR.  ADJUST_INSN_ADDR and
342
     ADJUST_INSN_ADDR_END are output parameters that return the
343
     address range where the instruction at TPADDR was relocated
344
     to.  */
345
  int (*install_fast_tracepoint_jump_pad) (CORE_ADDR tpoint, CORE_ADDR tpaddr,
346
                                           CORE_ADDR collector,
347
                                           CORE_ADDR lockaddr,
348
                                           ULONGEST orig_size,
349
                                           CORE_ADDR *jump_entry,
350
                                           unsigned char *jjump_pad_insn,
351
                                           ULONGEST *jjump_pad_insn_size,
352
                                           CORE_ADDR *adjusted_insn_addr,
353
                                           CORE_ADDR *adjusted_insn_addr_end);
354
 
355
  /* Return the bytecode operations vector for the current inferior.
356
     Returns NULL if bytecode compilation is not supported.  */
357
  struct emit_ops *(*emit_ops) (void);
358
};
359
 
360
extern struct target_ops *the_target;
361
 
362
void set_target_ops (struct target_ops *);
363
 
364
#define create_inferior(program, args) \
365
  (*the_target->create_inferior) (program, args)
366
 
367
#define myattach(pid) \
368
  (*the_target->attach) (pid)
369
 
370
#define kill_inferior(pid) \
371
  (*the_target->kill) (pid)
372
 
373
#define detach_inferior(pid) \
374
  (*the_target->detach) (pid)
375
 
376
#define mourn_inferior(PROC) \
377
  (*the_target->mourn) (PROC)
378
 
379
#define mythread_alive(pid) \
380
  (*the_target->thread_alive) (pid)
381
 
382
#define fetch_inferior_registers(regcache, regno)       \
383
  (*the_target->fetch_registers) (regcache, regno)
384
 
385
#define store_inferior_registers(regcache, regno) \
386
  (*the_target->store_registers) (regcache, regno)
387
 
388
#define join_inferior(pid) \
389
  (*the_target->join) (pid)
390
 
391
#define target_supports_non_stop() \
392
  (the_target->supports_non_stop ? (*the_target->supports_non_stop ) () : 0)
393
 
394
#define target_async(enable) \
395
  (the_target->async ? (*the_target->async) (enable) : 0)
396
 
397
#define target_supports_multi_process() \
398
  (the_target->supports_multi_process ? \
399
   (*the_target->supports_multi_process) () : 0)
400
 
401
#define target_process_qsupported(query)                \
402
  do                                                    \
403
    {                                                   \
404
      if (the_target->process_qsupported)               \
405
        the_target->process_qsupported (query);         \
406
    } while (0)
407
 
408
#define target_supports_tracepoints()                   \
409
  (the_target->supports_tracepoints                     \
410
   ? (*the_target->supports_tracepoints) () : 0)
411
 
412
#define target_supports_fast_tracepoints()              \
413
  (the_target->install_fast_tracepoint_jump_pad != NULL)
414
 
415
#define thread_stopped(thread) \
416
  (*the_target->thread_stopped) (thread)
417
 
418
#define pause_all(freeze)                       \
419
  do                                            \
420
    {                                           \
421
      if (the_target->pause_all)                \
422
        (*the_target->pause_all) (freeze);      \
423
    } while (0)
424
 
425
#define unpause_all(unfreeze)                   \
426
  do                                            \
427
    {                                           \
428
      if (the_target->unpause_all)              \
429
        (*the_target->unpause_all) (unfreeze);  \
430
    } while (0)
431
 
432
#define cancel_breakpoints()                    \
433
  do                                            \
434
    {                                           \
435
      if (the_target->cancel_breakpoints)       \
436
        (*the_target->cancel_breakpoints) ();   \
437
    } while (0)
438
 
439
#define stabilize_threads()                     \
440
  do                                            \
441
    {                                           \
442
      if (the_target->stabilize_threads)        \
443
        (*the_target->stabilize_threads) ();    \
444
    } while (0)
445
 
446
#define install_fast_tracepoint_jump_pad(tpoint, tpaddr,                \
447
                                         collector, lockaddr,           \
448
                                         orig_size,                     \
449
                                         jump_entry, jjump_pad_insn,    \
450
                                         jjump_pad_insn_size,           \
451
                                         adjusted_insn_addr,            \
452
                                         adjusted_insn_addr_end)        \
453
  (*the_target->install_fast_tracepoint_jump_pad) (tpoint, tpaddr,      \
454
                                                   collector,lockaddr,  \
455
                                                   orig_size, jump_entry, \
456
                                                   jjump_pad_insn,      \
457
                                                   jjump_pad_insn_size, \
458
                                                   adjusted_insn_addr,  \
459
                                                   adjusted_insn_addr_end)
460
 
461
#define target_emit_ops() \
462
  (the_target->emit_ops ? (*the_target->emit_ops) () : NULL)
463
 
464
/* Start non-stop mode, returns 0 on success, -1 on failure.   */
465
 
466
int start_non_stop (int nonstop);
467
 
468
ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
469
               int connected_wait);
470
 
471
int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len);
472
 
473
int write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
474
                           int len);
475
 
476
void set_desired_inferior (int id);
477
 
478
const char *target_pid_to_str (ptid_t);
479
 
480
const char *target_waitstatus_to_string (const struct target_waitstatus *);
481
 
482
#endif /* TARGET_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.