From 76db0bf8cfb5d37c393a827987e291a5c47258a7 Mon Sep 17 00:00:00 2001 From: Ramsey Harris Date: Thu, 12 Feb 2015 17:59:26 -0800 Subject: [PATCH] Added comment to explain hazards of enabling debug trace SocketFxns.c is used by both LAD and TransportRpmsg. When debug trace is enabled in LAD, it can cause data corruption. I explain this in the comment and provide advice. --- linux/src/utils/SocketFxns.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/linux/src/utils/SocketFxns.c b/linux/src/utils/SocketFxns.c index 7c97083..acef72e 100644 --- a/linux/src/utils/SocketFxns.c +++ b/linux/src/utils/SocketFxns.c @@ -55,7 +55,29 @@ /* For MultiProc id to remoteproc index map */ #include <_MultiProc.h> -/* traces in this file are controlled via _SocketFxns_verbose */ +/* Traces in this file are controlled via _SocketFxns_verbose + * + * Caution! This file is used by both LAD and TransportRpmsg. The + * PRINTVERBOSE macros use printf(), which sends its output to + * STDOUT (fd = 0). However, LAD closes STDOUT and by unfortunate + * chance, the file descriptor zero (fd = 0) is reused for the outbound + * pipe to the first client. This means all trace messages go into + * the pipe and corrupt the data on the client side. + + * If you want to enable this trace for LAD, in addition to setting + * _SocketFxns_versbose to TRUE below, you must also comment out the + * three calls to close() in linux/src/daemon/lad.c: + * + * close(STDIN_FILENO); + * close(STDOUT_FILENO); + * close(STDERR_FILENO); + * + * If you only want to enable trace in the client (i.e. calls from + * TransportRpmsg), then simply set the environment variable IPC_DEBUG + * (to either 2 or 3) before you run your program. + * + * IPC_DEBUG=3 ./app_host + */ Bool _SocketFxns_verbose = FALSE; #define verbose _SocketFxns_verbose -- 2.39.2