From patchwork Tue May 16 11:16:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 20465 Received: (qmail 103203 invoked by alias); 16 May 2017 11:16:35 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 103173 invoked by uid 89); 16 May 2017 11:16:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=Sometimes, longest X-HELO: EUR03-DB5-obe.outbound.protection.outlook.com Received: from mail-eopbgr40064.outbound.protection.outlook.com (HELO EUR03-DB5-obe.outbound.protection.outlook.com) (40.107.4.64) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 16 May 2017 11:16:26 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com (10.160.211.19) by AM3PR08MB0101.eurprd08.prod.outlook.com (10.160.211.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1084.16; Tue, 16 May 2017 11:16:26 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::b823:64c1:afc5:3a08]) by AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::b823:64c1:afc5:3a08%17]) with mapi id 15.01.1084.029; Tue, 16 May 2017 11:16:26 +0000 From: Alan Hayward To: Yao Qi CC: "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (2/4) Date: Tue, 16 May 2017 11:16:25 +0000 Message-ID: References: <3C00280E-37C9-4C0A-9DA6-F3B9DB1A6E8F@arm.com> <86y3v7uf9j.fsf@gmail.com> <806B436F-EFA1-4200-AC54-9036D166C9B9@arm.com> <867f1m8nhm.fsf@gmail.com> In-Reply-To: <867f1m8nhm.fsf@gmail.com> authentication-results: gmail.com; dkim=none (message not signed) header.d=none; gmail.com; dmarc=none action=none header.from=arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM3PR08MB0101; 7:GzPKGYI/nb25s28Fh9qAHJyu1OGh4zVrGiEE3PT4pmBzhmwh17HDcLOMxj0aJq4cKF8vFe1S7Gd9t2YsALxRKN4W3BxZc1om1Pmg0z92xl5+tvdXYmT6YSr265OXieYxV3037CE2xuAb5zZSZkaY9cGn9dY8BR4oaaPcmf1HImR1A0bj0xWKiXRzXt69ODFj1mu2j/LLEI7nh9FKw4IpcDzkgxaHzQQKHV8kAUpVvT0VQxvApSkM9BfQE9fvUuNEDqL5QNVknxIhdXYbNNkLfIHz8iTnkbGf/o5OIm1nDCHKDJ2uo39wUGqpfT+Puv+f8/ApjcG4VTIk3evJH93lKw== x-ms-office365-filtering-correlation-id: 4758a172-5002-4346-3277-08d49c4cfe15 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081)(201702281549075); SRVR:AM3PR08MB0101; nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123558100)(20161123555025)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148); SRVR:AM3PR08MB0101; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0101; x-forefront-prvs: 03094A4065 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39410400002)(39850400002)(39400400002)(39860400002)(39840400002)(39450400003)(24454002)(377424004)(2900100001)(4326008)(305945005)(50986999)(76176999)(39060400002)(3660700001)(54356999)(7736002)(102836003)(1411001)(3280700002)(8676002)(3846002)(81166006)(6116002)(33656002)(2906002)(189998001)(8936002)(82746002)(478600001)(6512007)(54906002)(99286003)(53946003)(53936002)(36756003)(6436002)(83716003)(5660300001)(6486002)(6506006)(229853002)(72206003)(38730400002)(93886004)(110136004)(6246003)(2950100002)(6916009)(25786009)(5250100002)(66066001)(86362001)(53546009)(575784001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0101; H:AM3PR08MB0101.eurprd08.prod.outlook.com; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 16 May 2017 11:16:25.7119 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0101 > On 12 May 2017, at 09:53, Yao Qi wrote: > > Alan Hayward writes: > >> } >> >> +/* Supply register REGNUM, whose contents are stored in signed VAL, to >> + REGCACHE. */ >> + >> +void >> +regcache::raw_supply_signed (int regnum, LONGEST val) > > The unsigned version of this function is also needed, because I see such > pattern also exists, > > store_unsigned_integer (buf, 8, byte_order, sp + offset); > regcache_raw_supply (regcache, AMD64_RSP_REGNUM, buf); > > this leads me thinking we need to use function template to define > functions for both LONGEST and ULONGEST. > > Secondly, this method can be named as raw_supply. > >> +{ >> + enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch); >> + gdb_byte *regbuf; >> + size_t size; >> + >> + gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers); >> + gdb_assert (!m_readonly_p); >> + >> + regbuf = register_buffer (regnum); >> + size = m_descr->sizeof_register[regnum]; >> + >> + store_signed_integer (regbuf, size, byte_order, val); >> + m_register_status[regnum] = REG_VALID; >> +} >> + >> /* Collect register REGNUM from REGCACHE and store its contents in BUF. */ >> >> void >> @@ -1251,6 +1271,23 @@ regcache::raw_collect (int regnum, void *buf) const >> memcpy (buf, regbuf, size); >> } >> >> +/* Collect register REGNUM from REGCACHE and extract its contents into a signed > > This line is too long. > >> + LONGEST. */ >> + >> +LONGEST >> +regcache::raw_collect_signed (int regnum) const > > We can define this method like this, > > template > using LongType = typename std::enable_if<(std::is_same::value > || std::is_same::value), > T>::type; > > template > LongType raw_collect (int regnum) const > { > .... > if (std::is_signed::value) > return extract_signed_integer (regbuf, size, byte_order); > else > return extract_unsigned_integer (regbuf, size, byte_order); > } > >> +{ >> + enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch); >> + const gdb_byte *regbuf; >> + size_t size; >> + >> + gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers); >> + >> + regbuf = register_buffer (regnum); >> + size = m_descr->sizeof_register[regnum]; >> + return extract_signed_integer (regbuf, size, byte_order); >> +} > > If you want, we can add a function template for extract_signed_integer > and extract_unsigned_integer. > > template > LongType > extract_integer (const gdb_byte *addr, int len, enum bfd_endian byte_order) > { > T retval; > > ... > if (std::is_signed::value) > { > ... > } > else > { > ... > } > return retval; > } > > so, the raw_collect above becomes, > > template > LongType raw_collect (int regnum) const > { > .... > return extract_integer (regbuf, size, byte_order); > } > > and raw_read_{signed,unsigned}, cooked_read_{signed,unsigned} can be > merged as function template too. > Added templates for extract_integer and store_integer, raw_supply and raw_collect. Did not add raw_read and cooked_read, as they are out of the scope of this patch. Tested on a --enable-targets=all build using make check with board files unix and native-gdbserver. I do not have a MIPS machine to test on. Ok to commit? Alan. 2017-05-16 Alan Hayward * gdb/defs.h (LongType): New templated type. (extract_integer): New declaration. (extract_signed_integer): Switched to inline. (extract_unsigned_integer): Likewise. (store_integer): New declaration (store_signed_integer): Switched to inline. (store_unsigned_integer): Likewise. * gdb/findvar.c (extract_integer): New function and instantiations. (extract_signed_integer): Removed function. (extract_unsigned_integer): Likewise. (store_integer): New function and instantiations. (store_signed_integer): Removed function. (store_unsigned_integer): Likewise. * mips-fbsd-tdep.c (mips_fbsd_supply_reg): Use templated raw_supply. (mips_fbsd_collect_reg): Use templated raw_collect. * mips-linux-tdep.c (supply_32bit_reg): Use templated raw_supply. (mips64_fill_gregset): Use templated raw_collect. (mips64_fill_fpregset): Use templated raw_supply. * gdb/regcache.c (regcache::raw_supply): New function and instantiations. (LongType regcache::raw_collect): Likewise * gdb/regcache.h (regcache::raw_supply): New declaration. (regcache::raw_collect): Likewise diff --git a/gdb/defs.h b/gdb/defs.h index a0b586f401eca205334e9f237081f4da97c83aa1..45c02f89d9c7a6326a82a6eaaf7d226175e24513 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -627,6 +627,11 @@ enum symbol_needs_kind SYMBOL_NEEDS_FRAME }; +template +using LongType = typename std::enable_if<(std::is_same::value + || std::is_same::value), + T>::type; + /* Dynamic target-system-dependent parameters for GDB. */ #include "gdbarch.h" @@ -637,11 +642,21 @@ enum { MAX_REGISTER_SIZE = 64 }; /* In findvar.c. */ -extern LONGEST extract_signed_integer (const gdb_byte *, int, - enum bfd_endian); +template LongType extract_integer (const gdb_byte *addr, + int len, + enum bfd_endian byte_order); + +inline LONGEST extract_signed_integer (const gdb_byte *addr, int len, + enum bfd_endian byte_order) +{ + return extract_integer (addr, len, byte_order); +} -extern ULONGEST extract_unsigned_integer (const gdb_byte *, int, - enum bfd_endian); +inline ULONGEST extract_unsigned_integer (const gdb_byte *addr, int len, + enum bfd_endian byte_order) +{ + return extract_integer (addr, len, byte_order); +} extern int extract_long_unsigned_integer (const gdb_byte *, int, enum bfd_endian, LONGEST *); @@ -649,11 +664,21 @@ extern int extract_long_unsigned_integer (const gdb_byte *, int, extern CORE_ADDR extract_typed_address (const gdb_byte *buf, struct type *type); -extern void store_signed_integer (gdb_byte *, int, - enum bfd_endian, LONGEST); +template void store_integer (gdb_byte *addr, int len, + enum bfd_endian byte_order, + LongType val); -extern void store_unsigned_integer (gdb_byte *, int, - enum bfd_endian, ULONGEST); +inline void store_signed_integer (gdb_byte *addr, int len, + enum bfd_endian byte_order, LONGEST val) +{ + store_integer (addr, len, byte_order, val); +} + +inline void store_unsigned_integer (gdb_byte *addr, int len, + enum bfd_endian byte_order, ULONGEST val) +{ + store_integer (addr, len, byte_order, val); +} extern void store_typed_address (gdb_byte *buf, struct type *type, CORE_ADDR addr); diff --git a/gdb/findvar.c b/gdb/findvar.c index ed4d5c1266c9de069981b306bc8229ae5fb02350..3bcc98ce3421cb800fc8222535b16ca94ee043da 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -46,70 +46,54 @@ you lose #endif -LONGEST -extract_signed_integer (const gdb_byte *addr, int len, - enum bfd_endian byte_order) +template +LongType +extract_integer (const gdb_byte *addr, int len, enum bfd_endian byte_order) { - LONGEST retval; + T retval; const unsigned char *p; const unsigned char *startaddr = addr; const unsigned char *endaddr = startaddr + len; - if (len > (int) sizeof (LONGEST)) + if (len > (int) sizeof (T)) error (_("\ That operation is not available on integers of more than %d bytes."), - (int) sizeof (LONGEST)); + (int) sizeof (T)); /* Start at the most significant end of the integer, and work towards the least significant. */ if (byte_order == BFD_ENDIAN_BIG) { p = startaddr; - /* Do the sign extension once at the start. */ - retval = ((LONGEST) * p ^ 0x80) - 0x80; - for (++p; p < endaddr; ++p) + if (std::is_signed::value) + { + /* Do the sign extension once at the start. */ + retval = ((LONGEST) * p ^ 0x80) - 0x80; + ++p; + } + for (; p < endaddr; ++p) retval = (retval << 8) | *p; } else { p = endaddr - 1; - /* Do the sign extension once at the start. */ - retval = ((LONGEST) * p ^ 0x80) - 0x80; - for (--p; p >= startaddr; --p) + if (std::is_signed::value) + { + /* Do the sign extension once at the start. */ + retval = ((LONGEST) * p ^ 0x80) - 0x80; + --p; + } + for (; p >= startaddr; --p) retval = (retval << 8) | *p; } return retval; } -ULONGEST -extract_unsigned_integer (const gdb_byte *addr, int len, - enum bfd_endian byte_order) -{ - ULONGEST retval; - const unsigned char *p; - const unsigned char *startaddr = addr; - const unsigned char *endaddr = startaddr + len; +template LongType extract_integer + (const gdb_byte *addr, int len, enum bfd_endian byte_order); - if (len > (int) sizeof (ULONGEST)) - error (_("\ -That operation is not available on integers of more than %d bytes."), - (int) sizeof (ULONGEST)); - - /* Start at the most significant end of the integer, and work towards - the least significant. */ - retval = 0; - if (byte_order == BFD_ENDIAN_BIG) - { - for (p = startaddr; p < endaddr; ++p) - retval = (retval << 8) | *p; - } - else - { - for (p = endaddr - 1; p >= startaddr; --p) - retval = (retval << 8) | *p; - } - return retval; -} +template LongType extract_integer + (const gdb_byte *addr, int len, enum bfd_endian byte_order); /* Sometimes a long long unsigned integer can be extracted as a LONGEST value. This is done so that we can print these values @@ -180,9 +164,10 @@ extract_typed_address (const gdb_byte *buf, struct type *type) /* All 'store' functions accept a host-format integer and store a target-format integer at ADDR which is LEN bytes long. */ +template void -store_signed_integer (gdb_byte *addr, int len, - enum bfd_endian byte_order, LONGEST val) +store_integer (gdb_byte *addr, int len, enum bfd_endian byte_order, + LongType val) { gdb_byte *p; gdb_byte *startaddr = addr; @@ -208,33 +193,12 @@ store_signed_integer (gdb_byte *addr, int len, } } -void -store_unsigned_integer (gdb_byte *addr, int len, - enum bfd_endian byte_order, ULONGEST val) -{ - unsigned char *p; - unsigned char *startaddr = (unsigned char *) addr; - unsigned char *endaddr = startaddr + len; - - /* Start at the least significant end of the integer, and work towards - the most significant. */ - if (byte_order == BFD_ENDIAN_BIG) - { - for (p = endaddr - 1; p >= startaddr; --p) - { - *p = val & 0xff; - val >>= 8; - } - } - else - { - for (p = startaddr; p < endaddr; ++p) - { - *p = val & 0xff; - val >>= 8; - } - } -} +template void store_integer (gdb_byte *addr, int len, + enum bfd_endian byte_order, + LongType val); +template void store_integer (gdb_byte *addr, int len, + enum bfd_endian byte_order, + LongType val); /* Store the address ADDR as a pointer of type TYPE at BUF, in target form. */ diff --git a/gdb/mips-fbsd-tdep.c b/gdb/mips-fbsd-tdep.c index 00fae0ec60ddc9e645d3236efe29f2f9e9ceab5c..1e391bfd16864d9d45f3b6e0de425aa5543515df 100644 --- a/gdb/mips-fbsd-tdep.c +++ b/gdb/mips-fbsd-tdep.c @@ -48,9 +48,9 @@ #define MIPS_FBSD_NUM_FPREGS 34 /* Supply a single register. If the source register size matches the - size the regcache expects, this can use regcache_raw_supply(). If + size the regcache expects, this can use regcache->raw_supply (). If they are different, this copies the source register into a buffer - that can be passed to regcache_raw_supply(). */ + that can be passed to regcache->raw_supply (). */ static void mips_fbsd_supply_reg (struct regcache *regcache, int regnum, const void *addr, @@ -63,20 +63,17 @@ mips_fbsd_supply_reg (struct regcache *regcache, int regnum, const void *addr, else { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - gdb_byte buf[MAX_REGISTER_SIZE]; LONGEST val; - val = extract_signed_integer ((const gdb_byte *) addr, len, byte_order); - store_signed_integer (buf, register_size (gdbarch, regnum), byte_order, - val); - regcache_raw_supply (regcache, regnum, buf); + val = extract_integer ((const gdb_byte *) addr, len, byte_order); + regcache->raw_supply (regnum, val); } } /* Collect a single register. If the destination register size matches the size the regcache expects, this can use - regcache_raw_supply(). If they are different, this fetches the - register via regcache_raw_supply() into a buffer and then copies it + regcache->raw_supply (). If they are different, this fetches the + register via regcache->raw_supply () into a buffer and then copies it into the final destination. */ static void @@ -90,13 +87,8 @@ mips_fbsd_collect_reg (const struct regcache *regcache, int regnum, void *addr, else { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - gdb_byte buf[MAX_REGISTER_SIZE]; - LONGEST val; - - regcache_raw_collect (regcache, regnum, buf); - val = extract_signed_integer (buf, register_size (gdbarch, regnum), - byte_order); - store_signed_integer ((gdb_byte *) addr, len, byte_order, val); + LONGEST val = regcache->raw_collect (regnum); + store_integer ((gdb_byte *) addr, len, byte_order, val); } } diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c index 48a582a16c934abe6e8f87c46a6009649c606d49..bac106ed5e9e5d89285420beb52b33d6ce36265a 100644 --- a/gdb/mips-linux-tdep.c +++ b/gdb/mips-linux-tdep.c @@ -118,11 +118,10 @@ supply_32bit_reg (struct regcache *regcache, int regnum, const void *addr) { struct gdbarch *gdbarch = get_regcache_arch (regcache); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - gdb_byte buf[MAX_REGISTER_SIZE]; - store_signed_integer (buf, register_size (gdbarch, regnum), byte_order, - extract_signed_integer ((const gdb_byte *) addr, 4, - byte_order)); - regcache_raw_supply (regcache, regnum, buf); + LONGEST val; + + val = extract_integer ((const gdb_byte *) addr, 4, byte_order); + regcache->raw_supply (regnum, val); } /* Unpack an elf_gregset_t into GDB's register cache. */ @@ -460,14 +459,9 @@ mips64_fill_gregset (const struct regcache *regcache, if (regaddr != -1) { - gdb_byte buf[MAX_REGISTER_SIZE]; - LONGEST val; - - regcache_raw_collect (regcache, regno, buf); - val = extract_signed_integer (buf, register_size (gdbarch, regno), - byte_order); + LONGEST val = regcache->raw_collect (regno); dst = regp + regaddr; - store_signed_integer ((gdb_byte *) dst, 8, byte_order, val); + store_integer ((gdb_byte *) dst, 8, byte_order, val); } } @@ -564,25 +558,15 @@ mips64_fill_fpregset (const struct regcache *regcache, } else if (regno == mips_regnum (gdbarch)->fp_control_status) { - gdb_byte buf[MAX_REGISTER_SIZE]; - LONGEST val; - - regcache_raw_collect (regcache, regno, buf); - val = extract_signed_integer (buf, register_size (gdbarch, regno), - byte_order); + LONGEST val = regcache->raw_collect (regno); to = (gdb_byte *) (*fpregsetp + 32); - store_signed_integer (to, 4, byte_order, val); + store_integer (to, 4, byte_order, val); } else if (regno == mips_regnum (gdbarch)->fp_implementation_revision) { - gdb_byte buf[MAX_REGISTER_SIZE]; - LONGEST val; - - regcache_raw_collect (regcache, regno, buf); - val = extract_signed_integer (buf, register_size (gdbarch, regno), - byte_order); + LONGEST val = regcache->raw_collect (regno); to = (gdb_byte *) (*fpregsetp + 32) + 4; - store_signed_integer (to, 4, byte_order, val); + store_integer (to, 4, byte_order, val); } else if (regno == -1) { diff --git a/gdb/regcache.h b/gdb/regcache.h index 4dcfccbac70f0f962bf5e5596d035fda42322795..1ec8b98aa79c58c413786351a715ee46a0f5d5c2 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -21,6 +21,7 @@ #define REGCACHE_H #include "common-regcache.h" +#include "defs.h" struct regcache; struct regset; @@ -294,8 +295,12 @@ public: void raw_collect (int regnum, void *buf) const; + template LongType raw_collect (int regnum) const; + void raw_supply (int regnum, const void *buf); + template void raw_supply (int regnum, LongType val); + void raw_supply_zeroed (int regnum); void raw_copy (int regnum, struct regcache *src_regcache); diff --git a/gdb/regcache.c b/gdb/regcache.c index 957b265c28d929376c3b7d8c100ea355d8292b94..4facc6b55e2bd08972cce1081b27e669103b6717 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1208,6 +1208,31 @@ regcache::raw_supply (int regnum, const void *buf) } } +/* Supply register REGNUM, whose contents are stored in VAL, to + REGCACHE. */ + +template +void +regcache::raw_supply (int regnum, LongType val) +{ + enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch); + gdb_byte *regbuf; + size_t size; + + gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers); + gdb_assert (!m_readonly_p); + + regbuf = register_buffer (regnum); + size = m_descr->sizeof_register[regnum]; + + store_integer (regbuf, size, byte_order, val); + m_register_status[regnum] = REG_VALID; +} + +template void regcache::raw_supply (int regnum, + LongType val); +template void regcache::raw_supply (int regnum, LongType val); + /* Supply register REGNUM with zeroed value to REGCACHE. This is not the same as calling raw_supply with NULL (which will set the state to unavailable). */ @@ -1251,6 +1276,30 @@ regcache::raw_collect (int regnum, void *buf) const memcpy (buf, regbuf, size); } +/* Collect register REGNUM from REGCACHE and extract its contents into a + LONGEST. */ + +template +LongType regcache::raw_collect (int regnum) const +{ + enum bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch); + const gdb_byte *regbuf; + size_t size; + + gdb_assert (regnum >= 0 && regnum < m_descr->nr_raw_registers); + + regbuf = register_buffer (regnum); + size = m_descr->sizeof_register[regnum]; + + if (std::is_signed::value) + return extract_signed_integer (regbuf, size, byte_order); + else + return extract_unsigned_integer (regbuf, size, byte_order); +} + +template LongType regcache::raw_collect (int regnum) const; +template LongType regcache::raw_collect (int regnum) const; + void regcache::raw_copy (int regnum, struct regcache *src_regcache) {