OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [mem-break.c] - Blame information for rev 301

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

Line No. Rev Author Line
1 24 jeremybenn
/* Simulate breakpoints by patching locations in the target system, for GDB.
2
 
3
   Copyright (C) 1990, 1991, 1992, 1993, 1995, 1997, 1998, 1999, 2000, 2002,
4
   2007, 2008 Free Software Foundation, Inc.
5
 
6
   Contributed by Cygnus Support.  Written by John Gilmore.
7
 
8
   This file is part of GDB.
9
 
10
   This program is free software; you can redistribute it and/or modify
11
   it under the terms of the GNU General Public License as published by
12
   the Free Software Foundation; either version 3 of the License, or
13
   (at your option) any later version.
14
 
15
   This program is distributed in the hope that it will be useful,
16
   but WITHOUT ANY WARRANTY; without even the implied warranty of
17
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
   GNU General Public License for more details.
19
 
20
   You should have received a copy of the GNU General Public License
21
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
22
 
23
#include "defs.h"
24
 
25
/* This file is only useful if BREAKPOINT_FROM_PC is set.  If not, we
26
   punt.  */
27
 
28
#include "symtab.h"
29
#include "breakpoint.h"
30
#include "inferior.h"
31
#include "target.h"
32
 
33
 
34
/* Insert a breakpoint on targets that don't have any better
35
   breakpoint support.  We read the contents of the target location
36
   and stash it, then overwrite it with a breakpoint instruction.
37
   BP_TGT->placed_address is the target location in the target
38
   machine.  BP_TGT->shadow_contents is some memory allocated for
39
   saving the target contents.  It is guaranteed by the caller to be
40
   long enough to save BREAKPOINT_LEN bytes (this is accomplished via
41
   BREAKPOINT_MAX).  */
42
 
43
int
44
default_memory_insert_breakpoint (struct gdbarch *gdbarch,
45
                                  struct bp_target_info *bp_tgt)
46
{
47
  int val;
48
  const unsigned char *bp;
49
  int bplen;
50
 
51
  /* Determine appropriate breakpoint contents and size for this address.  */
52
  bp = gdbarch_breakpoint_from_pc
53
       (gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size);
54
  if (bp == NULL)
55
    error (_("Software breakpoints not implemented for this target."));
56
 
57
  /* Save the memory contents.  */
58
  bp_tgt->shadow_len = bp_tgt->placed_size;
59
  val = target_read_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
60
                            bp_tgt->placed_size);
61
 
62
  /* Write the breakpoint.  */
63
  if (val == 0)
64
    val = target_write_memory (bp_tgt->placed_address, bp,
65
                               bp_tgt->placed_size);
66
 
67
  return val;
68
}
69
 
70
 
71
int
72
default_memory_remove_breakpoint (struct gdbarch *gdbarch,
73
                                  struct bp_target_info *bp_tgt)
74
{
75
  return target_write_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
76
                              bp_tgt->placed_size);
77
}
78
 
79
 
80
int
81
memory_insert_breakpoint (struct bp_target_info *bp_tgt)
82
{
83
  return gdbarch_memory_insert_breakpoint (current_gdbarch, bp_tgt);
84
}
85
 
86
int
87
memory_remove_breakpoint (struct bp_target_info *bp_tgt)
88
{
89
  return gdbarch_memory_remove_breakpoint (current_gdbarch, bp_tgt);
90
}

powered by: WebSVN 2.1.0

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