aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-09-13 12:56:06 +0200
committerBjörn Gustavsson <[email protected]>2017-09-14 10:23:17 +0200
commit4bf642e54bca72d77b64af4409a13188dd5c7378 (patch)
tree5ef6a1cd9b7b6ec4c0a6fcd9cb6c501625bbbd50
parentddaed7774eb0a3bbaf6ee40153d2b082181a1223 (diff)
downloadotp-4bf642e54bca72d77b64af4409a13188dd5c7378.tar.gz
otp-4bf642e54bca72d77b64af4409a13188dd5c7378.tar.bz2
otp-4bf642e54bca72d77b64af4409a13188dd5c7378.zip
Correct disassembly of select instructions
Make sure to use the 'unpacked[-1]' when accessing the unpacked arguments.
-rw-r--r--erts/emulator/beam/beam_debug.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/erts/emulator/beam/beam_debug.c b/erts/emulator/beam/beam_debug.c
index afde45ba71..7017656476 100644
--- a/erts/emulator/beam/beam_debug.c
+++ b/erts/emulator/beam/beam_debug.c
@@ -629,13 +629,20 @@ print_op(fmtfn_t to, void *to_arg, int op, int size, BeamInstr* addr)
unpacked = ap;
ap = addr + size;
+
+ /*
+ * In the code below, never use ap[-1], ap[-2], ...
+ * (will not work if the arguments have been packed).
+ *
+ * Instead use unpacked[-1], unpacked[-2], ...
+ */
switch (op) {
case op_i_select_val_lins_xfI:
case op_i_select_val_lins_yfI:
case op_i_select_val_bins_xfI:
case op_i_select_val_bins_yfI:
{
- int n = ap[-1];
+ int n = unpacked[-1];
int ix = n;
Sint32* jump_tab = (Sint32 *)(ap + n);
@@ -656,7 +663,7 @@ print_op(fmtfn_t to, void *to_arg, int op, int size, BeamInstr* addr)
case op_i_select_tuple_arity_xfI:
case op_i_select_tuple_arity_yfI:
{
- int n = ap[-1];
+ int n = unpacked[-1];
int ix = n - 1; /* without sentinel */
Sint32* jump_tab = (Sint32 *)(ap + n);
@@ -698,7 +705,7 @@ print_op(fmtfn_t to, void *to_arg, int op, int size, BeamInstr* addr)
case op_i_jump_on_val_xfIW:
case op_i_jump_on_val_yfIW:
{
- int n = ap[-2];
+ int n = unpacked[-2];
Sint32* jump_tab = (Sint32 *) ap;
size += (n+1) / 2;
@@ -712,7 +719,7 @@ print_op(fmtfn_t to, void *to_arg, int op, int size, BeamInstr* addr)
case op_i_jump_on_val_zero_xfI:
case op_i_jump_on_val_zero_yfI:
{
- int n = ap[-1];
+ int n = unpacked[-1];
Sint32* jump_tab = (Sint32 *) ap;
size += (n+1) / 2;