Debug improvements from tizen_3.0 25/118925/6
authorMariusz <m.wachowicz@partner.samsung.com>
Tue, 14 Mar 2017 14:35:12 +0000 (15:35 +0100)
committerLukasz <l.oleksak@samsung.com>
Fri, 24 Mar 2017 15:21:08 +0000 (16:21 +0100)
Change-Id: I3a9d5f08a7132c7cd7e4d2cd09086e7355e18861

include/screen_reader_utils.h
src/app_tracker.c
src/flat_navi.c
src/navigator.c
src/screen_reader_tts.c
src/screen_reader_utils.c
src/smart_notification.c

index b4b515675555ef581d08f1cd6afcba945f8c46b6..5295cbc73e347ceaeb5fedae640fab911c3ed33d 100644 (file)
@@ -58,4 +58,7 @@ bool widget_has_state(AtspiAccessible *obj, AtspiStateType type);
 
 char *state_to_char(AtspiStateType state);
 
+const char *get_debug_object_info_implementation(AtspiAccessible *obj, const char *filename, int fileline);
+#define get_debug_object_info(obj) get_debug_object_info_implementation(obj, NULL, 0)
+#define get_debug_object_info_with_location(obj) get_debug_object_info_implementation(obj, __FILE__, __LINE__)
 #endif
index a619046946339c1346537e7026b3fb506a764bd5..63a42164b047eff638e06bc870acd0c15d7dd134 100644 (file)
@@ -122,7 +122,7 @@ static gboolean _on_timeout_rebuild_navigation_context(gpointer user_data)
 
        if (active_window_context->view_content_changed_ecd && active_window_context->view_content_changed_ecd->func) {
                AtspiAccessible *root = active_window_context->modals->data ? active_window_context->modals->data : active_window_context->root;
-               DEBUG("Want to rebuild navigation context for new root = %p", root);
+               DEBUG("Want to rebuild navigation context for new root = %s", get_debug_object_info(root));
                if (root)
                        active_window_context->view_content_changed_ecd->func(root, active_window_context->view_content_changed_ecd->user_data);
        }
@@ -835,7 +835,8 @@ static void app_tracker_switch_active_window_context(void *data, AtspiAccessible
                ERROR("app_tracker module used without initialization");
                return;
        }
