public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug exp/18617] New: Incorrect expression bytecode generated for narrowing conversions
@ 2015-07-01 5:55 robert at ocallahan dot org
2015-07-01 18:38 ` [Bug exp/18617] " khuey at kylehuey dot com
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: robert at ocallahan dot org @ 2015-07-01 5:55 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=18617
Bug ID: 18617
Summary: Incorrect expression bytecode generated for narrowing
conversions
Product: gdb
Version: 7.9
Status: NEW
Severity: normal
Priority: P2
Component: exp
Assignee: unassigned at sourceware dot org
Reporter: robert at ocallahan dot org
Target Milestone: ---
Given the program:
uint64_t u64max = (uint64_t)(int64_t)-1;
int main(int argc, char* argv[]) {
return 0;
}
and the commands
break main
cond 1 (unsigned char)u64max==255
the following expression bytecode is generated:
{0x24, 0x0, 0x60, 0xd, 0x38, 0x1a, 0x2a, 0x40, 0x23, 0x0, 0xff, 0x13, 0x27}
That is:
const32 0x600d38
ref64
zero_ext 64
const16 0xff
equal
end
The zero_ext operand is incorrect. It should have been 8, to keep the low 8
bits and zero the rest. The breakpoint condition therefore returns false when
it should return true.
The bug is in ax-gdb.c:
/* If we're converting to a narrower type, then we need to clear out
the upper bits. */
if (TYPE_LENGTH (to) < TYPE_LENGTH (from))
gen_extend (ax, from);
That should be
gen_extend (ax, to);
to keep `to` bits and zero the rest.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug exp/18617] Incorrect expression bytecode generated for narrowing conversions
2015-07-01 5:55 [Bug exp/18617] New: Incorrect expression bytecode generated for narrowing conversions robert at ocallahan dot org
@ 2015-07-01 18:38 ` khuey at kylehuey dot com
2015-07-01 21:56 ` robert at ocallahan dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: khuey at kylehuey dot com @ 2015-07-01 18:38 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=18617
Kyle Huey (Mozilla) <khuey at kylehuey dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |khuey at kylehuey dot com
--- Comment #1 from Kyle Huey (Mozilla) <khuey at kylehuey dot com> ---
Your testcase WFM on gdb 7.7.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug exp/18617] Incorrect expression bytecode generated for narrowing conversions
2015-07-01 5:55 [Bug exp/18617] New: Incorrect expression bytecode generated for narrowing conversions robert at ocallahan dot org
2015-07-01 18:38 ` [Bug exp/18617] " khuey at kylehuey dot com
@ 2015-07-01 21:56 ` robert at ocallahan dot org
2015-07-02 14:27 ` palves at redhat dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: robert at ocallahan dot org @ 2015-07-01 21:56 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=18617
Robert O'Callahan <robert at ocallahan dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at sourceware dot org |robert at ocallahan dot org
--- Comment #2 from Robert O'Callahan <robert at ocallahan dot org> ---
Created attachment 8406
--> https://sourceware.org/bugzilla/attachment.cgi?id=8406&action=edit
preserve 'to' bits when generating bytecode for a narrowing conversion
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug exp/18617] Incorrect expression bytecode generated for narrowing conversions
2015-07-01 5:55 [Bug exp/18617] New: Incorrect expression bytecode generated for narrowing conversions robert at ocallahan dot org
2015-07-01 18:38 ` [Bug exp/18617] " khuey at kylehuey dot com
2015-07-01 21:56 ` robert at ocallahan dot org
@ 2015-07-02 14:27 ` palves at redhat dot com
2015-07-03 1:17 ` robert at ocallahan dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: palves at redhat dot com @ 2015-07-02 14:27 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=18617
Pedro Alves <palves at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |palves at redhat dot com
--- Comment #3 from Pedro Alves <palves at redhat dot com> ---
Hi. Thanks for finding and fixing this.
It'd be great if you sent this as a full/finished patch to the patches list.
Then someone can git am/push it.
Please take a look at contribution guidelines in the wiki:
https://sourceware.org/gdb/wiki/ContributionChecklist
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug exp/18617] Incorrect expression bytecode generated for narrowing conversions
2015-07-01 5:55 [Bug exp/18617] New: Incorrect expression bytecode generated for narrowing conversions robert at ocallahan dot org
` (2 preceding siblings ...)
2015-07-02 14:27 ` palves at redhat dot com
@ 2015-07-03 1:17 ` robert at ocallahan dot org
2015-07-08 10:10 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: robert at ocallahan dot org @ 2015-07-03 1:17 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=18617
--- Comment #4 from Robert O'Callahan <robert at ocallahan dot org> ---
https://sourceware.org/ml/gdb-patches/2015-07/msg00089.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug exp/18617] Incorrect expression bytecode generated for narrowing conversions
2015-07-01 5:55 [Bug exp/18617] New: Incorrect expression bytecode generated for narrowing conversions robert at ocallahan dot org
` (3 preceding siblings ...)
2015-07-03 1:17 ` robert at ocallahan dot org
@ 2015-07-08 10:10 ` cvs-commit at gcc dot gnu.org
2015-07-08 10:17 ` cvs-commit at gcc dot gnu.org
2015-07-08 10:20 ` palves at redhat dot com
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-07-08 10:10 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=18617
--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Pedro Alves <palves@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bcf5c1d96b3b5493041002eb2b6d27288d9d160a
commit bcf5c1d96b3b5493041002eb2b6d27288d9d160a
Author: Robert O'Callahan <robert@ocallahan.org>
Date: Wed Jul 8 10:53:36 2015 +0100
PR18617 - Incorrect expression bytecode generated for narrowing conversions
The existing code preserves 'from' bits, which is incorrect. E.g.
(gdb) maint agent-eval (char)255L
Scope: 0x4008d6
Reg mask: 00
0 const16 255
3 ext 64
5 end
'ext 64' should be 'ext 8'; this bytecode evaluates to 255 instead of
the correct result of -1. The fix is simple. I ran the entire test
suite on x86-64 and there were no new test failures.
gdb/ChangeLog:
2015-07-08 Robert O'Callahan <robert@ocallahan.org>
PR exp/18617
* ax-gdb.c (gen_conversion): Extend to 'to' bits, not 'from'.
gdb/testsuite/ChangeLog:
2015-07-08 Robert O'Callahan <robert@ocallahan.org>
PR exp/18617
* gdb.trace/ax.exp: Add test.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug exp/18617] Incorrect expression bytecode generated for narrowing conversions
2015-07-01 5:55 [Bug exp/18617] New: Incorrect expression bytecode generated for narrowing conversions robert at ocallahan dot org
` (4 preceding siblings ...)
2015-07-08 10:10 ` cvs-commit at gcc dot gnu.org
@ 2015-07-08 10:17 ` cvs-commit at gcc dot gnu.org
2015-07-08 10:20 ` palves at redhat dot com
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-07-08 10:17 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=18617
--- Comment #6 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-7.10-branch branch has been updated by Pedro Alves
<palves@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cc1259417e727c47e58cea1bb4a148974689ad8e
commit cc1259417e727c47e58cea1bb4a148974689ad8e
Author: Robert O'Callahan <robert@ocallahan.org>
Date: Wed Jul 8 11:11:22 2015 +0100
PR18617 - Incorrect expression bytecode generated for narrowing conversions
The existing code preserves 'from' bits, which is incorrect. E.g.
(gdb) maint agent-eval (char)255L
Scope: 0x4008d6
Reg mask: 00
0 const16 255
3 ext 64
5 end
'ext 64' should be 'ext 8'; this bytecode evaluates to 255 instead of
the correct result of -1. The fix is simple. I ran the entire test
suite on x86-64 and there were no new test failures.
gdb/ChangeLog:
2015-07-08 Robert O'Callahan <robert@ocallahan.org>
PR exp/18617
* ax-gdb.c (gen_conversion): Extend to 'to' bits, not 'from'.
gdb/testsuite/ChangeLog:
2015-07-08 Robert O'Callahan <robert@ocallahan.org>
PR exp/18617
* gdb.trace/ax.exp: Add test.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug exp/18617] Incorrect expression bytecode generated for narrowing conversions
2015-07-01 5:55 [Bug exp/18617] New: Incorrect expression bytecode generated for narrowing conversions robert at ocallahan dot org
` (5 preceding siblings ...)
2015-07-08 10:17 ` cvs-commit at gcc dot gnu.org
@ 2015-07-08 10:20 ` palves at redhat dot com
6 siblings, 0 replies; 8+ messages in thread
From: palves at redhat dot com @ 2015-07-08 10:20 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=18617
Pedro Alves <palves at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |7.10
--- Comment #7 from Pedro Alves <palves at redhat dot com> ---
Fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-07-08 10:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-01 5:55 [Bug exp/18617] New: Incorrect expression bytecode generated for narrowing conversions robert at ocallahan dot org
2015-07-01 18:38 ` [Bug exp/18617] " khuey at kylehuey dot com
2015-07-01 21:56 ` robert at ocallahan dot org
2015-07-02 14:27 ` palves at redhat dot com
2015-07-03 1:17 ` robert at ocallahan dot org
2015-07-08 10:10 ` cvs-commit at gcc dot gnu.org
2015-07-08 10:17 ` cvs-commit at gcc dot gnu.org
2015-07-08 10:20 ` palves at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).