Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH v1 1/1] sql: remove registerTrace() from mem.c
@ 2021-11-24 12:22 Mergen Imeev via Tarantool-patches
  0 siblings, 0 replies; only message in thread
From: Mergen Imeev via Tarantool-patches @ 2021-11-24 12:22 UTC (permalink / raw)
  To: v.shpilevoy; +Cc: tarantool-patches

This patch changes the way values are displayed in debug information.
---
https://github.com/tarantool/tarantool/issues/3050
https://github.com/tarantool/tarantool/tree/imeevma/gh-3050-drop-registerTrace

 src/box/sql/mem.c  | 119 ---------------------------------------------
 src/box/sql/mem.h  |   3 --
 src/box/sql/vdbe.c |  13 +++--
 3 files changed, 8 insertions(+), 127 deletions(-)

diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
index 530bde615..b7bf5e892 100644
--- a/src/box/sql/mem.c
+++ b/src/box/sql/mem.c
@@ -2595,125 +2595,6 @@ sqlVdbeCheckMemInvariants(Mem * p)
 	}
 	return 1;
 }
-
-/*
- * Write a nice string representation of the contents of cell pMem
- * into buffer zBuf, length nBuf.
- */
-void
-sqlVdbeMemPrettyPrint(Mem *pMem, char *zBuf)
-{
-	char *zCsr = zBuf;
-	int f = pMem->flags;
-
-	if (pMem->type == MEM_TYPE_BIN) {
-		int i;
-		char c;
-		if ((f & MEM_Static) != 0) {
-			c = 't';
-			assert((f & MEM_Ephem) == 0);
-		} else if (f & MEM_Ephem) {
-			c = 'e';
-			assert((f & MEM_Static) == 0);
-		} else {
-			c = 's';
-		}
-
-		sql_snprintf(100, zCsr, "%c", c);
-		zCsr += sqlStrlen30(zCsr);
-		sql_snprintf(100, zCsr, "%d[", pMem->n);
-		zCsr += sqlStrlen30(zCsr);
-		for(i=0; i<16 && i<pMem->n; i++) {
-			sql_snprintf(100, zCsr, "%02X", ((int)pMem->z[i] & 0xFF));
-			zCsr += sqlStrlen30(zCsr);
-		}
-		for(i=0; i<16 && i<pMem->n; i++) {
-			char z = pMem->z[i];
-			if (z<32 || z>126) *zCsr++ = '.';
-			else *zCsr++ = z;
-		}
-		sql_snprintf(100, zCsr, "]%s", "(8)");
-		zCsr += sqlStrlen30(zCsr);
-		*zCsr = '\0';
-	} else if (pMem->type == MEM_TYPE_STR) {
-		int j, k;
-		zBuf[0] = ' ';
-		if ((f & MEM_Static) != 0) {
-			zBuf[1] = 't';
-			assert((f & MEM_Ephem) == 0);
-		} else if (f & MEM_Ephem) {
-			zBuf[1] = 'e';
-			assert((f & MEM_Static) == 0);
-		} else {
-			zBuf[1] = 's';
-		}
-		k = 2;
-		sql_snprintf(100, &zBuf[k], "%d", pMem->n);
-		k += sqlStrlen30(&zBuf[k]);
-		zBuf[k++] = '[';
-		for(j=0; j<15 && j<pMem->n; j++) {
-			u8 c = pMem->z[j];
-			if (c>=0x20 && c<0x7f) {
-				zBuf[k++] = c;
-			} else {
-				zBuf[k++] = '.';
-			}
-		}
-		zBuf[k++] = ']';
-		sql_snprintf(100,&zBuf[k],"(8)");
-		k += sqlStrlen30(&zBuf[k]);
-		zBuf[k++] = 0;
-	}
-}
-
-/*
- * Print the value of a register for tracing purposes:
- */
-static void
-memTracePrint(Mem *p)
-{
-	switch (p->type) {
-	case MEM_TYPE_NULL:
-		printf(" NULL");
-		return;
-	case MEM_TYPE_INT:
-		printf(" i:%lld", p->u.i);
-		return;
-	case MEM_TYPE_UINT:
-		printf(" u:%"PRIu64"", p->u.u);
-		return;
-	case MEM_TYPE_DOUBLE:
-		printf(" r:%g", p->u.r);
-		return;
-	case MEM_TYPE_INVALID:
-		printf(" undefined");
-		return;
-	case MEM_TYPE_BOOL:
-		printf(" bool:%s", SQL_TOKEN_BOOLEAN(p->u.b));
-		return;
-	case MEM_TYPE_UUID:
-		printf(" uuid:%s", tt_uuid_str(&p->u.uuid));
-		return;
-	case MEM_TYPE_DEC:
-		printf(" decimal:%s", decimal_str(&p->u.d));
-		return;
-	default: {
-		char zBuf[200];
-		sqlVdbeMemPrettyPrint(p, zBuf);
-		printf(" %s", zBuf);
-		if ((p->type & (MEM_TYPE_MAP | MEM_TYPE_ARRAY)) != 0)
-			printf(" subtype=0x%02x", SQL_SUBTYPE_MSGPACK);
-		return;
-	}
-	}
-}
-
-void
-registerTrace(int iReg, Mem *p) {
-	printf("REG[%d] = ", iReg);
-	memTracePrint(p);
-	printf("\n");
-}
 #endif
 
 static int
