summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2018-06-08 13:54:00 +0900
committerJunghoon Park <jh9216.park@samsung.com>2018-06-08 08:09:25 +0000
commit3ec1d67721e74e0c79339992b2083845e6a98491 (patch)
treeae012db219011fa6cf86113937c582a6ffd434c7
parentdaacfc2a42e1e16a5e9cc9307dd3f53d498489d4 (diff)
downloadtidl-3ec1d67721e74e0c79339992b2083845e6a98491.tar.gz
tidl-3ec1d67721e74e0c79339992b2083845e6a98491.tar.bz2
tidl-3ec1d67721e74e0c79339992b2083845e6a98491.zip
Add log messages for debugging
Change-Id: I5ef24f61d9d3a9a646d193d9cc4deb2dcbe7a280 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--idlc/c_gen/c_proxy_body_gen_cb.h5
-rw-r--r--idlc/cpp_gen/cpp_gen_base.cc7
-rw-r--r--idlc/cpp_gen/cpp_gen_base.h1
-rw-r--r--idlc/cpp_gen/cpp_gen_base_cb.h9
-rw-r--r--idlc/cpp_gen/cpp_proxy_body_gen.cc3
-rw-r--r--idlc/cpp_gen/cpp_proxy_body_gen_cb.h33
-rw-r--r--idlc/cpp_gen/cpp_stub_body_gen.cc3
-rw-r--r--idlc/cpp_gen/cpp_stub_body_gen_cb.h40
8 files changed, 75 insertions, 26 deletions
diff --git a/idlc/c_gen/c_proxy_body_gen_cb.h b/idlc/c_gen/c_proxy_body_gen_cb.h
index 86529cc..f80f848 100644
--- a/idlc/c_gen/c_proxy_body_gen_cb.h
+++ b/idlc/c_gen/c_proxy_body_gen_cb.h
@@ -253,8 +253,11 @@ static void __##_on_received(const char *endpoint, const char *port_name, void *
rpc_port_parcel_h parcel_received;
int cmd = -1;
- if (g_rec_mutex_trylock(&handle->mutex) == FALSE)
+ if (g_rec_mutex_trylock(&handle->mutex) == FALSE) {
+ dlog_print(DLOG_WARN, LOG_TAG, "Failed to try to lock the mutex");
return;
+ }
+
rpc_port_parcel_create_from_port(&parcel_received, handle->port);
rpc_port_parcel_read_int32(parcel_received, &cmd);
if (cmd != ##_METHOD_Callback) {
diff --git a/idlc/cpp_gen/cpp_gen_base.cc b/idlc/cpp_gen/cpp_gen_base.cc
index 4c4210c..c8c9bdf 100644
--- a/idlc/cpp_gen/cpp_gen_base.cc
+++ b/idlc/cpp_gen/cpp_gen_base.cc
@@ -694,4 +694,11 @@ void CppGeneratorBase::GenCopyright(std::ofstream& stream) {
});
}
+void CppGeneratorBase::GenLogTag(std::ofstream& stream, std::string id) {
+ GenTemplate(CB_LOG_TAG, stream,
+ [&]()->std::string {
+ return id;
+ });
+}
+
} // namespace tidl
diff --git a/idlc/cpp_gen/cpp_gen_base.h b/idlc/cpp_gen/cpp_gen_base.h
index 05d62f2..865a52b 100644
--- a/idlc/cpp_gen/cpp_gen_base.h
+++ b/idlc/cpp_gen/cpp_gen_base.h
@@ -57,6 +57,7 @@ class CppGeneratorBase : public Generator {
std::string ConvertTypeToSerializer(const BaseType& type,
std::string id, std::string parcel);
std::string GetParameters(const Parameters& ps);
+ void GenLogTag(std::ofstream& stream, std::string id);
private:
void GenSetter(std::ofstream& stream, const Element& ele);
diff --git a/idlc/cpp_gen/cpp_gen_base_cb.h b/idlc/cpp_gen/cpp_gen_base_cb.h
index e4ad06f..76fc3c0 100644
--- a/idlc/cpp_gen/cpp_gen_base_cb.h
+++ b/idlc/cpp_gen/cpp_gen_base_cb.h
@@ -213,4 +213,13 @@ $$
}
)__cpp_cb";
+const char CB_LOG_TAG[] =
+R"__cpp_cb(
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "$$"
+)__cpp_cb";
+
#endif // IDLC_CPP_GEN_CPP_GEN_BASE_CB_H_
diff --git a/idlc/cpp_gen/cpp_proxy_body_gen.cc b/idlc/cpp_gen/cpp_proxy_body_gen.cc
index 8226991..cc4c641 100644
--- a/idlc/cpp_gen/cpp_proxy_body_gen.cc
+++ b/idlc/cpp_gen/cpp_proxy_body_gen.cc
@@ -37,8 +37,11 @@ void CppProxyBodyGen::OnInitGen(std::ofstream& stream) {
stream << NLine(1);
stream << "#include <stdlib.h>" << NLine(1)
<< "#include <assert.h>" << NLine(1)
+ << "#include <dlog.h>" << NLine(1)
<< NLine(1)
<< "#include \"" << header_file << "\"" << NLine(2);
+ GenLogTag(stream, "RPC_PORT_PROXY");
+ stream << NLine(1);
GenNamespace(stream);
}
diff --git a/idlc/cpp_gen/cpp_proxy_body_gen_cb.h b/idlc/cpp_gen/cpp_proxy_body_gen_cb.h
index 879630e..45d150e 100644
--- a/idlc/cpp_gen/cpp_proxy_body_gen_cb.h
+++ b/idlc/cpp_gen/cpp_proxy_body_gen_cb.h
@@ -26,8 +26,10 @@ $$::~$$() {
)__cpp_cb";
const char CB_INVOCATION_PRE[] =
-R"__cpp_cb( if (port_ == nullptr)
+R"__cpp_cb( if (port_ == nullptr) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Not connected");
throw NotConnectedSocketException();
+ }
rpc_port_parcel_h p;
rpc_port_parcel_create(&p);
@@ -42,6 +44,7 @@ R"__cpp_cb(
const char CB_INVOCATION_RECEIVE[] =
R"__cpp_cb(
if (parcel_received == nullptr) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Invalid protocol");
throw InvalidProtocolException();
}
)__cpp_cb";
@@ -58,16 +61,18 @@ const char CB_PROXY_HELPER_METHODS[] =
R"__cpp_cb(
void ##::Connect() {
int ret = rpc_port_proxy_connect(proxy_, target_appid_.c_str(), "##");
+ if (ret != RPC_PORT_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to connect ##");
+ switch (ret) {
+ case RPC_PORT_ERROR_INVALID_PARAMETER:
+ throw InvalidIDException();
- switch (ret) {
- case RPC_PORT_ERROR_INVALID_PARAMETER:
- throw InvalidIDException();
-
- case RPC_PORT_ERROR_IO_ERROR:
- throw InvalidIOException();
+ case RPC_PORT_ERROR_IO_ERROR:
+ throw InvalidIOException();
- case RPC_PORT_ERROR_PERMISSION_DENIED:
- throw PermissionDeniedException();
+ case RPC_PORT_ERROR_PERMISSION_DENIED:
+ throw PermissionDeniedException();
+ }
}
}
@@ -141,10 +146,13 @@ void ##::OnReceivedCB(const char *ep, const char *port_name, void *data) {
int cmd;
rpc_port_parcel_h parcel_received;
- if (!l->mutex_.try_lock())
+ if (!l->mutex_.try_lock()) {
+ dlog_print(DLOG_WARN, LOG_TAG, "Failed to try to lock the mutex");
return;
+ }
if (rpc_port_parcel_create_from_port(&parcel_received, l->port_) != 0) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create parcel from port");
l->mutex_.unlock();
return;
}
@@ -168,8 +176,11 @@ $$::$$(IEventListener* listener, const std::string& target_appid)
target_appid_(target_appid) {
int r = rpc_port_proxy_create(&proxy_);
- if (r != RPC_PORT_ERROR_NONE)
+ if (r != RPC_PORT_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create proxy");
throw InvalidIOException();
+ }
+
rpc_port_proxy_add_connected_event_cb(proxy_, OnConnectedCB, this);
rpc_port_proxy_add_disconnected_event_cb(proxy_, OnDisconnectedCB, this);
rpc_port_proxy_add_rejected_event_cb(proxy_, OnRejectedCB, this);
diff --git a/idlc/cpp_gen/cpp_stub_body_gen.cc b/idlc/cpp_gen/cpp_stub_body_gen.cc
index e5b428b..a4e3dc9 100644
--- a/idlc/cpp_gen/cpp_stub_body_gen.cc
+++ b/idlc/cpp_gen/cpp_stub_body_gen.cc
@@ -37,8 +37,11 @@ void CppStubBodyGen::OnInitGen(std::ofstream& stream) {
stream << NLine(1);
stream << "#include <stdlib.h>" << NLine(1)
<< "#include <assert.h>" << NLine(1)
+ << "#include <dlog.h>" << NLine(1)
<< NLine(1)
<< "#include \"" << header_file << "\"" << NLine(2);
+ GenLogTag(stream, "RPC_PORT_STUB");
+ stream << NLine(1);
GenNamespace(stream);
}
diff --git a/idlc/cpp_gen/cpp_stub_body_gen_cb.h b/idlc/cpp_gen/cpp_stub_body_gen_cb.h
index f656bc1..b718dcd 100644
--- a/idlc/cpp_gen/cpp_stub_body_gen_cb.h
+++ b/idlc/cpp_gen/cpp_stub_body_gen_cb.h
@@ -21,8 +21,10 @@ const char CB_CTOR_FRONT[] =
R"__cpp_cb(
##::##() {
int r = rpc_port_stub_create(&stub_, "##");
- if (r != RPC_PORT_ERROR_NONE)
+ if (r != RPC_PORT_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create stub handle");
throw InvalidIOException();
+ }
rpc_port_stub_add_connected_event_cb(stub_, OnConnectedCB, this);
rpc_port_stub_add_disconnected_event_cb(stub_, OnDisconnectedCB, this);
rpc_port_stub_add_received_event_cb(stub_, OnReceivedCB, this);
@@ -43,11 +45,13 @@ R"__cpp_cb(
void ##::Listen(std::shared_ptr<##::ServiceBase::Factory> service_factory) {
service_factory_ = std::move(service_factory);
int r = rpc_port_stub_listen(stub_);
-
- switch (r) {
- case RPC_PORT_ERROR_INVALID_PARAMETER:
- case RPC_PORT_ERROR_IO_ERROR:
- throw InvalidIOException();
+ if (r != RPC_PORT_ERROR_NONE) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to listen stub");
+ switch (r) {
+ case RPC_PORT_ERROR_INVALID_PARAMETER:
+ case RPC_PORT_ERROR_IO_ERROR:
+ throw InvalidIOException();
+ }
}
}
@@ -79,13 +83,7 @@ int $$::OnReceivedCB(const char* sender, const char* instance, rpc_port_h port,
rpc_port_parcel_h p;
rpc_port_parcel_h result;
int cmd;
- int ret = rpc_port_parcel_create_from_port(&p, port);
-
- if (ret != 0)
- return ret;
-
- rpc_port_parcel_create(&result);
- rpc_port_parcel_read_int32(p, &cmd);
+ int ret;
std::shared_ptr<ServiceBase> b;
for (auto& i : cxt->services_) {
@@ -95,14 +93,28 @@ int $$::OnReceivedCB(const char* sender, const char* instance, rpc_port_h port,
}
}
- if (b.get() == nullptr)
+ if (b.get() == nullptr) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to find $$ context(%s)", instance);
return -1;
+ }
+
+ ret = rpc_port_parcel_create_from_port(&p, port);
+ if (ret != 0) {
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to create parcel from port");
+ return ret;
+ }
+
+ rpc_port_parcel_create(&result);
+ rpc_port_parcel_read_int32(p, &cmd);
switch (cmd) {
)__cpp_cb";
const char CB_ON_RECEIVED_CB_BACK[] =
R"__cpp_cb( default:
+ dlog_print(DLOG_ERROR, LOG_TAG, "Unknown command(%d)", cmd);
+ rpc_port_parcel_destroy(p);
+ rpc_port_parcel_destroy(result);
return -1;
}