Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Unified Diff: runtime/vm/disassembler_ia32.cc

Issue 2748023003: Sign extend correctly in disassembler (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/disassembler_x64.cc » ('j') | runtime/vm/disassembler_x64.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/disassembler_ia32.cc
diff --git a/runtime/vm/disassembler_ia32.cc b/runtime/vm/disassembler_ia32.cc
index 004ed60f8e721fb5f18d34eb37bfa7c632ca9532..90957ce1886a1134b0b78b2b108765bef69d7148 100644
--- a/runtime/vm/disassembler_ia32.cc
+++ b/runtime/vm/disassembler_ia32.cc
@@ -325,7 +325,7 @@ class X86Decoder : public ValueObject {
// Bottleneck functions to print into the out_buffer.
void PrintInt(int value);
- void PrintHex(int value);
+ void PrintHex(int value, bool signed_value = false);
void Print(const char* str);
const char* GetBranchPrefix(uint8_t** data);
@@ -401,9 +401,13 @@ void X86Decoder::PrintInt(int value) {
// Append the int value (printed in hex) to the output buffer.
-void X86Decoder::PrintHex(int value) {
+void X86Decoder::PrintHex(int value, bool signed_value) {
char hex_buffer[16];
- OS::SNPrint(hex_buffer, sizeof(hex_buffer), "%#x", value);
+ if (signed_value && value < 0) {
+ OS::SNPrint(hex_buffer, sizeof(hex_buffer), "-%#x", -value);
+ } else {
+ OS::SNPrint(hex_buffer, sizeof(hex_buffer), "%#x", value);
+ }
Print(hex_buffer);
}
@@ -685,7 +689,7 @@ int X86Decoder::PrintImmediateOp(uint8_t* data, bool size_override) {
PrintHex(*reinterpret_cast<int16_t*>(data + 1 + count));
return 1 + count + 2 /*int16_t*/;
} else if (sign_extension_bit) {
- PrintHex(*(data + 1 + count));
+ PrintHex(*reinterpret_cast<int8_t*>(data + 1 + count), sign_extension_bit);
return 1 + count + 1 /*int8_t*/;
} else {
PrintHex(*reinterpret_cast<int32_t*>(data + 1 + count));
« no previous file with comments | « no previous file | runtime/vm/disassembler_x64.cc » ('j') | runtime/vm/disassembler_x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698