From aa5055ced3d2b3258b8556dba6a5a77776dc9e11 Mon Sep 17 00:00:00 2001
From: Jason Volk <jason@zemos.net>
Date: Thu, 11 Apr 2019 03:55:51 -0700
Subject: [PATCH] modules/console: Use pretty(iec(bytes)) for ctx list stack
 sizes.

---
 modules/console.cc | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/modules/console.cc b/modules/console.cc
index e8ea4db85..4730747ee 100644
--- a/modules/console.cc
+++ b/modules/console.cc
@@ -1544,27 +1544,27 @@ console_cmd__ctx__list(opt &out, const string_view &line)
 	    << std::setw(7)
 	    << "STATE"
 	    << " "
+	    << std::setw(8)
+	    << "YIELDS"
+	    << " "
+	    << std::setw(5)
+	    << "NOTES"
+	    << " "
 	    << std::setw(15)
 	    << "CYCLE COUNT"
 	    << " "
 	    << std::setw(6)
 	    << "PCT"
 	    << " "
-	    << std::setw(7)
+	    << std::setw(25)
 	    << "STACK"
 	    << " "
-	    << std::setw(7)
+	    << std::setw(25)
 	    << "LIMIT"
 	    << " "
 	    << std::setw(6)
 	    << "PCT"
 	    << " "
-	    << std::setw(8)
-	    << "YIELDS"
-	    << " "
-	    << std::setw(5)
-	    << "NOTES"
-	    << " "
 	    << ":NAME"
 	    << std::endl;
 
@@ -1583,6 +1583,12 @@ console_cmd__ctx__list(opt &out, const string_view &line)
 		    << (running(ctx)? 'R' : '-')
 		    ;
 
+		out << " "
+		    << std::setw(8) << std::right << yields(ctx);
+
+		out << " "
+		    << std::setw(5) << std::right << notes(ctx);
+
 		out << " "
 		    << std::setw(15) << std::right << cycles(ctx);
 
@@ -1596,11 +1602,12 @@ console_cmd__ctx__list(opt &out, const string_view &line)
 		    << std::setw(5) << std::right << std::fixed << std::setprecision(2) << (tsc_pct * 100)
 		    << "%";
 
+		thread_local char pbuf[32];
 		out << " "
-		    << std::setw(7) << std::right << stack_at(ctx);
+		    << std::setw(25) << std::right << pretty(pbuf, iec(stack_at(ctx)));
 
 		out << " "
-		    << std::setw(7) << std::right << stack_max(ctx);
+		    << std::setw(25) << std::right << pretty(pbuf, iec(stack_max(ctx)));
 
 		const auto stack_pct
 		{
@@ -1611,12 +1618,6 @@ console_cmd__ctx__list(opt &out, const string_view &line)
 		    << std::setw(5) << std::right << std::fixed << std::setprecision(2) << (stack_pct * 100)
 		    << "%";
 
-		out << " "
-		    << std::setw(8) << std::right << yields(ctx);
-
-		out << " "
-		    << std::setw(5) << std::right << notes(ctx);
-
 		out << " :"
 		    << name(ctx);