Summary: | Incorrect expression bytecode generated for narrowing conversions | ||
---|---|---|---|
Product: | gdb | Reporter: | Robert O'Callahan <robert> |
Component: | exp | Assignee: | Robert O'Callahan <robert> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | khuey, pedro |
Priority: | P2 | ||
Version: | 7.9 | ||
Target Milestone: | 7.10 | ||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Attachments: | preserve 'to' bits when generating bytecode for a narrowing conversion |
Description
Robert O'Callahan
2015-07-01 05:55:41 UTC
Your testcase WFM on gdb 7.7. Created attachment 8406 [details]
preserve 'to' bits when generating bytecode for a narrowing conversion
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 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. 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. Fixed. |