Change in simtrace2[master]: implement minimalistic talloc_report(); add 't' command on UART

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sat Dec 14 22:30:59 UTC 2019


laforge has submitted this change. ( https://gerrit.osmocom.org/c/simtrace2/+/16580 )

Change subject: implement minimalistic talloc_report(); add 't' command on UART
......................................................................

implement minimalistic talloc_report(); add 't' command on UART

This helps when debugging the firmware, as it shows the current
utliization of the 10-msgb-talloc pool.

Change-Id: Ib10c4396cd4c9c4a6257cf45886e367214787927
Related: OS#4251
---
M firmware/libboard/qmod/source/board_qmod.c
M firmware/libcommon/include/talloc.h
M firmware/libcommon/source/pseudo_talloc.c
3 files changed, 21 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved



diff --git a/firmware/libboard/qmod/source/board_qmod.c b/firmware/libboard/qmod/source/board_qmod.c
index 6316979..32bfdd4 100644
--- a/firmware/libboard/qmod/source/board_qmod.c
+++ b/firmware/libboard/qmod/source/board_qmod.c
@@ -230,6 +230,7 @@
 		printf("\t2\tGenerate 1ms reset pulse on WWAN2\n\r");
 		printf("\t!\tSwitch Channel A from physical -> remote\n\r");
 		printf("\t@\tSwitch Channel B from physical -> remote\n\r");
+		printf("\tt\t(pseudo)talloc report\n\r");
 		break;
 	case 'R':
 		printf("Asking NVIC to reset us\n\r");
@@ -292,6 +293,9 @@
 	case '@':
 		sim_switch_use_physical(0, 0);
 		break;
+	case 't':
+		talloc_report(NULL, stdout);
+		break;
 	default:
 		if (!qmod_sam3_is_12())
 			printf("Unknown command '%c'\n\r", ch);
diff --git a/firmware/libcommon/include/talloc.h b/firmware/libcommon/include/talloc.h
index 0bd75d2..625355a 100644
--- a/firmware/libcommon/include/talloc.h
+++ b/firmware/libcommon/include/talloc.h
@@ -17,6 +17,7 @@
 #pragma once
 
 #include <stdlib.h>
+#include <stdio.h>
 #include <stdarg.h>
 
 /* minimalistic emulation of core talloc API functions used by msgb.c */
@@ -39,3 +40,4 @@
 void talloc_set_name_const(const void *ptr, const char *name);
 char *talloc_strdup(const void *t, const char *p);
 void *talloc_pool(const void *context, size_t size);
+void talloc_report(const void *ptr, FILE *f);
diff --git a/firmware/libcommon/source/pseudo_talloc.c b/firmware/libcommon/source/pseudo_talloc.c
index 862fffd..7c452b3 100644
--- a/firmware/libcommon/source/pseudo_talloc.c
+++ b/firmware/libcommon/source/pseudo_talloc.c
@@ -15,6 +15,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA
  */
 #include <stdint.h>
+#include <stdio.h>
 
 #include "talloc.h"
 #include "trace.h"
@@ -76,6 +77,20 @@
 	return -1;
 }
 
+void talloc_report(const void *ptr, FILE *f)
+{
+	unsigned int i;
+
+	fprintf(f, "talloc_report(): ");
+	for (i = 0; i < ARRAY_SIZE(msgb_inuse); i++) {
+		if (msgb_inuse[i])
+			fputc('X', f);
+		else
+			fputc('_', f);
+	}
+	fprintf(f, "\r\n");
+}
+
 void talloc_set_name_const(const void *ptr, const char *name)
 {
 	/* do nothing */

-- 
To view, visit https://gerrit.osmocom.org/c/simtrace2/+/16580
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: Ib10c4396cd4c9c4a6257cf45886e367214787927
Gerrit-Change-Number: 16580
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191214/f594c36e/attachment.htm>


More information about the gerrit-log mailing list