diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-30 15:32:27 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-09-01 12:30:34 +0000 |
commit | 20596907289d50be3a5e1597ba62cefb733e6f19 (patch) | |
tree | 47fb30f65337beb0a5926c75b7e95436b6d886f9 /src | |
parent | 50828bc6ed9112956170a68dffe72431a21fddd9 (diff) |
Add dumping of the raw hex values to the bytecode dumper
Change-Id: I1ddc179fb19983d079872bd59a48e83de7af8494
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/compiler/qv4instr_moth.cpp | 24 | ||||
-rw-r--r-- | src/qml/compiler/qv4instr_moth_p.h | 15 |
2 files changed, 35 insertions, 4 deletions
diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp index c51f604500..940c49c83a 100644 --- a/src/qml/compiler/qv4instr_moth.cpp +++ b/src/qml/compiler/qv4instr_moth.cpp @@ -55,7 +55,7 @@ int Instr::size(Type type) static QByteArray alignedNumber(int n) { QByteArray number = QByteArray::number(n); - while (number.size() < 12) + while (number.size() < 8) number.prepend(' '); return number; } @@ -63,7 +63,23 @@ static QByteArray alignedNumber(int n) { static QByteArray alignedLineNumber(int line) { if (line > 0) return alignedNumber(static_cast<int>(line)); - return QByteArray(" "); + return QByteArray(" "); +} + +static QByteArray rawBytes(const char *data, int n) +{ + QByteArray ba; + while (n) { + uint num = *reinterpret_cast<const uchar *>(data); + if (num < 16) + ba += '0'; + ba += QByteArray::number(num, 16) + " "; + ++data; + --n; + } + while (ba.size() < 25) + ba += ' '; + return ba; } static QString toString(QV4::ReturnedValue v) @@ -90,11 +106,11 @@ static QString toString(QV4::ReturnedValue v) #define MOTH_BEGIN_INSTR(instr) \ { \ - INSTR_##instr(MOTH_DECODE) \ + INSTR_##instr(MOTH_DECODE_WITH_BASE) \ QDebug d = qDebug(); \ d.noquote(); \ d.nospace(); \ - d << alignedLineNumber(line) << alignedNumber(codeOffset).constData() << ": " << #instr << " "; \ + d << alignedLineNumber(line) << alignedNumber(codeOffset).constData() << ": " << rawBytes(base_ptr, code - base_ptr) << #instr << " "; \ #define MOTH_END_INSTR(instr) \ continue; \ diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index a90954eaea..c70440fedd 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -360,6 +360,21 @@ QT_BEGIN_NAMESPACE op_main_##name: \ ; \ +#define MOTH_DECODE_WITH_BASE_INSTRUCTION(name, nargs, ...) \ + MOTH_DEFINE_ARGS(nargs, __VA_ARGS__) \ + const char *base_ptr; \ + op_int_##name: \ + base_ptr = code; \ + MOTH_ADJUST_CODE(int, nargs); \ + MOTH_DECODE_ARGS(name, int, nargs, __VA_ARGS__) \ + goto op_main_##name; \ + op_char_##name: \ + base_ptr = code; \ + MOTH_ADJUST_CODE(char, nargs); \ + MOTH_DECODE_ARGS(name, char, nargs, __VA_ARGS__) \ + op_main_##name: \ + ; \ + #define MOTH_DECODE_ARGS(name, type, nargs, ...) \ MOTH_DECODE_ARGS##nargs(name, type, nargs, __VA_ARGS__) |