diff --git a/src/box/sql/mem.h b/src/box/sql/mem.h
index e59f8ea44..ba36d17a7 100644
--- a/src/box/sql/mem.h
+++ b/src/box/sql/mem.h
@@ -784,9 +784,6 @@ mem_mp_type(const struct Mem *mem);
 
 #ifdef SQL_DEBUG
 int sqlVdbeCheckMemInvariants(struct Mem *);
-void sqlVdbeMemPrettyPrint(Mem * pMem, char *zBuf);
-void
-registerTrace(int iReg, Mem *p);
 
 /*
  * Return true if a memory cell is not marked as invalid.  This macro
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 0c4e38557..1d68d387f 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -253,7 +253,8 @@ allocateCursor(
 
 #ifdef SQL_DEBUG
 #  define REGISTER_TRACE(P,R,M)					\
-	if(P->sql_flags&SQL_VdbeTrace) registerTrace(R,M);
+	if ((P->sql_flags & SQL_VdbeTrace) != 0)		\
+		printf("REG[%d] = %s\n", R, mem_str(M));
 #else
 #  define REGISTER_TRACE(P,R,M)
 #endif
@@ -4393,11 +4394,13 @@ default: {          /* This is really OP_Noop and OP_Explain */
 		if ((p->sql_flags & SQL_VdbeTrace) != 0) {
 			u8 opProperty = sqlOpcodeProperty[pOrigOp->opcode];
 			if (rc!=0) printf("rc=%d\n",rc);
-			if (opProperty & (OPFLG_OUT2)) {
-				registerTrace(pOrigOp->p2, &aMem[pOrigOp->p2]);
+			if ((opProperty & OPFLG_OUT2) != 0) {
+				REGISTER_TRACE(p, pOrigOp->p2,
+					       &aMem[pOrigOp->p2]);
 			}
-			if (opProperty & OPFLG_OUT3) {
-				registerTrace(pOrigOp->p3, &aMem[pOrigOp->p3]);
+			if ((opProperty & OPFLG_OUT3) != 0) {
+				REGISTER_TRACE(p, pOrigOp->p3,
+					       &aMem[pOrigOp->p3]);
 			}
 		}
 #endif  /* SQL_DEBUG */
-- 
2.25.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-24 12:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 12:22 [Tarantool-patches] [PATCH v1 1/1] sql: remove registerTrace() from mem.c Mergen Imeev via Tarantool-patches

Tarantool development patches archive

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lists.tarantool.org/tarantool-patches/0 tarantool-patches/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tarantool-patches tarantool-patches/ https://lists.tarantool.org/tarantool-patches \
		tarantool-patches@dev.tarantool.org.
	public-inbox-index tarantool-patches

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git