e_info_server/client: add mtrace option 01/244601/3
authorSung-Jin Park <sj76.park@samsung.com>
Tue, 22 Sep 2020 08:12:55 +0000 (17:12 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Tue, 22 Sep 2020 11:37:15 +0000 (20:37 +0900)
Change-Id: Ie642ca21c31c7f16bd8cab423133bc26186933c5
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/bin/e_info_client.c
src/bin/e_info_server.c

index b8887be5bf31365b154ed6ba7b29e048910db2ae..5810e36892d414eee6912afa96d3e43b55b5cf6d 100644 (file)
@@ -6144,6 +6144,35 @@ usage:
    printf("Usage: %s", USAGE_FILTER);
 }
 
+static void
+_e_info_client_proc_mtrace(int argc, char **argv)
+{
+   int enable = 0;
+
+   if (argc == 3)
+     {
+        if ((argv[2][0] != '0' && argv[2][0] != '1'))
+          {
+             printf("Error: invalid argument\n");
+             return;
+          }
+
+        enable = atoi(argv[2]);
+        if (!_e_info_client_eldbus_message_with_args("mtrace", NULL, "i", enable))
+          {
+             printf("_e_info_client_proc_mtrace fail (enable:%d)\n", enable);
+             return;
+          }
+     }
+   else
+     {
+        printf("Error: invalid argument\n");
+        return;
+     }
+
+   return;
+}
+
 static void
 _e_info_client_proc_gcov(int argc, char **argv)
 {
@@ -6486,6 +6515,12 @@ static ProcInfo procs_to_execute[] =
       "Dump stack information by allocations",
       _e_info_client_memchecker
    },
+   {
+      "mtrace",
+      "[enable: 1, disable: 0]",
+      "enable/disable mtrace",
+      _e_info_client_proc_mtrace
+   },
    {
       "magnifier",
       NULL,
index 55b46c32dc48087970f5d2f0d17b2edf66b5b047..fe77b8c8b62f17ec8310ec51d408a0eb09c85e87 100644 (file)
@@ -6942,6 +6942,32 @@ reply:
    return reply;
 }
 
+static Eldbus_Message *
+_e_info_server_cb_mtrace(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   int enable;
+
+   if (!eldbus_message_arguments_get(msg, "i", &enable))
+     {
+        ERR("Error getting argument for enabling mtrace.");
+        return reply;
+     }
+
+   if (enable)
+     {
+        mtrace();
+        INF("mtrace enable=%d", enable);
+     }
+   else
+     {
+        muntrace();
+        INF("mtrace enable=0");
+     }
+
+   return reply;
+}
+
 static Eldbus_Message *
 _e_info_server_cb_gcov(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
 {
@@ -7036,6 +7062,7 @@ static const Eldbus_Method methods[] = {
    { "buffer_flush", ELDBUS_ARGS({"it", "option"}), ELDBUS_ARGS({"s", "buffer_flush status"}), _e_info_server_cb_buffer_flush, 0},
    { "deiconify_approve", ELDBUS_ARGS({"it", "option"}), ELDBUS_ARGS({"s", "deiconify_approve status"}), _e_info_server_cb_deiconify_approve, 0},
    { "key_repeat", ELDBUS_ARGS({"sii", "option"}), NULL, _e_info_server_cb_key_repeat, 0},
+   { "mtrace", ELDBUS_ARGS({"i", "enable"}), NULL, _e_info_server_cb_mtrace, 0},
    { "dump_memchecker", NULL, NULL, _e_info_server_cb_memchecker, 0},
    { "magnifier", ELDBUS_ARGS({"i", "magnifier"}), NULL, e_info_server_cb_magnifier, 0},
    { "input_region", ELDBUS_ARGS({"siiii", "options"}), ELDBUS_ARGS({"a(iiii)", "path"}), _e_info_server_cb_input_region, 0},
@@ -7167,6 +7194,14 @@ _e_info_server_cb_dbus_init_done(void *data, int type, void *event)
 EINTERN int
 e_info_server_init(void)
 {
+   char *s;
+   s = e_util_env_get("MALLOC_TRACE");
+
+   if (s)
+     E_FREE(s);
+   else
+     e_util_env_set("MALLOC_TRACE", "/tmp/e20_mtrace");
+
    e_info_server.edbus_conn = NULL;
    e_info_server.edbus_conn_type = ELDBUS_CONNECTION_TYPE_SYSTEM;
    e_info_server.dbus_init_done_handler = NULL;