From patchwork Fri Feb 24 10:21:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 19371 Received: (qmail 106700 invoked by alias); 24 Feb 2017 10:21:46 -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 106651 invoked by uid 89); 24 Feb 2017 10:21:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com Received: from mail-he1eur01on0079.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (104.47.0.79) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Feb 2017 10:21:43 +0000 Received: from VI1PR0801MB1822.eurprd08.prod.outlook.com (10.168.68.7) by VI1PR0801MB1824.eurprd08.prod.outlook.com (10.168.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.13; Fri, 24 Feb 2017 10:21:40 +0000 Received: from VI1PR0801MB1822.eurprd08.prod.outlook.com ([10.168.68.7]) by VI1PR0801MB1822.eurprd08.prod.outlook.com ([10.168.68.7]) with mapi id 15.01.0919.018; Fri, 24 Feb 2017 10:21:40 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd Subject: [PATCH] Remove MAX_REGISTER_SIZE from record-full.c Date: Fri, 24 Feb 2017 10:21:40 +0000 Message-ID: <92701E3D-1AB0-44F6-B3C8-6D2A8E489985@arm.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-office365-filtering-correlation-id: fc06aad8-c4be-42e2-7a91-08d45c9eec36 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:VI1PR0801MB1824; x-microsoft-exchange-diagnostics: 1; VI1PR0801MB1824; 7:f0o2TQyN2CU5TIUjltG6Sdk90Btwio07t8QDdNwbno52hvy4HLKH7osAS4y/Y9Vkgk3sH0FlcTV2ZoVOtrf/H/9ZeTrh8uB6RfTHFRPxQp6jNWSGJEgVv3o8JKDSY84LERnd822euA/f77I7pz4O4R5bPh588vr0QoMw5HunyvrzrvaGBEPa0yxwkcW5lJYvRck0s9qtPubuQeSQijNxEeXeqLtCD2BArGw1kwCrQOBUm9wC3gcZ+na1E3Vczj8GUrhOJ3ukE3KQYGJWu1RUG454iCXUY0kwA5EM1c79bfSSrt4SmVGTcxyo6hWC6kErkK1PUAFiAJ3DXx9Rt2bI0Q== nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(20161123558025)(6072148); SRVR:VI1PR0801MB1824; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0801MB1824; x-forefront-prvs: 0228DDDDD7 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39450400003)(39410400002)(39850400002)(39840400002)(39860400002)(199003)(189002)(377424004)(5660300001)(6512007)(2900100001)(2351001)(6916009)(122556002)(66066001)(6436002)(99286003)(105586002)(106116001)(106356001)(6506006)(6486002)(4326007)(77096006)(2501003)(2906002)(36756003)(6116002)(3846002)(102836003)(82746002)(53936002)(54356999)(3280700002)(8936002)(8676002)(33656002)(68736007)(3660700001)(86362001)(101416001)(81156014)(50986999)(83716003)(305945005)(81166006)(7736002)(97736004)(189998001)(110136004)(450100001)(5640700003)(38730400002)(25786008)(92566002)(104396002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0801MB1824; H:VI1PR0801MB1822.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Feb 2017 10:21:40.1141 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1824 Cannot avoid using buffer in record_full_exec_insn because it is doing an in place swap. Tested using make check with board files unix and native-gdbserver. Ok to commit? Alan. 2017-02-24 Alan Hayward * record-full.c (record_full_exec_insn): Use vec instead of array. (record_full_core_open_1): Call max_register_size. (record_full_core_fetch_registers): Likewise. (record_full_core_store_registers): Likewise. diff --git a/gdb/record-full.c b/gdb/record-full.c index bd95acc6b1854753eb5da541cd7934eb3b8c9113..290d833c36e453111d240a412feb21c93c7af617 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -698,7 +698,7 @@ record_full_exec_insn (struct regcache *regcache, { case record_full_reg: /* reg */ { - gdb_byte reg[MAX_REGISTER_SIZE]; + std::vector reg (register_size (gdbarch, entry->u.reg.num)); if (record_debug > 1) fprintf_unfiltered (gdb_stdlog, @@ -707,10 +707,10 @@ record_full_exec_insn (struct regcache *regcache, host_address_to_string (entry), entry->u.reg.num); - regcache_cooked_read (regcache, entry->u.reg.num, reg); - regcache_cooked_write (regcache, entry->u.reg.num, + regcache_cooked_read (regcache, entry->u.reg.num, reg.data ()); + regcache_cooked_write (regcache, entry->u.reg.num, record_full_get_loc (entry)); - memcpy (record_full_get_loc (entry), reg, entry->u.reg.len); + memcpy (record_full_get_loc (entry), reg.data (), entry->u.reg.len); } break; @@ -792,15 +792,17 @@ static void record_full_core_open_1 (const char *name, int from_tty) { struct regcache *regcache = get_current_regcache (); - int regnum = gdbarch_num_regs (get_regcache_arch (regcache)); + struct gdbarch *gdbarch = get_regcache_arch (regcache); + int regnum = gdbarch_num_regs (gdbarch); + int regmaxsize = max_register_size (gdbarch); int i; /* Get record_full_core_regbuf. */ target_fetch_registers (regcache, -1); - record_full_core_regbuf = (gdb_byte *) xmalloc (MAX_REGISTER_SIZE * regnum); + record_full_core_regbuf = (gdb_byte *) xmalloc (regmaxsize * regnum); for (i = 0; i < regnum; i ++) regcache_raw_collect (regcache, i, - record_full_core_regbuf + MAX_REGISTER_SIZE * i); + record_full_core_regbuf + regmaxsize * i); /* Get record_full_core_start and record_full_core_end. */ if (build_section_table (core_bfd, &record_full_core_start, @@ -2047,6 +2049,9 @@ record_full_core_fetch_registers (struct target_ops *ops, struct regcache *regcache, int regno) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); + int regmaxsize = max_register_size (gdbarch); + if (regno < 0) { int num = gdbarch_num_regs (get_regcache_arch (regcache)); @@ -2054,11 +2059,11 @@ record_full_core_fetch_registers (struct target_ops *ops, for (i = 0; i < num; i ++) regcache_raw_supply (regcache, i, - record_full_core_regbuf + MAX_REGISTER_SIZE * i); + record_full_core_regbuf + regmaxsize * i); } else regcache_raw_supply (regcache, regno, - record_full_core_regbuf + MAX_REGISTER_SIZE * regno); + record_full_core_regbuf + regmaxsize * regno); } /* "to_prepare_to_store" method for prec over corefile. */ @@ -2076,9 +2081,12 @@ record_full_core_store_registers (struct target_ops *ops, struct regcache *regcache, int regno) { + struct gdbarch *gdbarch = get_regcache_arch (regcache); + int regmaxsize = max_register_size (gdbarch); + if (record_full_gdb_operation_disable) regcache_raw_collect (regcache, regno, - record_full_core_regbuf + MAX_REGISTER_SIZE * regno); + record_full_core_regbuf + regmaxsize * regno); else error (_("You can't do that without a process to debug.")); } @@ -2263,25 +2271,6 @@ init_record_full_core_ops (void) } /* Record log save-file format - Version 1 (never released) - - Header: - 4 bytes: magic number htonl(0x20090829). - NOTE: be sure to change whenever this file format changes! - - Records: - record_full_end: - 1 byte: record type (record_full_end, see enum record_full_type). - record_full_reg: - 1 byte: record type (record_full_reg, see enum record_full_type). - 8 bytes: register id (network byte order). - MAX_REGISTER_SIZE bytes: register value. - record_full_mem: - 1 byte: record type (record_full_mem, see enum record_full_type). - 8 bytes: memory length (network byte order). - 8 bytes: memory address (network byte order). - n bytes: memory value (n == memory length). - Version 2 4 bytes: magic number netorder32(0x20091016). NOTE: be sure to change whenever this file format changes!