1 /* Builtin registers, for GDB, the GNU debugger.
3 Copyright 2002 Free Software Foundation, Inc.
5 Contributed by Red Hat.
7 This file is part of GDB.
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.
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.
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. */
25 #include "builtin-regs.h"
27 #include "gdb_string.h"
28 #include "gdb_assert.h"
30 /* Implement builtin register types. Builtin registers have regnum's
31 that live above of the range [0 .. NUM_REGS + NUM_PSEUDO_REGS)
32 (which is controlled by the target). The target should never see a
33 builtin register's regnum value. */
35 /* An array of builtin registers. Always append, never delete. By
36 doing this, the relative regnum (offset from NUM_REGS +
37 NUM_PSEUDO_REGS) assigned to each builtin register never changes. */
42 struct value
*(*value
) (struct frame_info
* frame
);
45 static struct builtin_reg
*builtin_regs
;
49 add_builtin_reg (const char *name
, struct value
*(*value
) (struct frame_info
* frame
))
52 builtin_regs
= xrealloc (builtin_regs
,
53 nr_builtin_regs
* sizeof (builtin_regs
[0]));
54 builtin_regs
[nr_builtin_regs
- 1].name
= name
;
55 builtin_regs
[nr_builtin_regs
- 1].value
= value
;
59 builtin_reg_map_name_to_regnum (const char *name
, int len
)
62 for (reg
= 0; reg
< nr_builtin_regs
; reg
++)
64 if (len
== strlen (builtin_regs
[reg
].name
)
65 && strncmp (builtin_regs
[reg
].name
, name
, len
) == 0)
66 return NUM_REGS
+ NUM_PSEUDO_REGS
+ reg
;
72 builtin_reg_map_regnum_to_name (int regnum
)
74 int reg
= regnum
- (NUM_REGS
+ NUM_PSEUDO_REGS
);
75 if (reg
< 0 || reg
>= nr_builtin_regs
)
77 return builtin_regs
[reg
].name
;
81 value_of_builtin_reg (int regnum
, struct frame_info
*frame
)
83 int reg
= regnum
- (NUM_REGS
+ NUM_PSEUDO_REGS
);
84 gdb_assert (reg
>= 0 && reg
< nr_builtin_regs
);
85 return builtin_regs
[reg
].value (frame
);
This page took 0.030772 seconds and 4 git commands to generate.