From patchwork Wed Feb 8 14:17:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 19176 Received: (qmail 63845 invoked by alias); 8 Feb 2017 14:17:25 -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 63700 invoked by uid 89); 8 Feb 2017 14:17:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=AWL, BAYES_50, KAM_LOTSOFHASH, MIME_BASE64_BLANKS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.2 spammy=qiyaoltc@gmail.com, qiyaoltcgmailcom, U*qiyaoltc, sk:qiyaolt X-HELO: EUR01-DB5-obe.outbound.protection.outlook.com Received: from mail-db5eur01on0042.outbound.protection.outlook.com (HELO EUR01-DB5-obe.outbound.protection.outlook.com) (104.47.2.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Feb 2017 14:17:11 +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.888.16; Wed, 8 Feb 2017 14:17:06 +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.0888.026; Wed, 8 Feb 2017 14:17:06 +0000 From: Alan Hayward To: Yao Qi CC: Pedro Alves , Joel Brobecker , "gdb-patches@sourceware.org" , nd Subject: Re: [PATCH] Removal of uses of MAX_REGISTER_SIZE Date: Wed, 8 Feb 2017 14:17:06 +0000 Message-ID: <34564AB1-2F18-45E3-BD61-EF123F6BF9B5@arm.com> References: <20170202094012.dge4r6rsl2skdrii@adacore.com> <20170203102819.GA11916@E107787-LIN> <25716edf-096e-20c5-4170-fb8ca04d897b@redhat.com> <0C6A0D51-4C49-4400-8C46-E77DD512DF56@arm.com> <20170203165022.GB11916@E107787-LIN> <1E0030CE-FB37-4821-AA53-9C6D1CC285C9@arm.com> <20170206152635.GE11916@E107787-LIN> <5F3D30AE-9A53-493A-B6DC-DF594C2FAB18@arm.com> <20170208104713.GB32023@E107787-LIN> In-Reply-To: <20170208104713.GB32023@E107787-LIN> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-office365-filtering-correlation-id: 364a4298-ba7d-44a4-e9ec-08d4502d2999 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:rFTIjUZIkMqgUrYXGBCYjlMwScxyVPDEdPhgKdDgabHTSU0dfSAH/+VRedNg0sdmmhWf5gxUlofU5OnFC7bfqhD6L2CmdQHI650h3/muAbogj/5s57WZDEqgjgwp2H6krGqrUObmT/EUQ8GSS3V1ZBck96AliVYF7oapuvFUSyJBjBLR3CNRWpR4iyB+udnTH6ZGq3gG4ojW34hUpkLfswvN/ca3PD7KI0Zq5x/RP9H1w55RD6Qdm/EStck+K81Po9Izd/237bpCLNEcwY9ulXCjjArfjc5Ki0mXDET+heqAiwA03jkHEN3sJS+AuE85/v6PSgVcDDX9FPLu/P1IiMU1HGupiAw7gV84wtiSSruIOHltXfggCvs3ab4gfaWuNL00J/kv7XhV2cl953myzzfk3GhUY90IFLRZF+XzzgPJalpVhgF8SbUEV7NU3Qm7Lvj9z+riRQtKmpSR9P3JAfyrbwrYGvNlsS0i7GeikZGw3L04LwNhRJOIpYs9bfagVcxK8AJhBqyKSqNLQwMJFA== 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)(20170203043)(5005006)(2017020702029)(3002001)(10201501046)(6055026)(6041248)(20161123564025)(20161123560025)(20161123562025)(20161123558025)(20161123555025)(6072148); SRVR:VI1PR0801MB1824; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0801MB1824; x-forefront-prvs: 0212BDE3BE x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39850400002)(39410400002)(39450400003)(39840400002)(39860400002)(377424004)(24454002)(189002)(199003)(3280700002)(106116001)(33656002)(92566002)(6246003)(25786008)(68736007)(93886004)(82746002)(97736004)(99286003)(5660300001)(1411001)(38730400002)(110136004)(8676002)(2900100001)(6512007)(81156014)(86362001)(122556002)(81166006)(8936002)(305945005)(54906002)(575784001)(3660700001)(2906002)(83716003)(106356001)(36756003)(105586002)(7736002)(189998001)(39060400001)(54356999)(2950100002)(76176999)(66066001)(229853002)(50986999)(53546003)(6436002)(6916009)(6116002)(4326007)(101416001)(6506006)(102836003)(3846002)(77096006)(53936002)(6486002)(104396002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0801MB1824; H:VI1PR0801MB1822.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <032D786C24768C48803274EF873088F6@eurprd08.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2017 14:17:06.6444 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1824 (Resend, in plain text format) > On 8 Feb 2017, at 10:47, Yao Qi wrote: > > On 17-02-07 16:33:19, Alan Hayward wrote: > > Hi Alan, > We end up having multiple different ways removing MAX_REGISTER_SIZE, and > each change is quite independent. I'll split it in my review, and you can > to post a patch set in the next version. > >> diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c >> index 8a4d59f6fdae8ec785462d0ceedcd6501b955cf0..081a16c6896ce7aee4db3b0be45fbbdd2c23dbdb 100644 >> --- a/gdb/i386-tdep.c >> +++ b/gdb/i386-tdep.c >> @@ -3250,7 +3250,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, >> int regnum, >> struct value *result_value) >> { >> - gdb_byte raw_buf[MAX_REGISTER_SIZE]; >> + gdb_byte raw_buf[I386_MAX_REGISTER_SIZE]; >> enum register_status status; >> gdb_byte *buf = value_contents_raw (result_value); >> >> @@ -3455,7 +3455,7 @@ void >> i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, >> int regnum, const gdb_byte *buf) >> { >> - gdb_byte raw_buf[MAX_REGISTER_SIZE]; >> + gdb_byte raw_buf[I386_MAX_REGISTER_SIZE]; >> >> if (i386_mmx_regnum_p (gdbarch, regnum)) >> { >> @@ -5037,7 +5037,7 @@ i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache, >> uint32_t opcode; >> uint8_t opcode8; >> ULONGEST addr; >> - gdb_byte buf[MAX_REGISTER_SIZE]; >> + gdb_byte buf[I386_MAX_REGISTER_SIZE]; >> struct i386_record_s ir; >> struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); >> uint8_t rex_w = -1; >> diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c >> index adbe72133089bc371108d5dd79bf8d8e61ba259c..fcd5ad248d6b737b9f27e294ce166a118e4bdcad 100644 >> --- a/gdb/i387-tdep.c >> +++ b/gdb/i387-tdep.c >> @@ -899,7 +899,7 @@ i387_supply_xsave (struct regcache *regcache, int regnum, >> const gdb_byte *regs = (const gdb_byte *) xsave; >> int i; >> unsigned int clear_bv; >> - static const gdb_byte zero[MAX_REGISTER_SIZE] = { 0 }; >> + static const gdb_byte zero[I386_MAX_REGISTER_SIZE] = { 0 }; >> enum >> { >> none = 0x0, >> diff --git a/gdb/m68k-linux-nat.c b/gdb/m68k-linux-nat.c >> index 6944c74eb198381135fda3ddf01b9da3a63e62d5..e5182caf39197f759c85c2321e4d66c428f5911e 100644 >> --- a/gdb/m68k-linux-nat.c >> +++ b/gdb/m68k-linux-nat.c >> @@ -105,7 +105,7 @@ fetch_register (struct regcache *regcache, int regno) >> struct gdbarch *gdbarch = get_regcache_arch (regcache); >> long regaddr, val; >> int i; >> - gdb_byte buf[MAX_REGISTER_SIZE]; >> + gdb_byte buf[M68K_MAX_REGISTER_SIZE]; > > Nit, we can even reduce the size of 'buf' to sizeof (long), because the > code read/write register by PTRACE_PEEKUSER/PTRACE_POKEUSER which is > word-wide operation. That wouldn't work. The code calls memcpy on the buffer using buf[i] up to max size of register_size (gdbarch, regno). > >> int tid; >> >> /* Overload thread id onto process id. */ >> @@ -160,7 +160,7 @@ store_register (const struct regcache *regcache, int regno) >> long regaddr, val; >> int i; >> int tid; >> - gdb_byte buf[MAX_REGISTER_SIZE]; >> + gdb_byte buf[M68K_MAX_REGISTER_SIZE]; >> >> /* Overload thread id onto process id. */ >> tid = ptid_get_lwp (inferior_ptid); > > This part is OK. > > -- > Yao (齐尧) The full M68K_MAX_REGISTER_SIZE/I386_MAX_REGISTER_SIZE changes as a single patch: 2017-02-08 Alan Hayward * i386-tdep.c (i386_pseudo_register_read_into_value): Use I386_MAX_REGISTER_SIZE. (i386_pseudo_register_write): Likewise. (i386_process_record): Likewise. * i387-tdep.c (i387_supply_xsave): Likewise. * m68k-linux-nat.c (fetch_register): Use M68K_MAX_REGISTER_SIZE. (store_register): Likewise. Alan. diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 8a4d59f6fdae8ec785462d0ceedcd6501b955cf0..081a16c6896ce7aee4db3b0be45fbbdd2c23dbdb 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3250,7 +3250,7 @@ i386_pseudo_register_read_into_value (struct gdbarch *gdbarch, int regnum, struct value *result_value) { - gdb_byte raw_buf[MAX_REGISTER_SIZE]; + gdb_byte raw_buf[I386_MAX_REGISTER_SIZE]; enum register_status status; gdb_byte *buf = value_contents_raw (result_value); @@ -3455,7 +3455,7 @@ void i386_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, int regnum, const gdb_byte *buf) { - gdb_byte raw_buf[MAX_REGISTER_SIZE]; + gdb_byte raw_buf[I386_MAX_REGISTER_SIZE]; if (i386_mmx_regnum_p (gdbarch, regnum)) { @@ -5037,7 +5037,7 @@ i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache, uint32_t opcode; uint8_t opcode8; ULONGEST addr; - gdb_byte buf[MAX_REGISTER_SIZE]; + gdb_byte buf[I386_MAX_REGISTER_SIZE]; struct i386_record_s ir; struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); uint8_t rex_w = -1; diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c index adbe72133089bc371108d5dd79bf8d8e61ba259c..fcd5ad248d6b737b9f27e294ce166a118e4bdcad 100644 --- a/gdb/i387-tdep.c +++ b/gdb/i387-tdep.c @@ -899,7 +899,7 @@ i387_supply_xsave (struct regcache *regcache, int regnum, const gdb_byte *regs = (const gdb_byte *) xsave; int i; unsigned int clear_bv; - static const gdb_byte zero[MAX_REGISTER_SIZE] = { 0 }; + static const gdb_byte zero[I386_MAX_REGISTER_SIZE] = { 0 }; enum { none = 0x0, diff --git a/gdb/m68k-linux-nat.c b/gdb/m68k-linux-nat.c index 6944c74eb198381135fda3ddf01b9da3a63e62d5..e5182caf39197f759c85c2321e4d66c428f5911e 100644 --- a/gdb/m68k-linux-nat.c +++ b/gdb/m68k-linux-nat.c @@ -105,7 +105,7 @@ fetch_register (struct regcache *regcache, int regno) struct gdbarch *gdbarch = get_regcache_arch (regcache); long regaddr, val; int i; - gdb_byte buf[MAX_REGISTER_SIZE]; + gdb_byte buf[M68K_MAX_REGISTER_SIZE]; int tid; /* Overload thread id onto process id. */ @@ -160,7 +160,7 @@ store_register (const struct regcache *regcache, int regno) long regaddr, val; int i; int tid; - gdb_byte buf[MAX_REGISTER_SIZE]; + gdb_byte buf[M68K_MAX_REGISTER_SIZE]; /* Overload thread id onto process id. */ tid = ptid_get_lwp (inferior_ptid);