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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [std-regs.c] - Blame information for rev 826

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

Line No. Rev Author Line
1 227 jeremybenn
/* Builtin frame register, for GDB, the GNU debugger.
2
 
3
   Copyright (C) 2002, 2005, 2007, 2008, 2009, 2010
4
   Free Software Foundation, Inc.
5
 
6
   Contributed by Red Hat.
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
#include "user-regs.h"
25
#include "frame.h"
26
#include "gdbtypes.h"
27
#include "value.h"
28
#include "gdb_string.h"
29
 
30
 
31
static struct value *
32
value_of_builtin_frame_fp_reg (struct frame_info *frame, const void *baton)
33
{
34
  struct gdbarch *gdbarch = get_frame_arch (frame);
35
  if (gdbarch_deprecated_fp_regnum (gdbarch) >= 0)
36
    /* NOTE: cagney/2003-04-24: Since the mere presence of "fp" in the
37
       register name table overrides this built-in $fp register, there
38
       is no real reason for this gdbarch_deprecated_fp_regnum trickery here.
39
       An architecture wanting to implement "$fp" as alias for a raw
40
       register can do so by adding "fp" to register name table (mind
41
       you, doing this is probably a dangerous thing).  */
42
    return value_of_register (gdbarch_deprecated_fp_regnum (gdbarch),
43
                              frame);
44
  else
45
    {
46
      struct type *data_ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
47
      struct value *val = allocate_value (data_ptr_type);
48
      gdb_byte *buf = value_contents_raw (val);
49
      if (frame == NULL)
50
        memset (buf, 0, TYPE_LENGTH (value_type (val)));
51
      else
52
        gdbarch_address_to_pointer (gdbarch, data_ptr_type,
53
                                    buf, get_frame_base_address (frame));
54
      return val;
55
    }
56
}
57
 
58
static struct value *
59
value_of_builtin_frame_pc_reg (struct frame_info *frame, const void *baton)
60
{
61
  struct gdbarch *gdbarch = get_frame_arch (frame);
62
  if (gdbarch_pc_regnum (gdbarch) >= 0)
63
    return value_of_register (gdbarch_pc_regnum (gdbarch), frame);
64
  else
65
    {
66
      struct type *func_ptr_type = builtin_type (gdbarch)->builtin_func_ptr;
67
      struct value *val = allocate_value (func_ptr_type);
68
      gdb_byte *buf = value_contents_raw (val);
69
      if (frame == NULL)
70
        memset (buf, 0, TYPE_LENGTH (value_type (val)));
71
      else
72
        gdbarch_address_to_pointer (gdbarch, func_ptr_type,
73
                                    buf, get_frame_pc (frame));
74
      return val;
75
    }
76
}
77
 
78
static struct value *
79
value_of_builtin_frame_sp_reg (struct frame_info *frame, const void *baton)
80
{
81
  struct gdbarch *gdbarch = get_frame_arch (frame);
82
  if (gdbarch_sp_regnum (gdbarch) >= 0)
83
    return value_of_register (gdbarch_sp_regnum (gdbarch), frame);
84
  error (_("Standard register ``$sp'' is not available for this target"));
85
}
86
 
87
static struct value *
88
value_of_builtin_frame_ps_reg (struct frame_info *frame, const void *baton)
89
{
90
  struct gdbarch *gdbarch = get_frame_arch (frame);
91
  if (gdbarch_ps_regnum (gdbarch) >= 0)
92
    return value_of_register (gdbarch_ps_regnum (gdbarch), frame);
93
  error (_("Standard register ``$ps'' is not available for this target"));
94
}
95
 
96
extern initialize_file_ftype _initialize_frame_reg; /* -Wmissing-prototypes */
97
 
98
void
99
_initialize_frame_reg (void)
100
{
101
  /* Frame based $fp, $pc, $sp and $ps.  These only come into play
102
     when the target does not define its own version of these
103
     registers.  */
104
  user_reg_add_builtin ("fp", value_of_builtin_frame_fp_reg, NULL);
105
  user_reg_add_builtin ("pc", value_of_builtin_frame_pc_reg, NULL);
106
  user_reg_add_builtin ("sp", value_of_builtin_frame_sp_reg, NULL);
107
  user_reg_add_builtin ("ps", value_of_builtin_frame_ps_reg, NULL);
108
}

powered by: WebSVN 2.1.0

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