Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
d7012e8f
Commit
d7012e8f
authored
9 years ago
by
Alexey Kudravtsev
Browse files
Options
Download
Email Patches
Plain Diff
cleanup
parent
5ec0ec30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
platform/util/src/com/intellij/diagnostic/ThreadDump.java
+4
-4
platform/util/src/com/intellij/diagnostic/ThreadDump.java
platform/util/src/com/intellij/diagnostic/ThreadDumper.java
+23
-22
platform/util/src/com/intellij/diagnostic/ThreadDumper.java
with
27 additions
and
26 deletions
+27
-26
platform/util/src/com/intellij/diagnostic/ThreadDump.java
+
4
-
4
View file @
d7012e8f
...
...
@@ -22,12 +22,12 @@ import org.jetbrains.annotations.Nullable;
* Represents thread dump of the IDE captured by its performance diagnostic tool.
*/
public
class
ThreadDump
{
private
String
myRawDump
;
private
StackTraceElement
[]
myEdtStack
;
private
final
String
myRawDump
;
private
final
StackTraceElement
[]
myEdtStack
;
ThreadDump
(
@NotNull
String
rawDump
,
@Nullable
StackTraceElement
[]
edtStack
)
{
this
.
myRawDump
=
rawDump
;
this
.
myEdtStack
=
edtStack
;
myRawDump
=
rawDump
;
myEdtStack
=
edtStack
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
platform/util/src/com/intellij/diagnostic/ThreadDumper.java
+
23
-
22
View file @
d7012e8f
/*
* Copyright 2000-201
4
JetBrains s.r.o.
* Copyright 2000-201
5
JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -35,6 +35,7 @@ public class ThreadDumper {
private
ThreadDumper
()
{
}
@NotNull
public
static
String
dumpThreadsToString
()
{
StringWriter
writer
=
new
StringWriter
();
dumpThreadsToFile
(
ManagementFactory
.
getThreadMXBean
(),
writer
);
...
...
@@ -49,20 +50,13 @@ public class ThreadDumper {
}
@Nullable
static
StackTraceElement
[]
dumpThreadsToFile
(
fina
l
ThreadMXBean
threadMXBean
,
fina
l
Writer
f
)
{
private
static
StackTraceElement
[]
dumpThreadsToFile
(
@NotNul
l
ThreadMXBean
threadMXBean
,
@NotNul
l
Writer
f
)
{
StackTraceElement
[]
edtStack
=
null
;
boolean
dumpSuccessful
=
false
;
try
{
ThreadInfo
[]
threads
=
sort
(
threadMXBean
.
dumpAllThreads
(
false
,
false
));
for
(
ThreadInfo
info:
threads
)
{
if
(
info
!=
null
)
{
if
(
info
.
getThreadName
().
equals
(
"AWT-EventQueue-1"
))
{
edtStack
=
info
.
getStackTrace
();
}
dumpThreadInfo
(
info
,
f
);
}
}
edtStack
=
dumpThreadInfos
(
threads
,
f
);
dumpSuccessful
=
true
;
}
catch
(
Exception
ignored
)
{
...
...
@@ -72,20 +66,27 @@ public class ThreadDumper {
if
(!
dumpSuccessful
)
{
final
long
[]
threadIds
=
threadMXBean
.
getAllThreadIds
();
final
ThreadInfo
[]
threadInfo
=
sort
(
threadMXBean
.
getThreadInfo
(
threadIds
,
Integer
.
MAX_VALUE
));
for
(
ThreadInfo
info
:
threadInfo
)
{
if
(
info
!=
null
)
{
if
(
info
.
getThreadName
().
equals
(
"AWT-EventQueue-1"
))
{
edtStack
=
info
.
getStackTrace
();
}
dumpThreadInfo
(
info
,
f
);
edtStack
=
dumpThreadInfos
(
threadInfo
,
f
);
}
return
edtStack
;
}
private
static
StackTraceElement
[]
dumpThreadInfos
(
@NotNull
ThreadInfo
[]
threadInfo
,
@NotNull
Writer
f
)
{
StackTraceElement
[]
edtStack
=
null
;
for
(
ThreadInfo
info
:
threadInfo
)
{
if
(
info
!=
null
)
{
if
(
info
.
getThreadName
().
equals
(
"AWT-EventQueue-1"
))
{
edtStack
=
info
.
getStackTrace
();
}
dumpThreadInfo
(
info
,
f
);
}
}
return
edtStack
;
}
private
static
ThreadInfo
[]
sort
(
ThreadInfo
[]
threads
)
{
@NotNull
private
static
ThreadInfo
[]
sort
(
@NotNull
ThreadInfo
[]
threads
)
{
Arrays
.
sort
(
threads
,
new
Comparator
<
ThreadInfo
>()
{
@Override
public
int
compare
(
ThreadInfo
o1
,
ThreadInfo
o2
)
{
...
...
@@ -104,11 +105,11 @@ public class ThreadDumper {
return
threads
;
}
private
static
void
dumpThreadInfo
(
fina
l
ThreadInfo
info
,
fina
l
Writer
f
)
{
private
static
void
dumpThreadInfo
(
@NotNul
l
ThreadInfo
info
,
@NotNul
l
Writer
f
)
{
dumpCallStack
(
info
,
f
,
info
.
getStackTrace
());
}
private
static
void
dumpCallStack
(
fina
l
ThreadInfo
info
,
fina
l
Writer
f
,
fina
l
StackTraceElement
[]
stackTraceElements
)
{
private
static
void
dumpCallStack
(
@NotNul
l
ThreadInfo
info
,
@NotNul
l
Writer
f
,
@NotNul
l
StackTraceElement
[]
stackTraceElements
)
{
try
{
@NonNls
StringBuilder
sb
=
new
StringBuilder
(
"\""
).
append
(
info
.
getThreadName
()).
append
(
"\""
);
sb
.
append
(
" prio=0 tid=0x0 nid=0x0 "
).
append
(
getReadableState
(
info
.
getThreadState
())).
append
(
"\n"
);
...
...
@@ -133,11 +134,11 @@ public class ThreadDumper {
f
.
write
(
"\n"
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
(
);
throw
new
RuntimeException
(
e
);
}
}
private
static
String
getReadableState
(
Thread
.
State
state
)
{
private
static
String
getReadableState
(
@NotNull
Thread
.
State
state
)
{
switch
(
state
)
{
case
BLOCKED:
return
"blocked"
;
case
TIMED_WAITING:
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment