Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Robert Dubner <rdubner@symas.com>
To: gdb-patches@sourceware.org
Cc: stephan.rohr@intel.com
Subject: [PATCH v2 2/2] gdb: Preserve subnormal values in target floating-point operations
Date: Mon,  9 Nov 2026 16:24:50 -0500	[thread overview]
Message-ID: <20261109212450.3137464-3-rdubner@symas.com> (raw)
In-Reply-To: <20261109212450.3137464-1-rdubner@symas.com>

The MPFR encoder can flush representable subnormal values to zero or
encode their significands incorrectly.

Encode subnormals with a zero exponent field and align their fractions
to the minimum normal exponent. Discard the implicit leading bit only
for normal values.

Carry MPFR's ternary results through parsing, conversions, and arithmetic
to avoid double rounding. Temporarily adjust the minimum exponent while
rounding, restoring it afterward. Preserve flush-to-zero behavior for
formats without subnormal support.

Explain the subnormal boundary, minimum-exponent calculation, and
significand scaling.

Add unit tests in target-float.c covering both byte orders, exact
subnormals, rounding boundaries, narrowing conversions, arithmetic,
explicit integer bits, and restoration of MPFR's exponent range.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34927
---
 gdb/target-float.c | 308 +++++++++++++++++++++++++++++++++++++++------
 1 file changed, 272 insertions(+), 36 deletions(-)

diff --git a/gdb/target-float.c b/gdb/target-float.c
index 8032d4b7738..080b79d455c 100644
--- a/gdb/target-float.c
+++ b/gdb/target-float.c
@@ -21,8 +21,13 @@
 #include "floatformat.h"
 #include "target-float.h"
 #include "gdbarch.h"
+#include "gdbsupport/scope-exit.h"
 #include "gdbsupport/selftest.h"
 
+#if GDB_SELF_TEST
+#include "arch-utils.h"
+#endif
+
 /* Target floating-point operations.
 
    We provide multiple implementations of those operations, which differ
@@ -1218,10 +1223,12 @@ class mpfr_float_ops : public target_float_ops
   void from_target (const struct type *type,
 		const gdb_byte *from, gdb_mpfr &to) const;
 
+  /* INEXACT is the MPFR ternary result of the computation producing FROM.
+     Carry it into subnormal rounding to avoid rounding twice.  */
   void to_target (const struct type *type,
-		  const gdb_mpfr &from, gdb_byte *to) const;
+		  const gdb_mpfr &from, gdb_byte *to, int inexact = 0) const;
   void to_target (const struct floatformat *fmt,
-		  const gdb_mpfr &from, gdb_byte *to) const;
+		  const gdb_mpfr &from, gdb_byte *to, int inexact = 0) const;
 };
 
 
