xref: /netbsd-src/external/gpl3/gdb.old/dist/gdbsupport/common-regcache.cc (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
17d62b00eSchristos /* Cache and manage the values of registers for GDB, the GNU debugger.
27d62b00eSchristos 
3*6881a400Schristos    Copyright (C) 2015-2023 Free Software Foundation, Inc.
47d62b00eSchristos 
57d62b00eSchristos    This file is part of GDB.
67d62b00eSchristos 
77d62b00eSchristos    This program is free software; you can redistribute it and/or modify
87d62b00eSchristos    it under the terms of the GNU General Public License as published by
97d62b00eSchristos    the Free Software Foundation; either version 3 of the License, or
107d62b00eSchristos    (at your option) any later version.
117d62b00eSchristos 
127d62b00eSchristos    This program is distributed in the hope that it will be useful,
137d62b00eSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
147d62b00eSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
157d62b00eSchristos    GNU General Public License for more details.
167d62b00eSchristos 
177d62b00eSchristos    You should have received a copy of the GNU General Public License
187d62b00eSchristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
197d62b00eSchristos 
207d62b00eSchristos #include "common-defs.h"
217d62b00eSchristos #include "common-regcache.h"
227d62b00eSchristos 
237d62b00eSchristos /* Return the register's value or throw if it's not available.  */
247d62b00eSchristos 
257d62b00eSchristos ULONGEST
267d62b00eSchristos regcache_raw_get_unsigned (struct regcache *regcache, int regnum)
277d62b00eSchristos {
287d62b00eSchristos   ULONGEST value;
297d62b00eSchristos   enum register_status status;
307d62b00eSchristos 
317d62b00eSchristos   status = regcache_raw_read_unsigned (regcache, regnum, &value);
327d62b00eSchristos   if (status == REG_UNAVAILABLE)
337d62b00eSchristos     throw_error (NOT_AVAILABLE_ERROR,
347d62b00eSchristos 		 _("Register %d is not available"), regnum);
357d62b00eSchristos   return value;
367d62b00eSchristos }
37