From f549f5527148b32a15489aae75c9e4557e19cbd4 Mon Sep 17 00:00:00 2001 From: Yusuke Sato Date: Fri, 18 May 2018 14:35:31 +0900 Subject: Introduce controlling entire system trace status feature from dlt-control (#57) * dlt-control: Provision to control entire system trace status 1. support for setting trace status using wildcards for both app and context 2. support for setting entire system trace status *This Logic is as same as for changing log level. (SHA: a966393ad7003d02870bceffa08df5ddf4bbf864 dlt-control: Provision to control entire system log level) * dlt-daemon: Fix control entire log level / trace status issue In previous, dlt-control could send request to set all log level / trace status with DLT_LOG_DEFAULT / DLT_TRACE_STATUS_DEFAULT(-1). However, dlt-daemon could not accept these value. This change fix this issue so that setting log level/trace status of all registered contexts become possible. Signed-off-by: Yusuke Sato --- src/console/dlt-control.c | 68 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 18 deletions(-) (limited to 'src/console') diff --git a/src/console/dlt-control.c b/src/console/dlt-control.c index 9c309a9..7e90c7c 100644 --- a/src/console/dlt-control.c +++ b/src/console/dlt-control.c @@ -72,6 +72,7 @@ #define DLT_GLOGINFO_DATA_MAX 800 #define DLT_GET_LOG_INFO_HEADER 18 /*Get log info header size in response text */ #define DLT_INVALID_LOG_LEVEL 0xF +#define DLT_INVALID_TRACE_STATUS 0xF /* Option of GET_LOG_INFO */ #define DLT_SERVICE_GET_LOG_INFO_OPT7 7 /* get Apid, ApDescription, Ctid, CtDescription, loglevel, tracestatus */ @@ -217,7 +218,14 @@ void usage() printf(" -l level -c xyz* (set level for all ctxts whose name starts with xyz)\n"); printf(" -l level -c ctxid (set level for the particular ctxt)\n"); printf(" -l level (set level for all the registered contexts)\n"); - printf(" -r tracestatus Set the trace status (0=off - 1=on,255=default)\n"); + printf(" -r tracestatus Set the trace status (0=off - 1=on,255=default)\n"); + printf(" supported options:\n"); + printf(" -r tracestatus -a appid -c ctid\n"); + printf(" -r tracestatus -a abc* (set status for all ctxts of apps name starts with abc)\n"); + printf(" -r tracestatus -a appid (set status for all ctxts of this app)\n"); + printf(" -r tracestatus -c xyz* (set status for all ctxts whose name starts with xyz)\n"); + printf(" -r tracestatus -c ctxid (set status for the particular ctxt)\n"); + printf(" -r tracestatus (set status for all the registered contexts)\n"); printf(" -d loglevel Set the default log level (0=off - 5=verbose)\n"); printf(" -f tracestatus Set the default trace status (0=off - 1=on)\n"); printf(" -i enable Enable timing packets (0=off - 1=on)\n"); @@ -293,7 +301,7 @@ int main(int argc, char* argv[]) dltdata.xvalue = 0; dltdata.tvalue = 1000; dltdata.lvalue = DLT_INVALID_LOG_LEVEL; - dltdata.rvalue = -1; + dltdata.rvalue = DLT_INVALID_TRACE_STATUS; dltdata.dvalue = -1; dltdata.fvalue = -1; dltdata.ivalue = -1; @@ -384,8 +392,13 @@ int main(int argc, char* argv[]) } case 'r': { - dltdata.rvalue = atoi(optarg);; - break; + dltdata.rvalue = strtol(optarg, &endptr, 10); + if ((dltdata.rvalue < DLT_TRACE_STATUS_DEFAULT) || (dltdata.rvalue > DLT_TRACE_STATUS_ON)) + { + fprintf (stderr, "invalid trace status, supported trace status -1, 0, 1\n"); + return -1; + } + break; } case 'd': { @@ -615,22 +628,41 @@ int main(int argc, char* argv[]) } } } - else if(dltdata.rvalue!=-1 && dltdata.avalue && dltdata.cvalue) - { - /* trace status */ - printf("Set trace status:\n"); - printf("AppId: %s\n",dltdata.avalue); - printf("ConId: %s\n",dltdata.cvalue); - printf("TraceStatus: %d\n",dltdata.rvalue); - /* send control message in*/ - if (dlt_client_send_trace_status(&g_dltclient, - dltdata.avalue, - dltdata.cvalue, - dltdata.rvalue) != DLT_RETURN_OK) + else if (dltdata.rvalue != DLT_INVALID_TRACE_STATUS) + { + if ((dltdata.avalue == 0) && (dltdata.cvalue == 0)) + { + if (dltdata.vflag) + { + printf("Set all trace status:\n"); + printf("Tracestatus: %d\n", dltdata.rvalue); + } + if (0 != dlt_client_send_all_trace_status(&g_dltclient, + dltdata.rvalue)) + { + fprintf(stderr, "ERROR: Could not send trace status\n"); + } + } + else { - fprintf(stderr, "ERROR: Could not send trace status\n"); + /* trace status */ + if (dltdata.vflag) + { + printf("Set trace status:\n"); + printf("AppId: %s\n", dltdata.avalue); + printf("ConId: %s\n", dltdata.cvalue); + printf("Tracestatus: %d\n", dltdata.rvalue); + } + /* send control message*/ + if (0 != dlt_client_send_trace_status(&g_dltclient, + dltdata.avalue, + dltdata.cvalue, + dltdata.rvalue)) + { + fprintf(stderr, "ERROR: Could not send trace status\n"); + } } - } + } else if(dltdata.dvalue!=-1) { /* default log level */ -- cgit v1.2.1