xref: /netbsd-src/external/gpl3/gdb/dist/gdbsupport/common-regcache.cc (revision 5ba1f45f2a09259cc846f20c7c5501604d633c90)
18dffb485Schristos /* Cache and manage the values of registers for GDB, the GNU debugger.
28dffb485Schristos 
3*5ba1f45fSchristos    Copyright (C) 2015-2024 Free Software Foundation, Inc.
48dffb485Schristos 
58dffb485Schristos    This file is part of GDB.
68dffb485Schristos 
78dffb485Schristos    This program is free software; you can redistribute it and/or modify
88dffb485Schristos    it under the terms of the GNU General Public License as published by
98dffb485Schristos    the Free Software Foundation; either version 3 of the License, or
108dffb485Schristos    (at your option) any later version.
118dffb485Schristos 
128dffb485Schristos    This program is distributed in the hope that it will be useful,
138dffb485Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
148dffb485Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
158dffb485Schristos    GNU General Public License for more details.
168dffb485Schristos 
178dffb485Schristos    You should have received a copy of the GNU General Public License
188dffb485Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
198dffb485Schristos 
208dffb485Schristos #include "common-regcache.h"
218dffb485Schristos 
228dffb485Schristos /* Return the register's value or throw if it's not available.  */
238dffb485Schristos 
248dffb485Schristos ULONGEST
25*5ba1f45fSchristos regcache_raw_get_unsigned (reg_buffer_common *regcache, int regnum)
268dffb485Schristos {
278dffb485Schristos   ULONGEST value;
288dffb485Schristos   enum register_status status;
298dffb485Schristos 
308dffb485Schristos   status = regcache_raw_read_unsigned (regcache, regnum, &value);
318dffb485Schristos   if (status == REG_UNAVAILABLE)
328dffb485Schristos     throw_error (NOT_AVAILABLE_ERROR,
338dffb485Schristos 		 _("Register %d is not available"), regnum);
348dffb485Schristos   return value;
358dffb485Schristos }
36