OSDN Git Service

Enable debug logs for bluetooth process threads, modules
authorSrinu Jella <sjella@codeaurora.org>
Tue, 1 Mar 2016 11:29:35 +0000 (16:59 +0530)
committerAndre Eisenbach <eisenbach@google.com>
Fri, 25 Mar 2016 20:02:36 +0000 (13:02 -0700)
Use case: Debug enhancement for bluetooth threads,
          modules

- Most of the bluetooth process threads,modules uses
  APIs provided from the OSI layer.

- This patch enables the debug logs to know when the
  thread, module is created and exited.

- This would be useful while debugging the ON/OFF,
  ANR issues.

Bug: 27852645
Change-Id: I17f4f583d2c431725a8c44c586b29980b4bdab3f

btcore/src/module.c
osi/src/thread.c

index 341bc82..ba79b31 100644 (file)
@@ -78,10 +78,12 @@ bool module_init(const module_t *module) {
   assert(module != NULL);
   assert(get_module_state(module) == MODULE_STATE_NONE);
 
+  LOG_WARN(LOG_TAG, "%s initializing the module \"%s\"", __func__, module->name);
   if (!call_lifecycle_function(module->init)) {
     LOG_ERROR(LOG_TAG, "%s failed to initialize \"%s\"", __func__, module->name);
     return false;
   }
+  LOG_WARN(LOG_TAG, "%s initialized the module \"%s\"", __func__, module->name);
 
   set_module_state(module, MODULE_STATE_INITIALIZED);
   return true;
@@ -95,10 +97,12 @@ bool module_start_up(const module_t *module) {
   // as we're converting the startup sequence.
   assert(get_module_state(module) == MODULE_STATE_INITIALIZED || module->init == NULL);
 
+  LOG_WARN(LOG_TAG, "%s Starting the module \"%s\"", __func__, module->name);
   if (!call_lifecycle_function(module->start_up)) {
     LOG_ERROR(LOG_TAG, "%s failed to start up \"%s\"", __func__, module->name);
     return false;
   }
+  LOG_WARN(LOG_TAG, "%s Started the module \"%s\"", __func__, module->name);
 
   set_module_state(module, MODULE_STATE_STARTED);
   return true;
@@ -114,8 +118,11 @@ void module_shut_down(const module_t *module) {
   if (state < MODULE_STATE_STARTED)
     return;
 
+  LOG_WARN(LOG_TAG, "%s Shutting the module \"%s\"", __func__, module->name);
   if (!call_lifecycle_function(module->shut_down))
     LOG_ERROR(LOG_TAG, "%s found \"%s\" reported failure during shutdown. Continuing anyway.", __func__, module->name);
+  else
+    LOG_WARN(LOG_TAG, "%s Shutdown the module \"%s\"", __func__, module->name);
 
   set_module_state(module, MODULE_STATE_INITIALIZED);
 }
index 6120039..ebeab56 100644 (file)
@@ -195,6 +195,8 @@ static void *run_thread(void *start_arg) {
   }
   thread->tid = gettid();
 
+  LOG_WARN(LOG_TAG, "%s: thread id %d, thread name %s started", __func__, thread->tid, thread->name);
+
   semaphore_post(start->start_sem);
 
   int fd = fixed_queue_get_dequeue_fd(thread->work_queue);
@@ -219,6 +221,7 @@ static void *run_thread(void *start_arg) {
   if (count > fixed_queue_capacity(thread->work_queue))
     LOG_DEBUG(LOG_TAG, "%s growing event queue on shutdown.", __func__);
 
+  LOG_WARN(LOG_TAG, "%s: thread id %d, thread name %s exited", __func__, thread->tid, thread->name);
   return NULL;
 }