From patchwork Thu May 11 13:10:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 20393 Received: (qmail 71238 invoked by alias); 11 May 2017 13:11:03 -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 71184 invoked by uid 89); 11 May 2017 13:11:02 -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, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=padded X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-ve1eur01on0085.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (104.47.1.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 May 2017 13:10:55 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com (10.160.211.19) by AM3PR08MB0103.eurprd08.prod.outlook.com (10.160.211.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1084.16; Thu, 11 May 2017 13:10:54 +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.017; Thu, 11 May 2017 13:10:54 +0000 From: Alan Hayward To: Yao Qi CC: "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH 4/11] Add PPC_MAX_REGISTER_SIZE Date: Thu, 11 May 2017 13:10:54 +0000 Message-ID: <9C4FF969-E1F4-4052-B287-7DB20E519E08@arm.com> References: <1051BD9C-DE4B-4554-A0D8-4818C738B669@arm.com> <86zif4qy1l.fsf@gmail.com> In-Reply-To: <86zif4qy1l.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; AM3PR08MB0103; 7:mOm3iRToRvXy7uYOuFl+zSbnkiQQYZuX1m44mFhpuvV5AwOA/EYGURX4Q0SRyUxZ94wYDDO4Gs50xYUjhNHc+zx9bQS5YDiV655D/umiro4kOuVIhdChkZg0ZY6rPAAiiJjvuRDIBeQTPzIzM1jMUto40hYOcQrtJpw6umMT6AybChMGbv0p5KbutSzGy7fuflx6rb+mA3r2YzWZUS4NAd4BqAOlb3Jgw9x1Cy7sM4i6uMRhBayrRasRqoKbuLs2tPv3K97FUmJVx5i1CZ0qgm8P+YPzQ52dv/duIzPXjCYNDIi4faYU62jsKlSqI1X9n8WYnA/eB6KOXFgxilIMTg== x-ms-office365-filtering-correlation-id: 083babf8-3321-49a8-b3ba-08d4986f2823 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081)(201702281549075); SRVR:AM3PR08MB0103; nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(22074186197030)(183786458502308); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041248)(20161123558100)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(6072148); SRVR:AM3PR08MB0103; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0103; x-forefront-prvs: 0304E36CA3 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(39840400002)(39400400002)(39410400002)(39850400002)(39450400003)(377424004)(24454002)(478600001)(25786009)(36756003)(53546009)(4326008)(38730400002)(110136004)(8676002)(33656002)(5250100002)(189998001)(6246003)(7736002)(82746002)(76176999)(6486002)(54356999)(50986999)(305945005)(53936002)(2900100001)(3280700002)(6916009)(54906002)(2950100002)(99286003)(575784001)(1411001)(86362001)(229853002)(6306002)(83716003)(66066001)(102836003)(6116002)(3846002)(6512007)(5660300001)(81166006)(39060400002)(2906002)(8936002)(6436002)(3660700001)(6506006)(72206003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0103; H:AM3PR08MB0101.eurprd08.prod.outlook.com; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <6937935497CA434A845933971526D365@eurprd08.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 11 May 2017 13:10:54.6584 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0103 > On 25 Apr 2017, at 16:58, Yao Qi wrote: > > Alan Hayward writes: > >> Max size set to 128bits, which I determined using regformats/rs6000/powerpc*.dat >> >> Tested on a --enable-targets=all build using make check with board files >> unix and native-gdbserver. >> >> I do not have a PPC machine to test on. > > Note that some files you changed are not built, like *-nat.c. Could you > test your patch on gcc compile farm? There are some POWER machine you > can use. > > https://gcc.gnu.org/wiki/CompileFarm I’ve not had a reply from the compile farm access. I have manually checked that all the .c files I have touched already #include ppc-tdep.h > > > PPC has so many variants that it is hard to claim the max register size > is 16 byte. A conservative approach is still keep using 64. It is not > very smart, but at least won't break anything, IMO. > Patch updated to use 64 bytes instead. This change will ensure there is no change any of the Power targets when compiled. Ok to commit? Alan. 2017-05-11 Alan Hayward * ppc-linux-nat.c (fetch_register): Use PPC_MAX_REGISTER_SIZE. (store_register): Likewise. * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call): Likewise. (get_decimal_float_return_value): Likewise. (do_ppc_sysv_return_value): Likewise. (ppc64_sysv_abi_push_integer): Likewise. (ppc64_sysv_abi_push_freg): Likewise. (ppc64_sysv_abi_return_value_base): Likewise. (ppc64_sysv_abi_return_value): Likewise. * rs6000-aix-tdep.c (rs6000_push_dummy_call): Likewise. * rs6000-lynx178-tdep.c (rs6000_lynx178_push_dummy_call): Likewise. * rs6000-nat.c: Likewise. * rs6000-tdep.c (rs6000_register_to_value): Likewise. (rs6000_value_to_register): Likewise. * ppc-tdep.h (PPC_MAX_REGISTER_SIZE): Add. diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index 142fa315b0736f74d787c8cd05d13c11590affa7..40ea5893664bb717cdad749c7ecdd99412d60ca6 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -497,7 +497,7 @@ fetch_register (struct regcache *regcache, int tid, int regno) CORE_ADDR regaddr = ppc_register_u_addr (gdbarch, regno); int bytes_transferred; unsigned int offset; /* Offset of registers within the u area. */ - gdb_byte buf[MAX_REGISTER_SIZE]; + gdb_byte buf[PPC_MAX_REGISTER_SIZE]; if (altivec_register_p (gdbarch, regno)) { @@ -979,7 +979,7 @@ store_register (const struct regcache *regcache, int tid, int regno) CORE_ADDR regaddr = ppc_register_u_addr (gdbarch, regno); int i; size_t bytes_to_transfer; - gdb_byte buf[MAX_REGISTER_SIZE]; + gdb_byte buf[PPC_MAX_REGISTER_SIZE]; if (altivec_register_p (gdbarch, regno)) { diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index c1778f2ef06dfee18f0631e32477a201e8d67dbf..ea655b90d6e9fc27abc48c9677d1aa8717fb53f3 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -134,7 +134,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { /* Always store the floating point value using the register's floating-point format. */ - gdb_byte regval[MAX_REGISTER_SIZE]; + gdb_byte regval[PPC_MAX_REGISTER_SIZE]; struct type *regtype = register_type (gdbarch, tdep->ppc_fp0_regnum + freg); convert_typed_floating (val, type, regval, regtype); @@ -278,7 +278,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { if (write_pass) { - gdb_byte regval[MAX_REGISTER_SIZE]; + gdb_byte regval[PPC_MAX_REGISTER_SIZE]; const gdb_byte *p; /* 32-bit decimal floats are right aligned in the @@ -364,7 +364,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, if (write_pass) { int regnum = tdep->ppc_fp0_regnum + freg; - gdb_byte regval[MAX_REGISTER_SIZE]; + gdb_byte regval[PPC_MAX_REGISTER_SIZE]; struct type *regtype = register_type (gdbarch, regnum); convert_typed_floating (elval, eltype, @@ -411,7 +411,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, } else { - gdb_byte word[MAX_REGISTER_SIZE]; + gdb_byte word[PPC_MAX_REGISTER_SIZE]; store_unsigned_integer (word, tdep->wordsize, byte_order, unpack_long (eltype, elval)); @@ -516,8 +516,8 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { /* Reduce the parameter down to something that fits in a "word". */ - gdb_byte word[MAX_REGISTER_SIZE]; - memset (word, 0, MAX_REGISTER_SIZE); + gdb_byte word[PPC_MAX_REGISTER_SIZE]; + memset (word, 0, PPC_MAX_REGISTER_SIZE); if (len > tdep->wordsize || TYPE_CODE (type) == TYPE_CODE_STRUCT || TYPE_CODE (type) == TYPE_CODE_UNION) @@ -623,7 +623,7 @@ get_decimal_float_return_value (struct gdbarch *gdbarch, struct type *valtype, { if (writebuf != NULL) { - gdb_byte regval[MAX_REGISTER_SIZE]; + gdb_byte regval[PPC_MAX_REGISTER_SIZE]; const gdb_byte *p; /* 32-bit decimal float is right aligned in the doubleword. */ @@ -706,7 +706,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, { /* Floats and doubles stored in "f1". Convert the value to the required type. */ - gdb_byte regval[MAX_REGISTER_SIZE]; + gdb_byte regval[PPC_MAX_REGISTER_SIZE]; struct type *regtype = register_type (gdbarch, tdep->ppc_fp0_regnum + 1); regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 1, regval); @@ -716,7 +716,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, { /* Floats and doubles stored in "f1". Convert the value to the register's "double" type. */ - gdb_byte regval[MAX_REGISTER_SIZE]; + gdb_byte regval[PPC_MAX_REGISTER_SIZE]; struct type *regtype = register_type (gdbarch, tdep->ppc_fp0_regnum); convert_typed_floating (writebuf, type, regval, regtype); regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 1, regval); @@ -847,7 +847,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, if (TYPE_CODE (eltype) == TYPE_CODE_FLT) { int regnum = tdep->ppc_fp0_regnum + 1 + i; - gdb_byte regval[MAX_REGISTER_SIZE]; + gdb_byte regval[PPC_MAX_REGISTER_SIZE]; struct type *regtype = register_type (gdbarch, regnum); if (writebuf != NULL) @@ -977,7 +977,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, /* GCC screwed up for structures or unions whose size is less than or equal to 8 bytes.. Instead of left-aligning, it right-aligns the data into the buffer formed by r3, r4. */ - gdb_byte regvals[MAX_REGISTER_SIZE * 2]; + gdb_byte regvals[PPC_MAX_REGISTER_SIZE * 2]; int len = TYPE_LENGTH (type); int offset = (2 * tdep->wordsize - len) % tdep->wordsize; @@ -1010,7 +1010,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, /* This matches SVr4 PPC, it does not match GCC. */ /* The value is right-padded to 8 bytes and then loaded, as two "words", into r3/r4. */ - gdb_byte regvals[MAX_REGISTER_SIZE * 2]; + gdb_byte regvals[PPC_MAX_REGISTER_SIZE * 2]; regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3, regvals + 0 * tdep->wordsize); if (TYPE_LENGTH (type) > tdep->wordsize) @@ -1023,7 +1023,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *func_type, /* This matches SVr4 PPC, it does not match GCC. */ /* The value is padded out to 8 bytes and then loaded, as two "words" into r3/r4. */ - gdb_byte regvals[MAX_REGISTER_SIZE * 2]; + gdb_byte regvals[PPC_MAX_REGISTER_SIZE * 2]; memset (regvals, 0, sizeof regvals); memcpy (regvals, writebuf, TYPE_LENGTH (type)); regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3, @@ -1340,7 +1340,7 @@ ppc64_sysv_abi_push_integer (struct gdbarch *gdbarch, ULONGEST val, { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - gdb_byte buf[MAX_REGISTER_SIZE]; + gdb_byte buf[PPC_MAX_REGISTER_SIZE]; if (argpos->regcache) store_unsigned_integer (buf, tdep->wordsize, byte_order, val); @@ -1369,7 +1369,7 @@ ppc64_sysv_abi_push_freg (struct gdbarch *gdbarch, { int regnum = tdep->ppc_fp0_regnum + argpos->freg; struct type *regtype = register_type (gdbarch, regnum); - gdb_byte regval[MAX_REGISTER_SIZE]; + gdb_byte regval[PPC_MAX_REGISTER_SIZE]; convert_typed_floating (val, type, regval, regtype); regcache_cooked_write (argpos->regcache, regnum, regval); @@ -1814,7 +1814,7 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype, { int regnum = tdep->ppc_fp0_regnum + 1 + index; struct type *regtype = register_type (gdbarch, regnum); - gdb_byte regval[MAX_REGISTER_SIZE]; + gdb_byte regval[PPC_MAX_REGISTER_SIZE]; if (writebuf != NULL) { @@ -2071,7 +2071,7 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, for (i = 0; i < n_regs; i++) { - gdb_byte regval[MAX_REGISTER_SIZE]; + gdb_byte regval[PPC_MAX_REGISTER_SIZE]; int regnum = tdep->ppc_gp0_regnum + 3 + i; int offset = i * tdep->wordsize; int len = TYPE_LENGTH (valtype) - offset; diff --git a/gdb/ppc-tdep.h b/gdb/ppc-tdep.h index 8d15ace21441a6e6393bbd0b5426b0a376567344..4ae5c7f66e60ce91af583947cecbd0ba80ec094e 100644 --- a/gdb/ppc-tdep.h +++ b/gdb/ppc-tdep.h @@ -305,6 +305,9 @@ enum { PPC_NUM_REGS }; +/* Big enough to hold the size of the largest register in bytes. */ +#define PPC_MAX_REGISTER_SIZE 64 + /* An instruction to match. */ struct ppc_insn_pattern diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c index 7d817bee1d741f3e57141375a658fd60374332cb..6cbfdbe9909d4eb00e22d8417650b9537758b5d6 100644 --- a/gdb/rs6000-aix-tdep.c +++ b/gdb/rs6000-aix-tdep.c @@ -253,7 +253,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, Always store the floating point value using the register's floating-point format. */ const int fp_regnum = tdep->ppc_fp0_regnum + 1 + f_argno; - gdb_byte reg_val[MAX_REGISTER_SIZE]; + gdb_byte reg_val[PPC_MAX_REGISTER_SIZE]; struct type *reg_type = register_type (gdbarch, fp_regnum); gdb_assert (len <= 8); @@ -270,7 +270,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Argument takes more than one register. */ while (argbytes < len) { - gdb_byte word[MAX_REGISTER_SIZE]; + gdb_byte word[PPC_MAX_REGISTER_SIZE]; memset (word, 0, reg_size); memcpy (word, ((char *) value_contents (arg)) + argbytes, @@ -290,7 +290,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, else { /* Argument can fit in one register. No problem. */ - gdb_byte word[MAX_REGISTER_SIZE]; + gdb_byte word[PPC_MAX_REGISTER_SIZE]; memset (word, 0, reg_size); memcpy (word, value_contents (arg), len); diff --git a/gdb/rs6000-lynx178-tdep.c b/gdb/rs6000-lynx178-tdep.c index f2aa1f8448cf487b1522df89ef42a3937799d95f..d72a61958e3ffc19e6f39ef5d30427ace2877edc 100644 --- a/gdb/rs6000-lynx178-tdep.c +++ b/gdb/rs6000-lynx178-tdep.c @@ -105,7 +105,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, Always store the floating point value using the register's floating-point format. */ const int fp_regnum = tdep->ppc_fp0_regnum + 1 + f_argno; - gdb_byte reg_val[MAX_REGISTER_SIZE]; + gdb_byte reg_val[PPC_MAX_REGISTER_SIZE]; struct type *reg_type = register_type (gdbarch, fp_regnum); gdb_assert (len <= 8); @@ -122,7 +122,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, /* Argument takes more than one register. */ while (argbytes < len) { - gdb_byte word[MAX_REGISTER_SIZE]; + gdb_byte word[PPC_MAX_REGISTER_SIZE]; memset (word, 0, reg_size); memcpy (word, ((char *) value_contents (arg)) + argbytes, @@ -142,7 +142,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch, else { /* Argument can fit in one register. No problem. */ - gdb_byte word[MAX_REGISTER_SIZE]; + gdb_byte word[PPC_MAX_REGISTER_SIZE]; memset (word, 0, reg_size); memcpy (word, value_contents (arg), len); diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index 83e0693d9834cf97863b038e4778405692220265..833cf01619593f1f737405b53ea5fb05b8b15b89 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -162,7 +162,7 @@ static void fetch_register (struct regcache *regcache, int regno) { struct gdbarch *gdbarch = get_regcache_arch (regcache); - int addr[MAX_REGISTER_SIZE]; + int addr[PPC_MAX_REGISTER_SIZE]; int nr, isfloat; pid_t pid = ptid_get_pid (regcache_get_ptid (regcache)); @@ -221,7 +221,7 @@ static void store_register (struct regcache *regcache, int regno) { struct gdbarch *gdbarch = get_regcache_arch (regcache); - int addr[MAX_REGISTER_SIZE]; + int addr[PPC_MAX_REGISTER_SIZE]; int nr, isfloat; pid_t pid = ptid_get_pid (regcache_get_ptid (regcache)); diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 4072464558ea436cfa6ca8cd784b64c41becc8ed..204b34ab4e13ff4eef4f2c1b9db120787d7b4a13 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -2611,7 +2611,7 @@ rs6000_register_to_value (struct frame_info *frame, int *optimizedp, int *unavailablep) { struct gdbarch *gdbarch = get_frame_arch (frame); - gdb_byte from[MAX_REGISTER_SIZE]; + gdb_byte from[PPC_MAX_REGISTER_SIZE]; gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT); @@ -2633,7 +2633,7 @@ rs6000_value_to_register (struct frame_info *frame, const gdb_byte *from) { struct gdbarch *gdbarch = get_frame_arch (frame); - gdb_byte to[MAX_REGISTER_SIZE]; + gdb_byte to[PPC_MAX_REGISTER_SIZE]; gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);