4 * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
6 * Contact: Ja-young Gu <jygu@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
26 #include <communicator.h>
27 #include <user_request.h>
33 #include <core_object.h>
35 #define NOTUSED(var) (var = var)
37 /* hacking TcoreQueue */
38 struct tcore_queue_type {
43 static void _hash_dump(gpointer key, gpointer value, gpointer user_data)
47 msg(" - %s: [%s]", key, value);
50 static void _monitor_core_objects(GSList *list)
58 msg(" Name: [%s]", tcore_object_ref_name(co));
59 msg(" - addr: %p", co);
60 msg(" - type: %p", tcore_object_get_type(co));
61 msg(" - hal: %p", tcore_object_get_hal(co));
63 prop = tcore_object_ref_property_hash(co);
65 msg(" - Properties: %d", g_hash_table_size(prop));
66 g_hash_table_foreach(prop, _hash_dump, NULL);
73 static void _monitor_plugin(Server *s)
82 list = tcore_server_ref_plugins(s);
89 msg("Name: [%s]", tcore_plugin_get_description(p)->name);
91 str = tcore_plugin_get_filename(p);
93 msg(" - file: %s", str);
97 msg(" - addr: %p", p);
98 msg(" - userdata: %p", tcore_plugin_ref_user_data(p));
100 co_list = tcore_plugin_get_core_objects(p);
102 msg(" - core_object list: %d", g_slist_length(co_list));
104 _monitor_core_objects(co_list);
105 g_slist_free(co_list);
114 static void _monitor_storage(Server *s)
119 msg("-- Storages --");
121 list = tcore_server_ref_storages(s);
128 msg("Name: [%s]", tcore_storage_ref_name(strg));
129 msg(" - addr: %p", strg);
136 static void _monitor_communicator(Server *s)
141 msg("-- Coomunicators --");
143 list = tcore_server_ref_communicators(s);
150 msg("Name: [%s]", tcore_communicator_ref_name(comm));
151 msg(" - addr: %p", comm);
152 msg(" - parent_plugin: %p", tcore_communicator_ref_plugin(comm));
153 msg(" - userdata: %p", tcore_communicator_ref_user_data(comm));
160 static void _monitor_hal(Server *s)
165 TcorePending *pending;
171 unsigned int data_len;
175 list = tcore_server_ref_hals(s);
182 str = tcore_hal_get_name(h);
184 msg("Name: [%s]", str);
187 msg(" - addr: %p", h);
188 msg(" - parent_plugin: %p", tcore_hal_ref_plugin(h));
189 msg(" - userdata: %p", tcore_hal_ref_user_data(h));
191 q = tcore_hal_ref_queue(h);
204 qlen = tcore_queue_get_length(q);
205 msg(" - queue: %p, length: %d", q, qlen);
206 msg(" queue_head: %p", g_queue_peek_head(q->gq));
207 for (i = 0; i < qlen; i++) {
208 pending = g_queue_peek_nth(q->gq, i);
209 ur = tcore_pending_ref_user_request(pending);
210 msg(" [%02d] pending=%p, id=0x%x, ur=%p", i, pending, tcore_pending_get_id(pending), ur);
212 msg(" ur request command = 0x%x", tcore_user_request_get_command(ur));
215 data = tcore_pending_ref_request_data(pending, &data_len);
216 msg(" data=%p, data_len=%d", data, data_len);
218 msg(" queue_tail: %p", g_queue_peek_tail(q->gq));
225 void monitor_server_state(Server *s)
229 _monitor_communicator(s);