From patchwork Fri Mar 24 15:22:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 19722 Received: (qmail 101037 invoked by alias); 24 Mar 2017 15:23:07 -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 101021 invoked by uid 89); 24 Mar 2017 15:23:06 -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, KAM_LOTSOFHASH, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=Comments X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com Received: from mail-he1eur01on0076.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (104.47.0.76) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Mar 2017 15:23:04 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com (10.160.211.19) by AM3PR08MB0104.eurprd08.prod.outlook.com (10.160.211.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.991.14; Fri, 24 Mar 2017 15:22:59 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::a542:8c73:7479:1ad3]) by AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::a542:8c73:7479:1ad3%15]) with mapi id 15.01.0991.017; Fri, 24 Mar 2017 15:22:59 +0000 From: Alan Hayward To: Yao Qi CC: "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH] Remove MAX_REGISTER_SIZE from target.c Date: Fri, 24 Mar 2017 15:22:44 +0000 Message-ID: References: <868toorjwz.fsf@gmail.com> In-Reply-To: <868toorjwz.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-exchange-messagesentrepresentingtype: 1 x-microsoft-exchange-diagnostics: 1; AM3PR08MB0104; 7:4D2vRGPenu4WB5mCGzhlNMbNC9uIQRsluqOy2wrpkzrO6Y0NDxb5KQSmCeJxoNIzNduJ8nXItrLAOKE3JDPEdw3SXF86WigO8kLNBUoBWDYrUgh+05cnhq9jdWRjMgCSUpi3/aBgCbOKmkpchGo4NZJgIt3/+iUodBYwzantCNLxT8NytnEzrHzNJMX4lfGQ4KLJ3GhBxrU+ARaULlQPBZh7+3mixMt3CJdYzIUVaS/2qpVTVVez/5Lr4OPNz+NZ2YaWpoK+CeHef6odngz6N9ioBABAgXcNwlRWG9ZeCsL0j4YuPfeksfdOSALOGqLiUFXTh+IRExJ6RfU7MipA+Q== x-ms-office365-filtering-correlation-id: fbe6dd5c-f799-4ad7-2136-08d472c9a7bb x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(48565401081); SRVR:AM3PR08MB0104; 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)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123564025)(20161123560025)(20161123562025)(20161123558025)(6072148); SRVR:AM3PR08MB0104; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0104; x-forefront-prvs: 0256C18696 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39840400002)(39450400003)(39850400002)(39860400002)(39410400002)(377424004)(24454002)(6506006)(6486002)(86362001)(7736002)(189998001)(5660300001)(82746002)(6436002)(54356999)(33656002)(76176999)(50986999)(53546009)(66066001)(1411001)(25786009)(36756003)(6116002)(102836003)(2900100001)(8676002)(6246003)(3660700001)(4326008)(38730400002)(8936002)(3280700002)(5250100002)(81166006)(2906002)(39060400002)(110136004)(575784001)(2950100002)(6916009)(83716003)(229853002)(53936002)(305945005)(6512007)(99286003)(54906002)(6666003)(3846002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0104; H:AM3PR08MB0101.eurprd08.prod.outlook.com; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <9411F5153F00C3488BC3FA4CB30A9518@eurprd08.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Mar 2017 15:22:44.0464 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0104 > On 1 Mar 2017, at 17:22, Yao Qi wrote: > > Alan Hayward writes: > >> +extern void regcache_debug_print_register (const char *func, >> + struct regcache *regcache, >> + int regno); > > Comments are needed. > >> + >> #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); > > Don't need to call regcache_raw_collect, otherwise, the src and dst of > copy is at the same address (register_buffer (regcache, regno)). > > -- > Yao (齐尧) Patch updated from review comments. Tested using make check with board files unix and native-gdbserver. Ok to commit? Alan. 2017-03-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 63a1a980eb757167fe253164730a534344543948..8b7a0a2afb416df9c03216a203f05d1a2ca0ac8d 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -234,4 +234,10 @@ extern void regcache_cpy (struct regcache *dest, struct regcache *src); extern void registers_changed (void); extern void registers_changed_ptid (ptid_t); +/* Dump the contents of a register from the register cache to the target + debug. */ +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 59ee5be14817d61ec1180cae2c19719949af0a03..eb6d09f6cb50ff9347991b7b061f4314c497e018 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -1268,6 +1268,41 @@ 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); + + 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); } }