From db193ba5dac15b1341a622307adbaf55002531b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= <egil@erlang.org>
Date: Wed, 17 Jun 2015 11:23:11 +0200
Subject: erts: Fix erts_debug:df/1 in debug

Sentinels in select_tuple_arity instructions are not proper
tuple arities and thus cannot be checked in debug.
Print them as small integers instead.
---
 erts/emulator/beam/beam_debug.c | 40 ++++++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 18 deletions(-)

(limited to 'erts')

diff --git a/erts/emulator/beam/beam_debug.c b/erts/emulator/beam/beam_debug.c
index 0367ca8aba..78ddecafc3 100644
--- a/erts/emulator/beam/beam_debug.c
+++ b/erts/emulator/beam/beam_debug.c
@@ -616,24 +616,28 @@ print_op(int to, void *to_arg, int op, int size, BeamInstr* addr)
     case op_i_select_tuple_arity_rfI:
     case op_i_select_tuple_arity_xfI:
     case op_i_select_tuple_arity_yfI:
-	{
-	    int n = ap[-1];
-	    int ix = n;
-
-	    while (ix--) {
-		Uint arity = arityval(ap[0]);
-		erts_print(to, to_arg, "{%d} ", arity, ap[1]);
-		ap++;
-		size++;
-	    }
-	    ix = n;
-	    while (ix--) {
-		erts_print(to, to_arg, "f(" HEXF ") ", ap[0]);
-		ap++;
-		size++;
-	    }
-	}
-	break;
+        {
+            int n = ap[-1];
+            int ix = n - 1; /* without sentinel */
+
+            while (ix--) {
+                Uint arity = arityval(ap[0]);
+                erts_print(to, to_arg, "{%d} ", arity, ap[1]);
+                ap++;
+                size++;
+            }
+            /* print sentinel */
+            erts_print(to, to_arg, "{%T} ", ap[0], ap[1]);
+            ap++;
+            size++;
+            ix = n;
+            while (ix--) {
+                erts_print(to, to_arg, "f(" HEXF ") ", ap[0]);
+                ap++;
+                size++;
+            }
+        }
+        break;
     case op_i_jump_on_val_rfII:
     case op_i_jump_on_val_xfII:
     case op_i_jump_on_val_yfII:
-- 
cgit v1.2.3