From patchwork Fri Feb 24 10:08:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 19368 Received: (qmail 55704 invoked by alias); 24 Feb 2017 10:09:04 -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 55686 invoked by uid 89); 24 Feb 2017 10:09:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, 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-he1eur01on0068.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (104.47.0.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Feb 2017 10:09:02 +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:08:59 +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:08:59 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd Subject: [PATCH] Remove MAX_REGISTER_SIZE from target.c Date: Fri, 24 Feb 2017 10:08:58 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-office365-filtering-correlation-id: 4e48b1ea-7d8d-4069-753c-08d45c9d267d 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:JhzlGVwya4ot7cB3yLSLMJecQMwIIrNHkprKp9cJBCeD5Iqh4y+3dDKhQR9+eqhzG15MfwhQ/ijPtnK0S0qGufz1NIXK8zKgOp0PJdMuhnqnOTdArZzhSaRRbzxR0F0dvIhcJsoV/eVS/CS28n1bTV081Bwhr9z6tL9sgQPniN02PQ4sdSjzHzEG2nLBGwJ4Sm21NUCGpRPS2bBtk1N2Cupi26PGRfEC07pqEEtc2qYwKEK6L5hNZsKcMFz21AOJemkJ/Mnzw2QT2LccuM4RiYs/mcat4qqulkg/ehuprAStqxaOIKaBXcNJbTXcM6jD0ZmVOfBM33RokAAcyAwxwg== 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)(10201501046)(3002001)(6055026)(6041248)(20161123558025)(20161123560025)(20161123562025)(20161123564025)(20161123555025)(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)(575784001)(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:08:58.8597 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1824 Avoid copying the register in debug_print_register by moving the func into regcache. Tested using make check with board files unix and native-gdbserver. Ok to commit? Alan. 2017-02-24 Alan Hayward * regcache.c (regcache_debug_print_register): New function. * regcache.h (regcache_debug_print_register): New declaration. * target.c (debug_print_register): Remove. (target_fetch_registers): Call regcache_debug_print_register. (target_store_registers): Likewise. diff --git a/gdb/regcache.h b/gdb/regcache.h index e1495f61426f879386b905ab1e97421bdd061bf5..59233308f926ebd52db9958cba168daacc77c1ee 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -232,4 +232,8 @@ extern void regcache_cpy (struct regcache *dest, struct regcache *src); extern void registers_changed (void); extern void registers_changed_ptid (ptid_t); +extern void regcache_debug_print_register (const char *func, + struct regcache *regcache, + int regno); + #endif /* REGCACHE_H */ diff --git a/gdb/regcache.c b/gdb/regcache.c index f190eda0e47c5c03744fc26263505d1c30ea1ee8..31aa1baf7ef69c27c00e45e3c8d4eb3c41dc4203 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1259,6 +1259,42 @@ regcache_write_pc (struct regcache *regcache, CORE_ADDR pc) reinit_frame_cache (); } +void +regcache_debug_print_register (const char *func, struct regcache *regcache, + int regno) +{ + struct gdbarch *gdbarch = get_regcache_arch (regcache); + + fprintf_unfiltered (gdb_stdlog, "%s ", func); + if (regno >= 0 && regno < gdbarch_num_regs (gdbarch) + && gdbarch_register_name (gdbarch, regno) != NULL + && gdbarch_register_name (gdbarch, regno)[0] != '\0') + fprintf_unfiltered (gdb_stdlog, "(%s)", + gdbarch_register_name (gdbarch, regno)); + else + fprintf_unfiltered (gdb_stdlog, "(%d)", regno); + if (regno >= 0 && regno < gdbarch_num_regs (gdbarch)) + { + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + int i, size = register_size (gdbarch, regno); + gdb_byte *buf = register_buffer (regcache, regno); + + regcache_raw_collect (regcache, regno, buf); + fprintf_unfiltered (gdb_stdlog, " = "); + for (i = 0; i < size; i++) + { + fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]); + } + if (size <= sizeof (LONGEST)) + { + ULONGEST val = extract_unsigned_integer (buf, size, byte_order); + + fprintf_unfiltered (gdb_stdlog, " %s %s", + core_addr_to_string_nz (val), plongest (val)); + } + } + fprintf_unfiltered (gdb_stdlog, "\n"); +} static void reg_flush_command (char *command, int from_tty) diff --git a/gdb/target.c b/gdb/target.c index 0ff8515d3b731ff5929e5c9c68a20d124c1ecd67..7c286ab6bf821ced42a0c1ac945343b761a37157 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3547,49 +3547,12 @@ target_options_to_string (int target_options) return ret; } -static void -debug_print_register (const char * func, - struct regcache *regcache, int regno) -{ - struct gdbarch *gdbarch = get_regcache_arch (regcache); - - fprintf_unfiltered (gdb_stdlog, "%s ", func); - if (regno >= 0 && regno < gdbarch_num_regs (gdbarch) - && gdbarch_register_name (gdbarch, regno) != NULL - && gdbarch_register_name (gdbarch, regno)[0] != '\0') - fprintf_unfiltered (gdb_stdlog, "(%s)", - gdbarch_register_name (gdbarch, regno)); - else - fprintf_unfiltered (gdb_stdlog, "(%d)", regno); - if (regno >= 0 && regno < gdbarch_num_regs (gdbarch)) - { - enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - int i, size = register_size (gdbarch, regno); - gdb_byte buf[MAX_REGISTER_SIZE]; - - regcache_raw_collect (regcache, regno, buf); - fprintf_unfiltered (gdb_stdlog, " = "); - for (i = 0; i < size; i++) - { - fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]); - } - if (size <= sizeof (LONGEST)) - { - ULONGEST val = extract_unsigned_integer (buf, size, byte_order); - - fprintf_unfiltered (gdb_stdlog, " %s %s", - core_addr_to_string_nz (val), plongest (val)); - } - } - fprintf_unfiltered (gdb_stdlog, "\n"); -} - void target_fetch_registers (struct regcache *regcache, int regno) { current_target.to_fetch_registers (¤t_target, regcache, regno); if (targetdebug) - debug_print_register ("target_fetch_registers", regcache, regno); + regcache_debug_print_register ("target_fetch_registers", regcache, regno); } void @@ -3601,7 +3564,8 @@ target_store_registers (struct regcache *regcache, int regno) current_target.to_store_registers (¤t_target, regcache, regno); if (targetdebug) { - debug_print_register ("target_store_registers", regcache, regno); + regcache_debug_print_register ("target_store_registers", regcache, + regno); } }