help_vars.Add(BoolVariable('BUILD_JAVA', 'Build Java bindings', False))
help_vars.Add(PathVariable('JAVA_HOME', 'JDK directory', os.environ.get('JAVA_HOME'), PathVariable.PathAccept))
+help_vars.Add(EnumVariable('OIC_SUPPORT_TIZEN_TRACE', 'Tizen Trace(T-trace) api availability', 'False', allowed_values=('True', 'False')))
AddOption('--prefix',
dest='prefix',
env.AppendUnique(LIBS = ['dl', 'pthread'])
env.AppendUnique(CCFLAGS = ['-D__TIZEN__', '-D_GNU_SOURCE', '-DTIZEN_DEBUG_ENABLE'])
-env.ParseConfig("pkg-config dlog ttrace --cflags --libs")
-
+env.ParseConfig("pkg-config dlog --cflags --libs")
+if env.get('OIC_SUPPORT_TIZEN_TRACE') == 'True':
+ env.ParseConfig("pkg-config ttrace --cflags --libs")
# Set arch flags : It will be handled by Tizen build system.
%{!?TARGET_TRANSPORT: %define TARGET_TRANSPORT IP}
%{!?VERBOSE: %define VERBOSE 1}
%{!?WITH_TCP: %define WITH_TCP 0}
+%{!?OIC_SUPPORT_TIZEN_TRACE: %define OIC_SUPPORT_TIZEN_TRACE False}
BuildRequires: pkgconfig(dlog)
+%if "%{OIC_SUPPORT_TIZEN_TRACE}" == "True"
BuildRequires: pkgconfig(ttrace)
+%endif
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(capi-network-connection)
BuildRequires: pkgconfig(capi-network-bluetooth)
TARGET_TRANSPORT=%{TARGET_TRANSPORT} \
VERBOSE=%{VERBOSE} \
WITH_TCP=%{WITH_TCP} \
+ OIC_SUPPORT_TIZEN_TRACE=%{OIC_SUPPORT_TIZEN_TRACE} \
#eol
if env.get('LOGGING'):
env.AppendUnique(CPPDEFINES = ['TB_LOG'])
-env.ParseConfig("pkg-config --cflags --libs capi-network-connection dlog ttrace glib-2.0")
+env.ParseConfig("pkg-config --cflags --libs capi-network-connection dlog glib-2.0")
+if env.get('OIC_SUPPORT_TIZEN_TRACE') == 'True':
+ env.ParseConfig("pkg-config --cflags --libs ttrace")
if 'ALL' in transport:
env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER', 'NO_ETHERNET_ADAPTER','EDR_ADAPTER','LE_ADAPTER'])
print "CA Transport is ALL"
{
#ifndef SINGLE_HANDLE
CAData_t *data = (CAData_t *) threadData;
+ OIC_TRACE_BEGIN(%s:CAProcessReceivedData, TAG);
CAProcessReceivedData(data);
+ OIC_TRACE_END();
#else
(void)threadData;
#endif
VERIFY_NON_NULL(data, TAG, "data");
VERIFY_NON_NULL(data->remoteEndpoint, TAG, "remoteEndpoint");
- OIC_TRACE_BEGIN(%s:CAProcessSendData, TAG);
-
CAResult_t res = CA_STATUS_FAILED;
CASendDataType_t type = data->type;
else
{
OIC_LOG(DEBUG, TAG, "request info, response info is empty");
- OIC_TRACE_END();
return CA_STATUS_INVALID_PARAM;
}
CAErrorHandler(data->remoteEndpoint, pdu->transport_hdr, pdu->length, res);
coap_delete_list(options);
coap_delete_pdu(pdu);
- OIC_TRACE_END();
return res;
}
}
CAErrorHandler(data->remoteEndpoint, pdu->transport_hdr, pdu->length, res);
coap_delete_list(options);
coap_delete_pdu(pdu);
- OIC_TRACE_END();
return res;
}
OIC_LOG_V(INFO, TAG, "retransmission is not enabled due to error, res : %d", res);
coap_delete_list(options);
coap_delete_pdu(pdu);
- OIC_TRACE_END();
return res;
}
}
{
OIC_LOG(ERROR,TAG,"Failed to generate unicast PDU");
CASendErrorInfo(data->remoteEndpoint, info, CA_SEND_FAILED);
- OIC_TRACE_END();
return CA_SEND_FAILED;
}
}
CAProcessMulticastData(data);
#endif
}
- OIC_TRACE_END();
+
return CA_STATUS_OK;
}
static void CASendThreadProcess(void *threadData)
{
CAData_t *data = (CAData_t *) threadData;
+ OIC_TRACE_BEGIN(%s:CAProcessSendData, TAG);
CAProcessSendData(data);
+ OIC_TRACE_END();
}
#endif
{
VERIFY_NON_NULL_VOID(sep, TAG, "remoteEndpoint");
VERIFY_NON_NULL_VOID(data, TAG, "data");
-
OIC_TRACE_BEGIN(%s:CAReceivedPacketCallback, TAG);
if (0 == dataLen)
VERIFY_NON_NULL_VOID(data, TAG, "data");
VERIFY_NON_NULL_VOID(pdu, TAG, "pdu");
+ OIC_TRACE_BEGIN(%s:CALogPDUInfo, TAG);
OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
if(SEND_TYPE_MULTICAST == data->type)
{
OIC_LOG(DEBUG, ANALYZER_TAG, "Coap Token");
OIC_LOG_BUFFER(DEBUG, ANALYZER_TAG, (const uint8_t *) info->token, info->tokenLength);
+ OIC_TRACE_BUFFER("OIC_CA_MSG_HANDLE:CALogPDUInfo:token:", (const uint8_t *) info->token,
+ info->tokenLength);
OIC_LOG_V(DEBUG, ANALYZER_TAG, "Res URI = [%s]", info->resourceUri);
+ OIC_TRACE_MARK(%s:CALogPDUInfo:uri:%s, TAG, info->resourceUri);
if (CA_FORMAT_APPLICATION_CBOR == info->payloadFormat)
{
// OIC_LOG_BUFFER(DEBUG, ANALYZER_TAG, pdu->data, payloadLen);
OIC_LOG_V(DEBUG, ANALYZER_TAG, "CoAP Payload Size = [%lu]", payloadLen);
OIC_LOG(DEBUG, ANALYZER_TAG, "=================================================");
+ OIC_TRACE_END();
}
#else
static void CALogPDUInfo(const CAData_t *data, const coap_pdu_t *pdu)
env.AppendUnique(LIBPATH = [build_dir])
else:
env.AppendUnique(LIBPATH = [os.path.join(build_dir, 'resource', 'csdk', 'logger')])
+if env.get('OIC_SUPPORT_TIZEN_TRACE') == 'True':
+ env.AppendUnique(CPPDEFINES = ['OIC_SUPPORT_TIZEN_TRACE'])
env.PrependUnique(LIBS = ['logger'])
#ifdef __ANDROID__
#include "logger.h"
#elif defined(__TIZEN__)
+#ifdef OIC_SUPPORT_TIZEN_TRACE
#include <ttrace.h>
+#endif
#elif defined(ARDUINO)
#endif
extern "C"
{
#endif
+
#ifdef __ANDROID__
+void oic_trace_begin(const char *name, ...);
+void oic_trace_end();
+void oic_trace_buffer(const char *name, const uint8_t * buffer, size_t bufferSize);
+
#define OIC_TRACE_BEGIN(MSG, ...) \
oic_trace_begin("OIC:"#MSG, ##__VA_ARGS__)
#define OIC_TRACE_END() \
oic_trace_end()
+#define OIC_TRACE_MARK(MSG, ...) \
+ oic_trace_begin("OIC:"#MSG, ##__VA_ARGS__), \
+ oic_trace_end()
+#define OIC_TRACE_BUFFER(MSG, BUF, SIZ) \
+ oic_trace_buffer(MSG, BUF, SIZ)
#elif defined(__TIZEN__)
/* trace macro for Tizen. this will call ttrace api internally*/
+#ifdef OIC_SUPPORT_TIZEN_TRACE
+
+#include <ttrace.h>
+
+void oic_trace_buffer(const char *name, const uint8_t * buffer, size_t bufferSize);
+
+/* ttrace api is available on tizen2.4 (or above) only */
#define OIC_TRACE_BEGIN(MSG, ...) \
- traceBegin(TTRACE_TAG_APP, "IOTIVITY:"#MSG, ##__VA_ARGS__)
+ traceBegin(TTRACE_TAG_APP, "OIC:"#MSG, ##__VA_ARGS__)
#define OIC_TRACE_END() \
traceEnd(TTRACE_TAG_APP)
+#define OIC_TRACE_MARK(MSG, ...) \
+ traceBegin(TTRACE_TAG_APP, "OIC:"#MSG, ##__VA_ARGS__), \
+ traceEnd(TTRACE_TAG_APP)
+#define OIC_TRACE_BUFFER(MSG, BUF, SIZ) \
+ oic_trace_buffer(MSG, BUF, SIZ)
+#else
+#define OIC_TRACE_BEGIN(MSG, ...)
+#define OIC_TRACE_END()
+#define OIC_TRACE_MARK(MSG, ...)
+#define OIC_TRACE_BUFFER(MSG, BUF, SIZ)
+#endif
#elif defined(ARDUINO)
/* trace macro for Arduino. currently this will call nothing*/
#define OIC_TRACE_BEGIN(MSG, ...)
#define OIC_TRACE_END()
+#define OIC_TRACE_MARK(MSG, ...)
+#define OIC_TRACE_BUFFER(MSG, BUF, SIZ)
#else
#define OIC_TRACE_BEGIN(MSG, ...)
#define OIC_TRACE_END()
+#define OIC_TRACE_MARK(MSG, ...)
+#define OIC_TRACE_BUFFER(MSG, BUF, SIZ)
#endif //endif
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-// Defining _POSIX_C_SOURCE macro with 199309L (or greater) as value
-// causes header files to expose definitions
-// corresponding to the POSIX.1b, Real-time extensions
-// (IEEE Std 1003.1b-1993) specification
-//
-// For this specific file, see use of clock_gettime,
-// Refer to http://pubs.opengroup.org/stage7tc1/functions/clock_gettime.html
-// and to http://man7.org/linux/man-pages/man2/clock_gettime.2.html
-#ifndef _POSIX_C_SOURCE
-#define _POSIX_C_SOURCE 200809L
-#endif
-
#include "iotivity_config.h"
+#include "trace.h"
+
+#if (defined(__ANDROID__)) || (defined(__TIZEN__) && defined(OIC_SUPPORT_TIZEN_TRACE))
+
+#define MAX_BUFFER_SIZE 8
+#define MAX_LINE_LEN ((MAX_BUFFER_SIZE) * 2) + 1
+
+void oic_trace_buffer(const char *name, const uint8_t * buffer, size_t bufferSize)
+{
+ if (!name || !buffer || (0 == bufferSize))
+ {
+ return;
+ }
+
+ char lineBuffer[MAX_LINE_LEN] = {0};
+ size_t count = (MAX_BUFFER_SIZE > bufferSize) ? bufferSize : MAX_BUFFER_SIZE;
+ size_t remainSize = MAX_LINE_LEN;
+ int writtenSize = 0;
+ char* buf = &lineBuffer[0];
+
+ for (size_t i = 0; i < count; i++)
+ {
+ writtenSize = snprintf(buf, remainSize, "%02x", buffer[i]);
+ if (2 != writtenSize)
+ {
+ break;
+ }
+ buf += writtenSize;
+ remainSize -= 2;
+ }
+
+ OIC_TRACE_BEGIN(%s:%s, name, lineBuffer);
+ OIC_TRACE_END();
+}
+
+#endif
-// Pull in _POSIX_TIMERS feature test macro to check for
-// clock_gettime() support.
#ifndef __TIZEN__
-#include "trace.h"
#include "logger.h"
#ifdef HAVE_UNISTD_H
int oic_trace_init()
{
OIC_LOG(INFO, TAG, "entering oic_trace_init");
- int mounts;
+ int mounts = -1;
char buf[MAX_BUF_SIZE] = {0};
- ssize_t buflen;
- char *line, *tmp1, *path = NULL;
+ ssize_t buflen = -1;
+ char *line = NULL, *tmp1 = NULL, *path = NULL;
if(g_trace_marker_hd == FD_INITIAL_VALUE)
{
line = strtok_r(buf, "\n", &tmp1);
while (line)
{
- char *tmp2, *tmp_path, *fstype;
+ char *tmp2 = NULL, *tmp_path = NULL, *fstype = NULL;
/* "<dev> <mountpoint> <fs type> ..." */
strtok_r(line, " ", &tmp2);
tmp_path = strtok_r(NULL, " ", &tmp2);
g_trace_marker_hd = open(buf, O_WRONLY);
if (g_trace_marker_hd < 0)
{
- OIC_LOG_V(INFO, TAG, "failed to open trace_marker file: %s (%d)", strerror(errno), errno);
+ OIC_LOG_V(INFO, TAG, "failed to open trace_marker file: %s (%d)",
+ strerror(errno), errno);
return -1;
}
}
OIC_LOG_V(INFO, TAG, "exit oic_trace_init with: %d", g_trace_marker_hd);
- return 0;
+ return g_trace_marker_hd;
}
void oic_trace_begin(const char *name, ...)
if env.get('LOGGING'):
env.AppendUnique(CPPDEFINES = ['TB_LOG'])
-env.ParseConfig("pkg-config --cflags --libs capi-network-connection dlog ttrace glib-2.0")
+env.ParseConfig("pkg-config --cflags --libs capi-network-connection dlog glib-2.0")
+if env.get('OIC_SUPPORT_TIZEN_TRACE') == 'True':
+ env.ParseConfig("pkg-config --cflags --libs ttrace")
+ env.AppendUnique(CPPDEFINES = ['OIC_SUPPORT_TIZEN_TRACE'])
if 'ALL' in transport:
env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER', 'NO_ETHERNET_ADAPTER','EDR_ADAPTER','LE_ADAPTER'])
print "CA Transport is ALL"
#include "occlientcb.h"
#include <coap/coap.h>
#include "logger.h"
+#include "trace.h"
#include "oic_malloc.h"
#include <string.h>
return OC_STACK_INVALID_PARAM;
}
+ OIC_TRACE_BEGIN(%s:AddClientCB, TAG);
+
ClientCB *cbNode = NULL;
#ifdef WITH_PRESENCE
{
OIC_LOG(INFO, TAG, "Adding client callback with token");
OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
+ OIC_TRACE_BUFFER("OIC_RI_CLIENTCB:AddClientCB:token:",
+ (const uint8_t *)token, tokenLength);
cbNode->callBack = cbData->cb;
cbNode->context = cbData->context;
cbNode->deleteCallback = cbData->cd;
cbNode->requestUri = requestUri; // I own it now
cbNode->devAddr = devAddr; // I own it now
OIC_LOG_V(INFO, TAG, "Added Callback for uri : %s", requestUri);
+ OIC_TRACE_MARK(%s:AddClientCB:uri:%s, TAG, requestUri);
LL_APPEND(cbList, cbNode);
*clientCB = cbNode;
}
if (method == OC_REST_PRESENCE && resourceTypeName)
{
+ OIC_TRACE_END();
// Amend the found or created node by adding a new resourceType to it.
return InsertResourceTypeFilter(cbNode,(char *)resourceTypeName);
// I own resourceTypName now.
OICFree(resourceTypeName);
#endif
+ OIC_TRACE_END();
return OC_STACK_OK;
exit:
+ OIC_TRACE_END();
return OC_STACK_NO_MEMORY;
}
void DeleteClientCB(ClientCB * cbNode)
{
+ OIC_TRACE_BEGIN(%s:DeleteClientCB, TAG);
if (cbNode)
{
LL_DELETE(cbList, cbNode);
OIC_LOG (INFO, TAG, "Deleting token");
OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)cbNode->token, cbNode->tokenLength);
+ OIC_TRACE_BUFFER("OIC_RI_CLIENTCB:DeleteClientCB:token:",
+ (const uint8_t *)cbNode->token, cbNode->tokenLength);
CADestroyToken (cbNode->token);
OICFree(cbNode->devAddr);
OICFree(cbNode->handle);
if (cbNode->requestUri)
{
OIC_LOG_V (INFO, TAG, "Deleting callback with uri %s", cbNode->requestUri);
+ OIC_TRACE_MARK(%s:DeleteClientCB:uri:%s, TAG, cbNode->requestUri);
OICFree(cbNode->requestUri);
}
if (cbNode->deleteCallback)
OICFree(cbNode);
cbNode = NULL;
}
+ OIC_TRACE_END();
}
/*
{
VERIFY_NON_NULL(object, FATAL, OC_STACK_INVALID_PARAM);
VERIFY_NON_NULL(requestInfo, FATAL, OC_STACK_INVALID_PARAM);
+ OIC_TRACE_BEGIN(%s:OCSendRequest, TAG);
#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
OCStackResult rmResult = RMAddInfo(object->routeData, requestInfo, true, NULL);
if (OC_STACK_OK != rmResult)
{
OIC_LOG(ERROR, TAG, "Add destination option failed");
+ OIC_TRACE_END();
return rmResult;
}
#endif
if(CA_STATUS_OK != result)
{
OIC_LOG_V(ERROR, TAG, "CASendRequest failed with CA error %u", result);
+ OIC_TRACE_END();
return CAResultToOCResult(result);
}
+ OIC_TRACE_END();
return OC_STACK_OK;
}
//-----------------------------------------------------------------------------
void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* responseInfo)
{
OIC_LOG(DEBUG, TAG, "Enter OCHandleResponse");
+ OIC_TRACE_MARK(%s:OCHandleResponse:%s, TAG, responseInfo->info.resourceUri);
if(responseInfo->info.resourceUri &&
strcmp(responseInfo->info.resourceUri, OC_RSRVD_PRESENCE_URI) == 0)
if (!response)
{
OIC_LOG(ERROR, TAG, "Allocating memory for response failed");
+ OIC_TRACE_END();
return;
}
void OCHandleRequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* requestInfo)
{
+ OIC_TRACE_MARK(%s:OCHandleRequests:%s, TAG, requestInfo->info.resourceUri);
OIC_LOG(DEBUG, TAG, "Enter OCHandleRequests");
OIC_LOG_V(INFO, TAG, "Endpoint URI : %s", requestInfo->info.resourceUri);
OCHeaderOption *options,
uint8_t numOptions)
{
+ OIC_TRACE_BEGIN(%s:OCDoRequest, TAG);
OCStackResult ret = OCDoRequest(handle, method, requestUri,destination, payload,
connectivityType, qos, cbData, options, numOptions);
+ OIC_TRACE_END();
// This is the owner of the payload object, so we free it
OCPayloadDestroy(payload);
OCStackResult OCDoResponse(OCEntityHandlerResponse *ehResponse)
{
+ OIC_TRACE_BEGIN(%s:OCDoResponse, TAG);
OCStackResult result = OC_STACK_ERROR;
OCServerRequest *serverRequest = NULL;
result = serverRequest->ehResponseHandler(ehResponse);
}
+ OIC_TRACE_END();
return result;
}
%define TARGET_TRANSPORT IP
%endif
+%if "%{tizen}" == "3.0"
+%define OIC_SUPPORT_TIZEN_TRACE True
+%endif
+
%if "%{profile}" == "ivi"
%define TARGET_TRANSPORT IP
%endif
%{!?WITH_MQ: %define WITH_MQ OFF}
%{!?WITH_PROXY: %define WITH_PROXY 0}
%{!?WITH_TCP: %define WITH_TCP 0}
+%{!?OIC_SUPPORT_TIZEN_TRACE: %define OIC_SUPPORT_TIZEN_TRACE False}
BuildRequires: expat-devel
BuildRequires: python, libcurl-devel
%if "%{TARGET_OS}" == "tizen"
BuildRequires: gettext-tools
BuildRequires: pkgconfig(dlog)
+%if "%{OIC_SUPPORT_TIZEN_TRACE}" == "True"
BuildRequires: pkgconfig(ttrace)
+%endif
BuildRequires: pkgconfig(capi-network-connection)
BuildRequires: pkgconfig(capi-network-bluetooth) >= 0.1.52
%else
WITH_MQ=%{WITH_MQ} \
WITH_PROXY=%{WITH_PROXY} \
WITH_TCP=%{WITH_TCP} \
+ OIC_SUPPORT_TIZEN_TRACE=%{OIC_SUPPORT_TIZEN_TRACE} \
#eol
WITH_MQ=%{WITH_MQ} \
WITH_PROXY=%{WITH_PROXY} \
WITH_TCP=%{WITH_TCP} \
+ OIC_SUPPORT_TIZEN_TRACE=%{OIC_SUPPORT_TIZEN_TRACE} \
#eol
mkdir -p %{ex_install_dir}