From patchwork Mon Jun 26 12:41:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 21263 Received: (qmail 102180 invoked by alias); 26 Jun 2017 12:41:27 -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 102124 invoked by uid 89); 26 Jun 2017 12:41:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=all, simulator X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-ve1eur01on0089.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (104.47.1.89) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Jun 2017 12:41:22 +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.1199.15; Mon, 26 Jun 2017 12:41:18 +0000 Received: from AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::c9c3:7efd:351b:dc0d]) by AM3PR08MB0101.eurprd08.prod.outlook.com ([fe80::c9c3:7efd:351b:dc0d%15]) with mapi id 15.01.1199.019; Mon, 26 Jun 2017 12:41:18 +0000 From: Alan Hayward To: Yao Qi CC: "gdb-patches@sourceware.org" , "vapier@gentoo.org" , nd Subject: Re: [PATCH] Remove MAX_REGISTER_SIZE from remote-sim.c Date: Mon, 26 Jun 2017 12:41:18 +0000 Message-ID: <692B46FA-E9FE-48BF-BE1C-9DDD606474B7@arm.com> References: <86wpbft0r4.fsf@gmail.com> In-Reply-To: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM3PR08MB0103; 7:bR9HKsqgsNGSiWl57jagD0XBWuWAHVXwu2n9TwuzKbtveqrwBzAdK5b0KW2y/OGlaIpOBVLsnbXdAFI+Ou3s3KAow6fI6SdXw5L4kkJNXgxleHmtXxXEyCo79EaW8Gz32gZSuZCFYytbDy7xkM3z6wVXgJPGPVWK07PnNpVDBynTQa2qZc+2tabkW8yZl9H9nyoXbIPLHytKjmN7FIR6Bs6SRYcdw+MWjuWd4nIsLGnxVpNWoLBp1F/Irv17uZkC5icR5na79GLqtivKb6/K4TGkrea5v39aNAHG1y2BltZ7OjKxNivbDFom2N3pWy+DYUf2Z+OcYW/gJPsfYoMcp0ZQ6MddRc9xAOAc44GvrkNhPTKVtBpj3W1dhu+FmNSBvFTcHFw/VcB33RHyAkKWLOSHBahQ9XYqbBitczXSGsaCDjzteckQvBGwsPwcZ3QaO9Ip7MkPwy4ANXVopyAKaASOb0jQPxuCQf4pB56jR4kYjkmnmFvHz1/huvVE42Owfb38Wm11gAREnNpKzsumND3ikkI+wrxDlOYKGNdXzzQUBtrANVIz3SPcNBWeEj9PhWBz3G+GU+CaPWpl6z28rmDV05leIlsmg2GKhXqagE0Fj9nqru+2wShiNHeYRFIbrakPTG8p8zGZvKenCM+b2NM9v4IQzpJHLHkWT1dl82tiQwDRtXr5fE0jysyocWgRxTpt6WGDrfkKNUviTgB/KmXzc17m9wBD7Lf5iZw7m/XJbDHfeTGSj9SIZK1L0AOmI3S+AxmcBRjnNqelYKPPkx8RyDbF9XnjeG4wfzTFuJA= x-ms-office365-filtering-correlation-id: 19ff5367-583c-4b90-7cbf-08d4bc90a449 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254075)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095); SRVR:AM3PR08MB0103; x-ms-traffictypediagnostic: AM3PR08MB0103: nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(236129657087228)(48057245064654); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123558100)(20161123560025)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM3PR08MB0103; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM3PR08MB0103; x-forefront-prvs: 0350D7A55D x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39450400003)(39850400002)(39840400002)(39410400002)(39400400002)(39860400002)(377454003)(24454002)(377424004)(575784001)(72206003)(305945005)(3660700001)(81166006)(25786009)(54356999)(50986999)(86362001)(8936002)(102836003)(6116002)(76176999)(3846002)(5250100002)(478600001)(101416001)(6246003)(110136004)(2906002)(39060400002)(36756003)(33656002)(38730400002)(99286003)(6512007)(93886004)(3280700002)(54906002)(53936002)(14454004)(8676002)(6486002)(4326008)(7736002)(83716003)(6436002)(229853002)(66066001)(6506006)(2900100001)(189998001)(53546010)(2950100002)(6916009)(1411001)(82746002)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0103; H:AM3PR08MB0101.eurprd08.prod.outlook.com; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <199B9F6B5F2A7F4E95841F8AF7CD1E98@eurprd08.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jun 2017 12:41:18.1018 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0103 X-IsSubscribed: yes > On 24 Mar 2017, at 11:59, Yao Qi wrote: > > On Fri, Mar 24, 2017 at 11:39 AM, Alan Hayward wrote: >>> >>> What is your target triplet? Do you see remote-sim.o in your build >>> directory? remote-sim.c may not be built at all. >> >> You’re correct - I’m not building remote-sim at all! >> Forcing SIM_OBS in Makefile.in gives me a compile error (just need to >> cast result of value_contents_all to remove the const). >> >> Is there an easy way to build and test remote-sim ? >> > > remote-sim.c is built if I configure gdb --target=arm-none-eabi. > I don't know how to test either, running sim test cases, Mike? > > -- > Yao (齐尧) Reworked this patch based on changes I’ve mode to similar patches. Built using --target=arm-none-eabi then tested using --target_board=arm-sim Ok to commit? 2017-06-26 Alan Hayward * remote-sim.c (gdbsim_fetch_register): Use byte_vector. (gdbsim_store_register): Likewise. diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index fd1bc66642389a4879171af8eeee30a5df7cbaec..8ff0bc937e5f2ec61d965788166b2bb12fdf7045 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -40,6 +40,7 @@ #include "arch-utils.h" #include "readline/readline.h" #include "gdbthread.h" +#include "common/byte-vector.h" /* Prototypes */ @@ -448,38 +449,32 @@ gdbsim_fetch_register (struct target_ops *ops, { /* For moment treat a `does not exist' register the same way as an ``unavailable'' register. */ - gdb_byte buf[MAX_REGISTER_SIZE]; - int nr_bytes; - - memset (buf, 0, MAX_REGISTER_SIZE); - regcache_raw_supply (regcache, regno, buf); + regcache->raw_supply_zeroed (regno); break; } default: { static int warn_user = 1; - gdb_byte buf[MAX_REGISTER_SIZE]; + int regsize = register_size (gdbarch, regno); + gdb::byte_vector buf (regsize, 0); int nr_bytes; gdb_assert (regno >= 0 && regno < gdbarch_num_regs (gdbarch)); - memset (buf, 0, MAX_REGISTER_SIZE); nr_bytes = sim_fetch_register (sim_data->gdbsim_desc, gdbarch_register_sim_regno (gdbarch, regno), - buf, - register_size (gdbarch, regno)); + buf.data (), regsize); if (nr_bytes > 0 - && nr_bytes != register_size (gdbarch, regno) && warn_user) + && nr_bytes != regsize && warn_user) { fprintf_unfiltered (gdb_stderr, "Size of register %s (%d/%d) " "incorrect (%d instead of %d))", gdbarch_register_name (gdbarch, regno), regno, - gdbarch_register_sim_regno - (gdbarch, regno), - nr_bytes, register_size (gdbarch, regno)); + gdbarch_register_sim_regno (gdbarch, regno), + nr_bytes, regsize); warn_user = 0; } /* FIXME: cagney/2002-05-27: Should check `nr_bytes == 0' @@ -487,13 +482,13 @@ gdbsim_fetch_register (struct target_ops *ops, which registers are fetchable. */ /* Else if (nr_bytes < 0): an old simulator, that doesn't think to return the register size. Just assume all is ok. */ - regcache_raw_supply (regcache, regno, buf); + regcache->raw_supply (regno, buf.data ()); if (remote_debug) { fprintf_unfiltered (gdb_stdlog, "gdbsim_fetch_register: %d", regno); /* FIXME: We could print something more intelligible. */ - dump_mem (buf, register_size (gdbarch, regno)); + dump_mem (buf.data (), regsize); } break; } @@ -518,15 +513,17 @@ gdbsim_store_register (struct target_ops *ops, } else if (gdbarch_register_sim_regno (gdbarch, regno) >= 0) { - gdb_byte tmp[MAX_REGISTER_SIZE]; + int regsize = register_size (gdbarch, regno); + gdb::byte_vector tmp (regsize); int nr_bytes; - regcache_cooked_read (regcache, regno, tmp); + regcache->cooked_read (regno, tmp.data ()); nr_bytes = sim_store_register (sim_data->gdbsim_desc, gdbarch_register_sim_regno (gdbarch, regno), - tmp, register_size (gdbarch, regno)); - if (nr_bytes > 0 && nr_bytes != register_size (gdbarch, regno)) + tmp.data (), regsize); + + if (nr_bytes > 0 && nr_bytes != regsize) internal_error (__FILE__, __LINE__, _("Register size different to expected")); if (nr_bytes < 0) @@ -540,7 +537,7 @@ gdbsim_store_register (struct target_ops *ops, { fprintf_unfiltered (gdb_stdlog, "gdbsim_store_register: %d", regno); /* FIXME: We could print something more intelligible. */ - dump_mem (tmp, register_size (gdbarch, regno)); + dump_mem (tmp.data (), regsize); } } }