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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [std-regs.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
/* Builtin frame register, for GDB, the GNU debugger.
2
 
3
   Copyright 2002 Free Software Foundation, Inc.
4
 
5
   Contributed by Red Hat.
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
21
   Foundation, Inc., 59 Temple Place - Suite 330,
22
   Boston, MA 02111-1307, USA.  */
23
 
24
#include "defs.h"
25
#include "builtin-regs.h"
26
#include "frame.h"
27
#include "gdbtypes.h"
28
#include "value.h"
29
#include "gdb_string.h"
30
 
31
/* Types that describe the various builtin registers.  */
32
 
33
static struct type *builtin_type_frame_reg;
34
 
35
/* Constructors for those types.  */
36
 
37
static void
38
build_builtin_type_frame_reg (void)
39
{
40
  /* $frame.  */
41
  if (builtin_type_frame_reg == NULL)
42
    {
43
#if 0
44
      struct frame
45
      {
46
        void *base;
47
      };
48
#endif
49
      builtin_type_frame_reg = init_composite_type ("frame", TYPE_CODE_STRUCT);
50
      append_composite_type_field (builtin_type_frame_reg, "base",
51
                                   builtin_type_void_data_ptr);
52
    }
53
}
54
 
55
static struct value *
56
value_of_builtin_frame_reg (struct frame_info *frame)
57
{
58
  struct value *val;
59
  char *buf;
60
  build_builtin_type_frame_reg ();
61
  val = allocate_value (builtin_type_frame_reg);
62
  VALUE_LVAL (val) = not_lval;
63
  buf = VALUE_CONTENTS_RAW (val);
64
  memset (buf, TYPE_LENGTH (VALUE_TYPE (val)), 0);
65
  /* frame.base.  */
66
  if (frame != NULL)
67
    ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf, frame->frame);
68
  buf += TYPE_LENGTH (builtin_type_void_data_ptr);
69
  /* frame.XXX.  */
70
  return val;
71
}
72
 
73
static struct value *
74
value_of_builtin_frame_fp_reg (struct frame_info *frame)
75
{
76
#ifdef FP_REGNUM
77
  if (FP_REGNUM >= 0)
78
    return value_of_register (FP_REGNUM, frame);
79
#endif
80
  {
81
    struct value *val = allocate_value (builtin_type_void_data_ptr);
82
    char *buf = VALUE_CONTENTS_RAW (val);
83
    if (frame == NULL)
84
      memset (buf, TYPE_LENGTH (VALUE_TYPE (val)), 0);
85
    else
86
      ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf, frame->frame);
87
    return val;
88
  }
89
}
90
 
91
static struct value *
92
value_of_builtin_frame_pc_reg (struct frame_info *frame)
93
{
94
#ifdef PC_REGNUM
95
  if (PC_REGNUM >= 0)
96
    return value_of_register (PC_REGNUM, frame);
97
#endif
98
  {
99
    struct value *val = allocate_value (builtin_type_void_data_ptr);
100
    char *buf = VALUE_CONTENTS_RAW (val);
101
    if (frame == NULL)
102
      memset (buf, TYPE_LENGTH (VALUE_TYPE (val)), 0);
103
    else
104
      ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf, frame->pc);
105
    return val;
106
  }
107
}
108
 
109
static struct value *
110
value_of_builtin_frame_sp_reg (struct frame_info *frame)
111
{
112
#ifdef SP_REGNUM
113
  if (SP_REGNUM >= 0)
114
    return value_of_register (SP_REGNUM, frame);
115
#endif
116
  error ("Standard register ``$sp'' is not available for this target");
117
}
118
 
119
static struct value *
120
value_of_builtin_frame_ps_reg (struct frame_info *frame)
121
{
122
#ifdef PS_REGNUM
123
  if (PS_REGNUM >= 0)
124
    return value_of_register (PS_REGNUM, frame);
125
#endif
126
  error ("Standard register ``$ps'' is not available for this target");
127
}
128
 
129
void
130
_initialize_frame_reg (void)
131
{
132
  /* FIXME: cagney/2002-02-08: At present the local builtin types
133
     can't be initialized using _initialize*() or gdbarch.  Due mainly
134
     to non-multi-arch targets, GDB initializes things piece meal and,
135
     as a consequence can leave these types NULL.  */
136
  REGISTER_GDBARCH_SWAP (builtin_type_frame_reg);
137
 
138
  /* Frame based $fp, $pc, $sp and $ps.  These only come into play
139
     when the target does not define its own version of these
140
     registers.  */
141
  add_builtin_reg ("fp", value_of_builtin_frame_fp_reg);
142
  add_builtin_reg ("pc", value_of_builtin_frame_pc_reg);
143
  add_builtin_reg ("sp", value_of_builtin_frame_sp_reg);
144
  add_builtin_reg ("ps", value_of_builtin_frame_ps_reg);
145
 
146
  /* NOTE: cagney/2002-04-05: For moment leave the $frame / $gdbframe
147
     / $gdb.frame disabled.  It isn't yet clear which of the many
148
     options is the best.  */
149
  if (0)
150
    add_builtin_reg ("frame", value_of_builtin_frame_reg);
151
}

powered by: WebSVN 2.1.0

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