mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-29 10:30:46 +00:00
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.
This commit is contained in:
committed by
Pedro Alves
parent
e8643a4533
commit
bcf5c1d96b
@@ -885,7 +885,7 @@ gen_conversion (struct agent_expr *ax, struct type *from, struct type *to)
|
||||
/* 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);
|
||||
gen_extend (ax, to);
|
||||
|
||||
/* If the two values have equal width, but different signednesses,
|
||||
then we need to extend. */
|
||||
|
||||
Reference in New Issue
Block a user