From 91c6c2ec21d91942c9286983d318845ba0854ae5 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Mon, 8 Jul 2013 23:21:36 -0400 Subject: [PATCH] Debugger: fix value reading problem. When reading a variable value from a register, if the value's size is smaller than the size of the register and the architecture is little endian, we need to adjust the bit offset we read from in addition to byte swapping, otherwise we wind up reading the wrong bytes. This was mainly noticeable in the case of functions that returned boolean values, which would consequently sometimes show up incorrectly. --- src/apps/debugger/value/ValueLoader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/apps/debugger/value/ValueLoader.cpp b/src/apps/debugger/value/ValueLoader.cpp index 81b7bfb22e..19f313669a 100644 --- a/src/apps/debugger/value/ValueLoader.cpp +++ b/src/apps/debugger/value/ValueLoader.cpp @@ -1,5 +1,6 @@ /* * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Copyright 2013, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -178,8 +179,10 @@ ValueLoader::LoadValue(ValueLocation* location, type_code valueType, if (registerValue.Size() < bytesToRead) return B_ENTRY_NOT_FOUND; - if (!bigEndian) + if (!bigEndian) { registerValue.SwapEndianess(); + bitOffset = registerValue.Size() * 8 - bitOffset - bitSize; + } valueBuffer.AddBits(registerValue.Bytes(), bitSize, bitOffset); break; }