-       DEBUG("switching active window context (%p) from root=%p to root=%p",active_window_context, active_window_context->root, root);
+       DEBUG("switching active window context (%p) from root %s to root %s",active_window_context,
+               get_debug_object_info(active_window_context->root), get_debug_object_info(root));
        if (!root) {
                ERROR("Invalid parameter. root is NULL. No top window found!");
                return;
index 7271f67f10e37c2b992f426697f54bc0070ba895..57ae4a9dcc21f9bf67ae907a20b7f42ff0cb36dc 100644 (file)
@@ -17,6 +17,7 @@
 #include "flat_navi.h"
 #include "logger.h"
 #include "smart_notification.h"
+#include "screen_reader_utils.h"
 
 static const AtspiStateType required_states[] = {
        ATSPI_STATE_SHOWING,
@@ -607,9 +608,7 @@ Eina_Bool flat_navi_context_setup(Flat_Navi_Context *ctx, AtspiAccessible *root)
                DEBUG("END -- no context");
                return EINA_FALSE;
        }
-       char *root_name = atspi_accessible_get_name(root, NULL);
-       DEBUG("Creating navigation context for root = %p, root_name = %s", root, root_name);
-       free(root_name);
+       DEBUG("Creating navigation context for root = %s", get_debug_object_info(root));
        ctx->root = root;
        ctx->current = _first(ctx);
        DEBUG("END");
index 28bfe3bdae0057b9095b8455dd9816908d6a7adb..541ee944e2f731f8770a00c3ff4da015c2d3ad17 100644 (file)
@@ -847,7 +847,7 @@ static void _current_highlight_object_set(Navigator_Data *nd, Screen_Reader_Vcon
        DEBUG("START");
 
        if (!obj) {
-               DEBUG("Clearing highlight object");
+               DEBUG("Clearing highlight object %s", get_debug_object_info(nd->current_obj));
                nd->current_obj = NULL;
                if (nd->current_comp) {
                        GError *err = NULL;
@@ -925,7 +925,7 @@ static void _current_highlight_object_set(Navigator_Data *nd, Screen_Reader_Vcon
                tts_speak_customized(text_to_speak, EINA_TRUE, EINA_TRUE, obj, tts_data);
                g_free(text_to_speak);
        } else
-               DEBUG("Unable to highlight on object");
+               DEBUG("Unable to highlight on object %s", get_debug_object_info(obj));
        DEBUG("END");
 }
 
@@ -2491,7 +2491,9 @@ static void _new_highlighted_obj_changed(AtspiAccessible *new_highlighted_obj, v
                return;
        }
 
-       DEBUG("context: %p, current: %p, new_highlighted_obj: %p", context, flat_navi_context_current_get(context), new_highlighted_obj);
+       DEBUG("context: %p, current: %s, new_highlighted_obj: %s", context,
+                       get_debug_object_info(flat_navi_context_current_get(context)),
+                       get_debug_object_info(new_highlighted_obj));
 
        if (context && flat_navi_context_current_get(context) != new_highlighted_obj) {
                flat_navi_context_current_set(context, g_object_ref(new_highlighted_obj));
index 66c1dcea0e0979ac3665590cf5a3bcd788af3188..28eb9cd048ef26706b5526e58071dd5b50aeed1a 100644 (file)
@@ -197,8 +197,8 @@ static void  _reading_status_notify(Signal signal, Read_Command *command)
                if (command->obj) {
                        //do AT-SPI action
                        if (!widget_do_action(command->obj, (char *) get_signal_name(signal)))
-                               ERROR("Failed to do AT-SPI action by name:%s for read command:%p with accessible object:%p",
-                                       get_signal_name(signal), command, command->obj);
+                               ERROR("Failed to do AT-SPI action by name:%s for read command:%p with accessible object:%s",
+                                       get_signal_name(signal), command, get_debug_object_info(command->obj));
                } else {
                        //broadcast dbus signal
                        if (dbus_direct_reading_adapter_emit(signal, command, sd->reading_adapter_data) != 0)
@@ -662,7 +662,7 @@ tts_speak_customized(char *text_to_speak, Eina_Bool want_discard_previous_readin
                return NULL;
        }
 
-       DEBUG("READ COMMAND PARAMS, TEXT: %.63s, DISCARDABLE: %d, ATSPI_OBJECT: %p", text_to_speak, discardable, obj);
+       DEBUG("READ COMMAND PARAMS, TEXT: %.63s, DISCARDABLE: %d, ATSPI_OBJECT: %s", text_to_speak, discardable, get_debug_object_info(obj));
 
        Read_Command *rc = calloc(1, sizeof(Read_Command));
        Read_Context *ctx = &rc->context;
index 9179673b1d01538161a7347941e518c8c666b4ba..49016185a19a4a206e47bea5fd547acdbf6a9cb5 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdlib.h>
 #include "screen_reader_utils.h"
 #include "logger.h"
+#include <glib/gmacros.h>
 
 #ifndef TIZEN_GTEST
 #define TIZEN_PROD_STATIC static
@@ -321,3 +322,53 @@ Eina_Bool widget_do_action(AtspiAccessible *obj, char *expected_action)
        DEBUG("END");
        return ret;
 }
+
+#define BUF_SIZE 4096
+static char *_get_debug_object_info_get_unique_buffer(void)
+{
+       typedef char unique_buf[BUF_SIZE];
+       static unique_buf buffers[4];
+       static unsigned char buffer_index = 0;
+
+       char *buf = buffers[buffer_index];
+       buffer_index = (buffer_index + 1) % (sizeof(buffers) / sizeof(buffers[0]));
+       return buf;
+}
+
+const char *get_debug_object_info_implementation(AtspiAccessible *obj, const char *filename, int fileline)
+{
+       char *text = _get_debug_object_info_get_unique_buffer();
+       char *text_end = text + BUF_SIZE;
+       char *text_pos = text;
+
+#define P(...) do { int off = snprintf(text_pos, text_end - text_pos, __VA_ARGS__); if (off > 0) text_pos += MIN(off, (int)(text_end - text_pos)); } while(0)
+
+       P("[ ");
+       if (filename != NULL)
+               P("%s:%d: ", filename, fileline);
+
+       if (!obj)
+               P("nil");
+       else {
+               gchar *path = atspi_accessible_get_path(obj, NULL);
+               gchar *name = atspi_accessible_get_name(obj, NULL);
+               gchar *role_name = atspi_accessible_get_role_name(obj, NULL);
+
+               P("object %p", obj);
+               if (path) {
+                       P(" path %s", path);
+                       g_free(path);
+               }
+               if (name) {
+                       P(" name %s", name);
+                       g_free(name);
+               }
+               if (role_name) {
+                       P(" role %s", role_name);
+                       g_free(role_name);
+               }
+       }
+       P(" ]");
+#undef P
+       return text;
+}
index 48d8a9d5457f0c269b58045cb8d79c5ebfaa8826..91c495d47caa56ccaf735d8e2f77234d0f8237d3 100644 (file)
@@ -21,6 +21,7 @@
 #include "logger.h"
 #include "screen_reader_tts.h"
 #include "screen_reader_haptic.h"
+#include "screen_reader_utils.h"
 #include "smart_notification.h"
 #include <wav_player.h>
 #include <sound_manager.h>
@@ -177,9 +178,7 @@ static void _scroll_event_cb(AtspiEvent *event, gpointer user_data)
        start_index = 0;
        end_index = 0;
 
-       gchar *role_name = atspi_accessible_get_role_name(event->source, NULL);
-       fprintf(stderr, "Event: %s: %d, obj: %p: role: %s\n", event->type, event->detail1, event->source, role_name);
-       g_free(role_name);
+       DEBUG("Event: %s: %d, obj: %s\n", event->type, event->detail1, get_debug_object_info(event->source));
 
        if (!strcmp(event->type, "object:scroll-start")) {
                DEBUG("Scrolling started");