aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2019-12-14 21:11:39 +0100
committerHarald Welte <laforge@osmocom.org>2019-12-14 23:07:04 +0100
commit63c9e1f402a39a3c05c94e9da4afff07a46ab7ae (patch)
tree92ad9643add90eed867b9e745846b896fd582f3a
parent7c1d85eb4de12dd5a083d01c5dc0eb2a3e3c8ec2 (diff)
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
-rw-r--r--firmware/libboard/qmod/source/board_qmod.c4
-rw-r--r--firmware/libcommon/include/talloc.h2
-rw-r--r--firmware/libcommon/source/pseudo_talloc.c15
3 files changed, 21 insertions, 0 deletions
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 @@ void board_exec_dbg_cmd(int ch)
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 @@ void board_exec_dbg_cmd(int ch)
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_named_const(const void *context, size_t size, const char *name);
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 @@ int _talloc_free(void *ptr, const char *location)
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 */