@@ -1344,12 +1351,14 @@ mpfr_float_ops::from_target (const struct type *type,
 
 void
 mpfr_float_ops::to_target (const struct floatformat *fmt,
-			   const gdb_mpfr &from, gdb_byte *orig_to) const
+			   const gdb_mpfr &from, gdb_byte *orig_to,
+			   int inexact) const
 {
   unsigned char *to = orig_to;
   mpfr_exp_t exponent;
   unsigned int mant_bits, mant_off;
   int mant_bits_left;
+  bool subnormal;
   enum floatformat_byteorders order = fmt->byteorder;
   unsigned char newto[FLOATFORMAT_LARGEST_BYTES];
 
@@ -1402,8 +1411,37 @@ mpfr_float_ops::to_target (const struct floatformat *fmt,
     {
       put_field (to, order, fmt->totalsize, fmt->sign_start, 1, 1);
       mpfr_neg (tmp.val, tmp.val, MPFR_RNDN);
+      inexact = -inexact;
+    }
+
+  /* MPFR represents a nonzero finite value as M * 2^E, where
+     0.5 <= abs (M) < 1.  The smallest normal target value is
+     2^(1 - exp_bias), so its MPFR exponent is 2 - exp_bias.
+     Smaller exponents (E + exp_bias <= 1) require subnormal rounding.
+     Formats without an infinity/NaN exponent do not support subnormals.  */
+  if (!mpfr_inf_p (tmp.val) && fmt->exp_nan != 0
+      && mpfr_get_exp (tmp.val) + fmt->exp_bias <= 1)
+    {
+      mpfr_exp_t saved_emin = mpfr_get_emin ();
+      SCOPE_EXIT
+	{
+	  mpfr_set_emin (saved_emin);
+	};
+
+      /* With precision P, the least subnormal is
+	 2^(1 - exp_bias - (P - 1)).  MPFR's exponent is one greater
+	 than the power of two, giving emin = 3 - exp_bias - P.
+	 Restrict the range only while rounding: the encoding below needs
+	 intermediates outside the target's range (e.g. for binary16).
+	 Use the operation's ternary result to avoid double rounding.  */
+      mpfr_set_emin (3 - fmt->exp_bias - floatformat_precision (fmt));
+      inexact = mpfr_check_range (tmp.val, inexact, MPFR_RNDN);
+      mpfr_subnormalize (tmp.val, inexact, MPFR_RNDN);
     }
 
+  if (mpfr_zero_p (tmp.val))
+    goto finalize_byteorder;
+
   if (mpfr_inf_p (tmp.val))		/* Result is Infinity.  */
     {
       /* Infinity exponent is same as NaN's.  */
@@ -1417,14 +1455,24 @@ mpfr_float_ops::to_target (const struct floatformat *fmt,
 
   mpfr_frexp (&exponent, tmp.val, tmp.val, MPFR_RNDN);
 
-  if (exponent + fmt->exp_bias <= 0)
+  subnormal = fmt->exp_nan != 0 && exponent + fmt->exp_bias <= 1;
+  if (subnormal)
     {
-      /* The value is too small to be expressed in the destination
-	 type (not enough bits in the exponent.  Treat as 0.  */
-      put_field (to, order, fmt->totalsize, fmt->exp_start,
-		 fmt->exp_len, 0);
-      put_field (to, order, fmt->totalsize, fmt->man_start,
-		 fmt->man_len, 0);
+      /* Subnormals use the minimum normal exponent, but have no leading
+	 one.  Scale the fraction returned by mpfr_frexp to that exponent,
+	 leaving the leading zero explicit, even for formats with an
+	 implicit integer bit.  The loop below extracts successive 32-bit
+	 chunks of this fraction.  An explicit integer bit occupies its
+	 first bit, so shift one place further right for those formats.  */
+      mpfr_mul_2si (tmp.val, tmp.val,
+		    exponent + fmt->exp_bias
+		    - (fmt->intbit == floatformat_intbit_no ? 1 : 2),
+		    MPFR_RNDN);
+    }
+  else if (exponent + fmt->exp_bias <= 0)
+    {
+      /* Formats without subnormals flush values that are too small to
+	 represent to zero.  The exponent and mantissa are already zero.  */
       goto finalize_byteorder;
     }
 
@@ -1440,7 +1488,7 @@ mpfr_float_ops::to_target (const struct floatformat *fmt,
     }
 
   put_field (to, order, fmt->totalsize, fmt->exp_start, fmt->exp_len,
-	     exponent + fmt->exp_bias - 1);
+	     subnormal ? 0 : exponent + fmt->exp_bias - 1);
 
   mant_bits_left = fmt->man_len;
   mant_off = fmt->man_start;
@@ -1454,11 +1502,8 @@ mpfr_float_ops::to_target (const struct floatformat *fmt,
       mant_long = mpfr_get_ui (tmp.val, MPFR_RNDZ) & 0xffffffffL;
       mpfr_sub_ui (tmp.val, tmp.val, mant_long, MPFR_RNDZ);
 
-      /* If the integer bit is implicit, then we need to discard it.
-	 If we are discarding a zero, we should be (but are not) creating
-	 a denormalized number which means adjusting the exponent
-	 (I think).  */
-      if (mant_bits_left == fmt->man_len
+      /* Only normal values have an implicit leading one to discard.  */
+      if (!subnormal && mant_bits_left == fmt->man_len
 	  && fmt->intbit == floatformat_intbit_no)
 	{
 	  mant_long <<= 1;
@@ -1495,12 +1540,12 @@ mpfr_float_ops::to_target (const struct floatformat *fmt,
 
 void
 mpfr_float_ops::to_target (const struct type *type,
-			   const gdb_mpfr &from, gdb_byte *to) const
+			   const gdb_mpfr &from, gdb_byte *to, int inexact) const
 {
   /* Ensure possible padding bytes in the target buffer are zeroed out.  */
   memset (to, 0, type->length ());
 
-  to_target (floatformat_from_type (type), from, to);
+  to_target (floatformat_from_type (type), from, to, inexact);
 }
 
 /* Convert the byte-stream ADDR, interpreted as floating-point type TYPE,
@@ -1558,13 +1603,13 @@ mpfr_float_ops::from_string (gdb_byte *addr,
   gdb_mpfr tmp (type);
 
   char *endptr;
-  mpfr_strtofr (tmp.val, in.c_str (), &endptr, 0, MPFR_RNDN);
+  int inexact = mpfr_strtofr (tmp.val, in.c_str (), &endptr, 0, MPFR_RNDN);
 
   /* We only accept the whole string.  */
   if (*endptr)
     return false;
 
-  to_target (type, tmp, addr);
+  to_target (type, tmp, addr, inexact);
   return true;
 }
 
@@ -1587,8 +1632,8 @@ mpfr_float_ops::from_longest (gdb_byte *addr,
 			      LONGEST val) const
 {
   gdb_mpfr tmp (type);
-  mpfr_set_sj (tmp.val, val, MPFR_RNDN);
-  to_target (type, tmp, addr);
+  int inexact = mpfr_set_sj (tmp.val, val, MPFR_RNDN);
+  to_target (type, tmp, addr, inexact);
 }
 
 /* Convert unsigned integer VAL to a target floating-number of type TYPE
@@ -1599,8 +1644,8 @@ mpfr_float_ops::from_ulongest (gdb_byte *addr,
 			       ULONGEST val) const
 {
   gdb_mpfr tmp (type);
-  mpfr_set_uj (tmp.val, val, MPFR_RNDN);
-  to_target (type, tmp, addr);
+  int inexact = mpfr_set_uj (tmp.val, val, MPFR_RNDN);
+  to_target (type, tmp, addr, inexact);
 }
 
 /* Convert the byte-stream ADDR, interpreted as floating-point type TYPE,
@@ -1622,8 +1667,8 @@ mpfr_float_ops::from_host_double (gdb_byte *addr,
 				  double val) const
 {
   gdb_mpfr tmp (type);
-  mpfr_set_d (tmp.val, val, MPFR_RNDN);
-  to_target (type, tmp, addr);
+  int inexact = mpfr_set_d (tmp.val, val, MPFR_RNDN);
+  to_target (type, tmp, addr, inexact);
 }
 
 /* Convert a floating-point number of type FROM_TYPE from the target
@@ -1637,8 +1682,8 @@ mpfr_float_ops::convert (const gdb_byte *from,
 {
   gdb_mpfr from_tmp (from_type), to_tmp (to_type);
   from_target (from_type, from, from_tmp);
-  mpfr_set (to_tmp.val, from_tmp.val, MPFR_RNDN);
-  to_target (to_type, to_tmp, to);
+  int inexact = mpfr_set (to_tmp.val, from_tmp.val, MPFR_RNDN);
+  to_target (to_type, to_tmp, to, inexact);
 }
 
 /* Perform the binary operation indicated by OPCODE, using as operands the
@@ -1656,34 +1701,35 @@ mpfr_float_ops::binop (enum exp_opcode op,
   from_target (type_x, x, x_tmp);
   from_target (type_y, y, y_tmp);
 
+  int inexact;
   switch (op)
     {
       case BINOP_ADD:
-	mpfr_add (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
+	inexact = mpfr_add (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
 	break;
 
       case BINOP_SUB:
-	mpfr_sub (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
+	inexact = mpfr_sub (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
 	break;
 
       case BINOP_MUL:
-	mpfr_mul (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
+	inexact = mpfr_mul (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
 	break;
 
       case BINOP_DIV:
-	mpfr_div (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
+	inexact = mpfr_div (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
 	break;
 
       case BINOP_EXP:
-	mpfr_pow (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
+	inexact = mpfr_pow (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
 	break;
 
       case BINOP_MIN:
-	mpfr_min (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
+	inexact = mpfr_min (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
 	break;
 
       case BINOP_MAX:
-	mpfr_max (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
+	inexact = mpfr_max (tmp.val, x_tmp.val, y_tmp.val, MPFR_RNDN);
 	break;
 
       default:
@@ -1691,7 +1737,7 @@ mpfr_float_ops::binop (enum exp_opcode op,
 	break;
     }
 
-  to_target (type_res, tmp, res);
+  to_target (type_res, tmp, res, inexact);
 }
 
 /* Compare the two target byte streams X and Y, interpreted as floating-point
@@ -2555,6 +2601,190 @@ put_field_test ()
     }
 }
 
+/* Exercise the MPFR implementation directly, independently of the host's
+   floating-point formats.  Each pair contains big- and little-endian forms.  */
+
+static const floatformat *const subnormal_formats[][2] =
+  {
+    {&floatformat_ieee_half_big, &floatformat_ieee_half_little},
+    {&floatformat_ieee_single_big, &floatformat_ieee_single_little},
+    {&floatformat_ieee_double_big, &floatformat_ieee_double_little},
+    {&floatformat_ieee_quad_big, &floatformat_ieee_quad_little}
+  };
+
+static type *
+subnormal_type (const floatformat *fmt)
+{
+  /* Supply FMT in both slots so it can be selected independently of the
+     architecture's byte order.  init_float_type retains only that format.  */
+  const floatformat *pair[] = {fmt, fmt};
+  type_allocator alloc (get_current_arch ());
+  return init_float_type (alloc, -1, "selftest_float", pair, BFD_ENDIAN_BIG);
+}
+
+/* Encode integer BITS independently of the floating-point encoder.  */
+
+static std::vector<gdb_byte>
+subnormal_bytes (const gdb_mpz &bits, const type *ftype)
+{
+  std::vector<gdb_byte> bytes (ftype->length ());
+  bfd_endian order = floatformat_from_type (ftype)->byteorder == floatformat_big
+		     ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
+  bits.write (bytes, order, true);
+  return bytes;
+}
+
+/* Spell COEFFICIENT * 2^EXPONENT exactly, without host floating-point math.  */
+
+static std::string
+subnormal_string (const gdb_mpz &coefficient, int exponent)
+{
+  return coefficient.hex () + "p" + std::to_string (exponent);
+}
+
+/* Check exact subnormals, text round trips, byte-order conversion, and the
+   boundary between normal and subnormal arithmetic.  */
+
+static void
+subnormal_test ()
+{
+  mpfr_float_ops ops;
+  for (const auto &formats : subnormal_formats)
+    for (int endian = 0; endian < 2; ++endian)
+      {
+	const floatformat *fmt = formats[endian];
+	type *ftype = subnormal_type (fmt);
+	type *opposite = subnormal_type (formats[1 - endian]);
+	int quantum = 1 - fmt->exp_bias - (int) fmt->man_len;
+	gdb_mpz normal = gdb_mpz (1) << fmt->man_len;
+	gdb_mpz sign = gdb_mpz (1) << (fmt->totalsize - 1);
+	for (const gdb_mpz &magnitude : {gdb_mpz (1), gdb_mpz (2),
+				       normal - gdb_mpz (1), normal})
+	  for (bool negative : {false, true})
+	    {
+	      gdb_mpz bits = negative ? magnitude | sign : magnitude;
+	      auto expected = subnormal_bytes (bits, ftype);
+	      std::vector<gdb_byte> actual (ftype->length ());
+	      std::string text = subnormal_string (magnitude, quantum);
+	      if (negative)
+		text.insert (0, "-");
+	      SELF_CHECK (ops.from_string (actual.data (), ftype, text));
+	      SELF_CHECK (actual == expected);
+	      text = ops.to_string (expected.data (), ftype, nullptr);
+	      SELF_CHECK (ops.from_string (actual.data (), ftype, text));
+	      SELF_CHECK (actual == expected);
+	      ops.convert (expected.data (), ftype, actual.data (), opposite);
+	      SELF_CHECK (actual == subnormal_bytes (bits, opposite));
+	    }
+
+	auto least = subnormal_bytes (gdb_mpz (1), ftype);
+	auto largest = subnormal_bytes (normal - gdb_mpz (1), ftype);
+	auto minimum = subnormal_bytes (normal, ftype);
+	std::vector<gdb_byte> actual (ftype->length ());
+	ops.binop (BINOP_SUB, minimum.data (), ftype, least.data (), ftype,
+		   actual.data (), ftype);
+	SELF_CHECK (actual == largest);
+	ops.binop (BINOP_ADD, largest.data (), ftype, least.data (), ftype,
+		   actual.data (), ftype);
+	SELF_CHECK (actual == minimum);
+      }
+}
+
+/* Test halfway values and both sides of each tie, including digits lost by
+   rounding to normal precision before subnormal rounding.  Expected results
+   follow round-to-nearest, ties-to-even, without using MPFR as an oracle.  */
+
+static void
+subnormal_rounding_test ()
+{
+  mpfr_float_ops ops;
+  mpfr_exp_t saved_emin = mpfr_get_emin (), saved_emax = mpfr_get_emax ();
+  for (const auto &formats : subnormal_formats)
+    for (const floatformat *fmt : formats)
+      {
+	type *ftype = subnormal_type (fmt);
+	type *wide = subnormal_type (&floatformat_ieee_quad_big);
+	int quantum = 1 - fmt->exp_bias - (int) fmt->man_len;
+	int tail = fmt->man_len + 9;
+	gdb_mpz normal = gdb_mpz (1) << fmt->man_len;
+	gdb_mpz sign = gdb_mpz (1) << (fmt->totalsize - 1);
+	for (const gdb_mpz &lower : {gdb_mpz (0), gdb_mpz (1), gdb_mpz (2),
+				   normal - gdb_mpz (1)})
+	  for (int side : {-1, 0, 1})
+	    for (bool negative : {false, true})
+	      {
+		gdb_mpz coefficient = ((lower * gdb_mpz (2) + 1) << (tail - 1))
+				       + gdb_mpz (side);
+		gdb_mpz expected = lower;
+		if (side > 0 || (side == 0 && (lower & gdb_mpz (1)) == 1))
+		  expected += 1;
+		if (negative)
+		  expected = expected | sign;
+		auto bytes = subnormal_bytes (expected, ftype);
+		std::string text
+		  = subnormal_string (coefficient, quantum - tail);
+		if (negative)
+		  text.insert (0, "-");
+		std::vector<gdb_byte> actual (ftype->length ());
+		SELF_CHECK (ops.from_string (actual.data (), ftype, text));
+		SELF_CHECK (actual == bytes);
+
+		/* Binary128 represents these binary16/32/64 cases exactly.
+		   Check the ternary result from narrowing and each operation,
+		   as well as parsing directly at the destination precision.  */
+		if (fmt->man_len < floatformat_ieee_quad_big.man_len)
+		  {
+		    std::vector<gdb_byte> source (wide->length ());
+		    SELF_CHECK (ops.from_string (source.data (), wide, text));
+		    ops.convert (source.data (), wide, actual.data (), ftype);
+		    SELF_CHECK (actual == bytes);
+		    for (exp_opcode op : {BINOP_ADD, BINOP_SUB, BINOP_MUL,
+					  BINOP_DIV, BINOP_EXP, BINOP_MIN, BINOP_MAX})
+		      {
+			std::vector<gdb_byte> right (wide->length ());
+			LONGEST rhs = op == BINOP_ADD || op == BINOP_SUB ? 0
+				      : op == BINOP_MAX ? -1 : 1;
+			ops.from_longest (right.data (), wide, rhs);
+			ops.binop (op, source.data (), wide, right.data (), wide,
+				   actual.data (), ftype);
+			SELF_CHECK (actual == bytes);
+		      }
+		  }
+		SELF_CHECK (mpfr_get_emin () == saved_emin);
+		SELF_CHECK (mpfr_get_emax () == saved_emax);
+	      }
+      }
+}
+
+/* Also check encoding with explicit integer bits and preserve the existing
+   flush-to-zero policy of formats without subnormal support.  */
+
+static void
+subnormal_other_formats_test ()
+{
+  mpfr_float_ops ops;
+  for (const floatformat *fmt : {&floatformat_i387_ext,
+				&floatformat_m68881_ext})
+    {
+      type *ftype = subnormal_type (fmt);
+      std::vector<gdb_byte> actual (ftype->length ());
+      std::vector<gdb_byte> expected (ftype->length ());
+      expected[fmt->byteorder == floatformat_little ? 0 : 11] = 1;
+      int quantum = 2 - fmt->exp_bias - floatformat_precision (fmt);
+      SELF_CHECK (ops.from_string (actual.data (), ftype,
+				   subnormal_string (gdb_mpz (1), quantum)));
+      SELF_CHECK (actual == expected);
+    }
+
+  type *ftype = subnormal_type (&floatformat_vax_f);
+  std::vector<gdb_byte> actual (ftype->length ());
+  std::vector<gdb_byte> zero (ftype->length ());
+  SELF_CHECK (ops.from_string (actual.data (), ftype, "0x1p-200"));
+  SELF_CHECK (actual == zero);
+  SELF_CHECK (ops.from_string (actual.data (), ftype, "0.125"));
+  SELF_CHECK (actual == std::vector<gdb_byte> ({0, 0x3f, 0, 0}));
+}
+
 } /* namespace selftests */
 #endif /* GDB_SELF_TEST */
 
@@ -2563,5 +2793,11 @@ INIT_GDB_FILE (target_float)
 #if GDB_SELF_TEST
   selftests::register_test ("target-float-put-field",
 			   selftests::put_field_test);
+  selftests::register_test ("target-float-subnormal",
+			   selftests::subnormal_test);
+  selftests::register_test ("target-float-subnormal-rounding",
+			   selftests::subnormal_rounding_test);
+  selftests::register_test ("target-float-subnormal-other-formats",
+			   selftests::subnormal_other_formats_test);
 #endif
 }
-- 
2.34.1


  parent reply	other threads:[~2026-11-09 21:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 21:24 [PATCH v2 0/2] gdb: Fix floating-point field writes and subnormal results Robert Dubner
2026-11-09 21:24 ` [PATCH v2 1/2] gdb: Preserve neighboring bits when writing floating-point fields Robert Dubner
2026-11-10 10:23   ` Rohr, Stephan
2026-11-11  4:03     ` Robert Dubner
2026-11-09 21:24 ` Robert Dubner [this message]
2026-11-10 10:40   ` [PATCH v2 2/2] gdb: Preserve subnormal values in target floating-point operations Rohr, Stephan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261109212450.3137464-3-rdubner@symas.com \
    --to=rdubner@symas.com \
    --cc=gdb-patches@sourceware.org \
    --cc=stephan.rohr@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox