comparison nspr/pr/src/threads/prdump.c @ 0:1e5118fa0cb1

This is NSS with a Cmake Buildsyste To compile a static NSS library for Windows we've used the Chromium-NSS fork and added a Cmake buildsystem to compile it statically for Windows. See README.chromium for chromium changes and README.trustbridge for our modifications.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 28 Jul 2014 10:47:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e5118fa0cb1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #include "primpl.h"
7
8 #if defined(WIN95)
9 /*
10 ** Some local variables report warnings on Win95 because the code paths
11 ** using them are conditioned on HAVE_CUSTOME_USER_THREADS.
12 ** The pragma suppresses the warning.
13 **
14 */
15 #pragma warning(disable : 4101)
16 #endif
17
18 /* XXX use unbuffered nspr stdio */
19
20 PRFileDesc *_pr_dumpOut;
21
22 PRUint32 _PR_DumpPrintf(PRFileDesc *fd, const char *fmt, ...)
23 {
24 char buf[100];
25 PRUint32 nb;
26 va_list ap;
27
28 va_start(ap, fmt);
29 nb = PR_vsnprintf(buf, sizeof(buf), fmt, ap);
30 va_end(ap);
31 PR_Write(fd, buf, nb);
32
33 return nb;
34 }
35
36 void _PR_DumpThread(PRFileDesc *fd, PRThread *thread)
37 {
38
39 #ifndef _PR_GLOBAL_THREADS_ONLY
40 _PR_DumpPrintf(fd, "%05d[%08p] pri=%2d flags=0x%02x",
41 thread->id, thread, thread->priority, thread->flags);
42 switch (thread->state) {
43 case _PR_RUNNABLE:
44 case _PR_RUNNING:
45 break;
46 case _PR_LOCK_WAIT:
47 _PR_DumpPrintf(fd, " lock=%p", thread->wait.lock);
48 break;
49 case _PR_COND_WAIT:
50 _PR_DumpPrintf(fd, " condvar=%p sleep=%lldms",
51 thread->wait.cvar, thread->sleep);
52 break;
53 case _PR_SUSPENDED:
54 _PR_DumpPrintf(fd, " suspended");
55 break;
56 }
57 PR_Write(fd, "\n", 1);
58 #endif
59
60 /* Now call dump routine */
61 if (thread->dump) {
62 thread->dump(fd, thread, thread->dumpArg);
63 }
64 }
65
66 static void DumpThreadQueue(PRFileDesc *fd, PRCList *list)
67 {
68 #ifndef _PR_GLOBAL_THREADS_ONLY
69 PRCList *q;
70
71 q = list->next;
72 while (q != list) {
73 PRThread *t = _PR_THREAD_PTR(q);
74 _PR_DumpThread(fd, t);
75 q = q->next;
76 }
77 #endif
78 }
79
80 void _PR_DumpThreads(PRFileDesc *fd)
81 {
82 PRThread *t;
83 PRIntn i;
84
85 _PR_DumpPrintf(fd, "Current Thread:\n");
86 t = _PR_MD_CURRENT_THREAD();
87 _PR_DumpThread(fd, t);
88
89 _PR_DumpPrintf(fd, "Runnable Threads:\n");
90 for (i = 0; i < 32; i++) {
91 DumpThreadQueue(fd, &_PR_RUNQ(t->cpu)[i]);
92 }
93
94 _PR_DumpPrintf(fd, "CondVar timed wait Threads:\n");
95 DumpThreadQueue(fd, &_PR_SLEEPQ(t->cpu));
96
97 _PR_DumpPrintf(fd, "CondVar wait Threads:\n");
98 DumpThreadQueue(fd, &_PR_PAUSEQ(t->cpu));
99
100 _PR_DumpPrintf(fd, "Suspended Threads:\n");
101 DumpThreadQueue(fd, &_PR_SUSPENDQ(t->cpu));
102 }
103
104 PR_IMPLEMENT(void) PR_ShowStatus(void)
105 {
106 PRIntn is;
107
108 if ( _PR_MD_CURRENT_THREAD()
109 && !_PR_IS_NATIVE_THREAD(_PR_MD_CURRENT_THREAD())) _PR_INTSOFF(is);
110 _pr_dumpOut = _pr_stderr;
111 _PR_DumpThreads(_pr_dumpOut);
112 if ( _PR_MD_CURRENT_THREAD()
113 && !_PR_IS_NATIVE_THREAD(_PR_MD_CURRENT_THREAD())) _PR_FAST_INTSON(is);
114 }
115
116 PR_IMPLEMENT(void)
117 PR_SetThreadDumpProc(PRThread* thread, PRThreadDumpProc dump, void *arg)
118 {
119 thread->dump = dump;
120 thread->dumpArg = arg;
121 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)