1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* vim:set expandtab ts=4 shiftwidth=4: */ 3 /* 4 * Copyright (C) 2008 Sun Microsystems, Inc. All rights reserved. 5 * Use is subject to license terms. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General 18 * Public License along with this library; if not, write to the 19 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 20 * Boston, MA 02111-1307, USA. 21 * 22 * Authors: Lin Ma <lin.ma (at) sun.com> 23 */ 24 25 #include "config.h" 26 #include <glib.h> 27 #include <glib/gprintf.h> 28 #include "fen-node.h" 29 #include "fen-data.h" 30 #include "fen-kernel.h" 31 #include "fen-missing.h" 32 #include "fen-dump.h" 33 34 G_LOCK_EXTERN (fen_lock); 35 36 /*-------------------- node ------------------*/ 37 static void 38 dump_node (node_t* node, gpointer data) 39 { 40 if (data && node->user_data) { 41 return; 42 } 43 g_printf ("[%s] < 0x%p : 0x%p > %s\n", __func__, node, node->user_data, NODE_NAME(node)); 44 } 45 46 static gboolean 47 dump_node_tree (node_t* node, gpointer user_data) 48 { 49 node_op_t op = {dump_node, NULL, NULL, user_data}; 50 GList* children; 51 GList* i; 52 if (G_TRYLOCK (fen_lock)) { 53 if (node) { 54 travel_nodes (node, &op); 55 } 56 G_UNLOCK (fen_lock); 57 } 58 return TRUE; 59 } 60 61 /* ------------------ fdata port hash --------------------*/ 62 void 63 dump_hash_cb (gpointer key, 64 gpointer value, 65 gpointer user_data) 66 { 67 g_printf ("[%s] < 0x%p : 0x%p >\n", __func__, key, value); 68 } 69 70 gboolean 71 dump_hash (GHashTable* hash, gpointer user_data) 72 { 73 if (G_TRYLOCK (fen_lock)) { 74 if (g_hash_table_size (hash) > 0) { 75 g_hash_table_foreach (hash, dump_hash_cb, user_data); 76 } 77 G_UNLOCK (fen_lock); 78 } 79 return TRUE; 80 } 81 82 /* ------------------ event --------------------*/ 83 void 84 dump_event (fnode_event_t* ev, gpointer user_data) 85 { 86 fdata* data = ev->user_data; 87 g_printf ("[%s] < 0x%p : 0x%p > [ %10s ] %s\n", __func__, ev, ev->user_data, _event_string (ev->e), FN_NAME(data)); 88 } 89 90 void 91 dump_event_queue (fdata* data, gpointer user_data) 92 { 93 if (G_TRYLOCK (fen_lock)) { 94 if (data->eventq) { 95 g_queue_foreach (data->eventq, (GFunc)dump_event, user_data); 96 } 97 G_UNLOCK (fen_lock); 98 } 99 } 100 101