'/>
summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/stack.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2009-08-15 12:58:08 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-08-19 17:57:53 -0700
commitb4d6c3d1bb461d2c8a396c9ed3881a4da40fc6ab (patch)
tree7a5a15665d46a91b9d4d744b0da599c4628d7f6c /libglusterfs/src/stack.c
parenta31b0016347b3bc9b341fa0f4541ed137224f593 (diff)
TAKE2[PATCH BUG:213 1/1] Support for Process State Dump
Support for process state dump. Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 213 (Support for process state dump) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=213
Diffstat (limited to 'libglusterfs/src/stack.c')
-rw-r--r--libglusterfs/src/stack.c171
1 files changed, 171 insertions, 0 deletions
diff --git a/libglusterfs/src/stack.c b/libglusterfs/src/stack.c
new file mode 100644
index 00000000000..453248479b3
--- /dev/null
+++ b/libglusterfs/src/stack.c
@@ -0,0 +1,171 @@
+/*
+ Copyright (c) 2009 Z RESEARCH, Inc. <http://www.zresearch.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+#include "statedump.h"
+#include "stack.h"
+
+static inline
+int call_frames_count (call_frame_t *call_frame)
+{
+ call_frame_t *pos;
+ int32_t count = 0;
+
+ if (!call_frame)
+ return count;
+
+ for (pos = call_frame; pos != NULL; pos = pos->next)
+ count++;
+
+ return count;
+}
+
+void
+gf_proc_dump_call_frame (call_frame_t *call_frame, const char *key_buf,...)
+{
+
+ char prefix[GF_DUMP_MAX_BUF_LEN];
+ va_list ap;
+ char key[GF_DUMP_MAX_BUF_LEN];
+ call_frame_t my_frame;
+ int ret = -1;
+
+ if (!call_frame)
+ return;
+
+ assert(key_buf);
+
+ memset(prefix, 0, sizeof(prefix));
+ memset(&my_frame, 0, sizeof(my_frame));
+ va_start(ap, key_buf);
+ vsnprintf(prefix, GF_DUMP_MAX_BUF_LEN, key_buf, ap);
+ va_end(ap);
+
+ ret = TRY_LOCK(&call_frame->lock);
+ if (ret) {
+ gf_log("", GF_LOG_WARNING, "Unable to dump call frame"
+ " errno: %d", errno);
+ return;
+ }
+
+ memcpy(&my_frame, call_frame, sizeof(my_frame));</