Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gk0749
jadx
提交
01f47282
J
jadx
项目概览
gk0749
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
01f47282
编写于
12月 18, 2021
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: forbid 'printStackTrace()' usage
上级
afdd37cd
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
128 addition
and
94 deletion
+128
-94
config/checkstyle/checkstyle.xml
config/checkstyle/checkstyle.xml
+6
-0
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
+4
-4
jadx-core/src/test/java/jadx/tests/integration/inline/TestIssue86.java
.../test/java/jadx/tests/integration/inline/TestIssue86.java
+1
-0
jadx-core/src/test/java/jadx/tests/integration/switches/TestSwitchWithTryCatch.java
...dx/tests/integration/switches/TestSwitchWithTryCatch.java
+1
-0
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestMultiExceptionCatch2.java
.../tests/integration/trycatch/TestMultiExceptionCatch2.java
+1
-0
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatch7.java
...t/java/jadx/tests/integration/trycatch/TestTryCatch7.java
+1
-0
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatchFinally.java
.../jadx/tests/integration/trycatch/TestTryCatchFinally.java
+1
-0
jadx-core/src/test/java/jadx/tests/integration/variables/TestVariables4.java
...java/jadx/tests/integration/variables/TestVariables4.java
+1
-0
jadx-gui/src/main/java/jadx/gui/device/debugger/BreakpointManager.java
...main/java/jadx/gui/device/debugger/BreakpointManager.java
+9
-5
jadx-gui/src/main/java/jadx/gui/device/debugger/DbgUtils.java
...-gui/src/main/java/jadx/gui/device/debugger/DbgUtils.java
+4
-1
jadx-gui/src/main/java/jadx/gui/device/debugger/DebugController.java
...c/main/java/jadx/gui/device/debugger/DebugController.java
+8
-2
jadx-gui/src/main/java/jadx/gui/device/debugger/SmaliDebugger.java
...src/main/java/jadx/gui/device/debugger/SmaliDebugger.java
+11
-11
jadx-gui/src/main/java/jadx/gui/device/protocol/ADB.java
jadx-gui/src/main/java/jadx/gui/device/protocol/ADB.java
+13
-9
jadx-gui/src/main/java/jadx/gui/ui/TabbedPane.java
jadx-gui/src/main/java/jadx/gui/ui/TabbedPane.java
+1
-1
jadx-gui/src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java
.../src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java
+9
-11
jadx-gui/src/main/java/jadx/gui/ui/codearea/SmaliArea.java
jadx-gui/src/main/java/jadx/gui/ui/codearea/SmaliArea.java
+10
-6
jadx-gui/src/main/java/jadx/gui/ui/dialog/ADBDialog.java
jadx-gui/src/main/java/jadx/gui/ui/dialog/ADBDialog.java
+34
-36
jadx-gui/src/main/java/jadx/gui/ui/popupmenu/VarTreePopupMenu.java
...src/main/java/jadx/gui/ui/popupmenu/VarTreePopupMenu.java
+13
-8
未找到文件。
config/checkstyle/checkstyle.xml
浏览文件 @
01f47282
...
...
@@ -124,6 +124,12 @@
<module
name=
"IllegalImport"
>
<property
name=
"illegalClasses"
value=
"jadx.core.utils.DebugUtils"
/>
</module>
<module
name=
"RegexpSinglelineJava"
>
<property
name=
"id"
value=
"printstacktrace"
/>
<property
name=
"format"
value=
"\.printStackTrace\(\)"
/>
<property
name=
"ignoreComments"
value=
"true"
/>
<property
name=
"message"
value=
"Using Throwable.printStackTrace() is forbidden. Use logger to print exception"
/>
</module>
</module>
<module
name=
"NewlineAtEndOfFile"
/>
...
...
jadx-core/src/test/java/jadx/tests/api/IntegrationTest.java
浏览文件 @
01f47282
...
...
@@ -65,8 +65,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
fail
;
public
abstract
class
IntegrationTest
extends
TestUtils
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
IntegrationTest
.
class
);
private
static
final
String
TEST_DIRECTORY
=
"src/test/java"
;
private
static
final
String
TEST_DIRECTORY2
=
"jadx-core/"
+
TEST_DIRECTORY
;
...
...
@@ -150,7 +150,7 @@ public abstract class IntegrationTest extends TestUtils {
assertThat
(
"File list is empty"
,
files
,
not
(
empty
()));
return
getClassNodeFromFiles
(
files
,
clazz
.
getName
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Failed to get class node"
,
e
);
fail
(
e
.
getMessage
());
}
return
null
;
...
...
@@ -194,7 +194,7 @@ public abstract class IntegrationTest extends TestUtils {
try
{
d
.
load
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Load failed"
,
e
);
d
.
close
();
fail
(
e
.
getMessage
());
return
null
;
...
...
@@ -332,7 +332,7 @@ public abstract class IntegrationTest extends TestUtils {
runDecompiledAutoCheck
(
cls
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Auto check failed"
,
e
);
fail
(
"Auto check exception: "
+
e
.
getMessage
());
}
}
...
...
jadx-core/src/test/java/jadx/tests/integration/inline/TestIssue86.java
浏览文件 @
01f47282
...
...
@@ -11,6 +11,7 @@ import jadx.tests.api.IntegrationTest;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
@SuppressWarnings
(
"checkstyle:printstacktrace"
)
public
class
TestIssue86
extends
IntegrationTest
{
public
static
class
TestCls
{
...
...
jadx-core/src/test/java/jadx/tests/integration/switches/TestSwitchWithTryCatch.java
浏览文件 @
01f47282
...
...
@@ -8,6 +8,7 @@ import jadx.tests.api.IntegrationTest;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
countString
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
@SuppressWarnings
(
"checkstyle:printstacktrace"
)
public
class
TestSwitchWithTryCatch
extends
IntegrationTest
{
public
static
class
TestCls
{
void
test
(
int
a
)
{
...
...
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestMultiExceptionCatch2.java
浏览文件 @
01f47282
...
...
@@ -11,6 +11,7 @@ import jadx.tests.api.IntegrationTest;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
@SuppressWarnings
(
"checkstyle:printstacktrace"
)
public
class
TestMultiExceptionCatch2
extends
IntegrationTest
{
public
static
class
TestCls
{
...
...
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatch7.java
浏览文件 @
01f47282
...
...
@@ -8,6 +8,7 @@ import jadx.tests.api.IntegrationTest;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
@SuppressWarnings
(
"checkstyle:printstacktrace"
)
public
class
TestTryCatch7
extends
IntegrationTest
{
public
static
class
TestCls
{
...
...
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatchFinally.java
浏览文件 @
01f47282
...
...
@@ -7,6 +7,7 @@ import jadx.tests.api.IntegrationTest;
import
static
jadx
.
tests
.
api
.
utils
.
assertj
.
JadxAssertions
.
assertThat
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
@SuppressWarnings
(
"checkstyle:printstacktrace"
)
public
class
TestTryCatchFinally
extends
IntegrationTest
{
public
static
class
TestCls
{
...
...
jadx-core/src/test/java/jadx/tests/integration/variables/TestVariables4.java
浏览文件 @
01f47282
...
...
@@ -11,6 +11,7 @@ import jadx.tests.api.IntegrationTest;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
@SuppressWarnings
(
"checkstyle:printstacktrace"
)
public
class
TestVariables4
extends
IntegrationTest
{
public
static
class
TestCls
{
...
...
jadx-gui/src/main/java/jadx/gui/device/debugger/BreakpointManager.java
浏览文件 @
01f47282
package
jadx.gui.device.debugger
;
import
java.io.IOException
;
import
java.lang.reflect.Type
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
...
...
@@ -15,6 +14,9 @@ import java.util.Map;
import
java.util.Map.Entry
;
import
java.util.Objects
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.google.gson.Gson
;
import
com.google.gson.GsonBuilder
;
import
com.google.gson.reflect.TypeToken
;
...
...
@@ -24,6 +26,8 @@ import jadx.gui.device.debugger.smali.Smali;
import
jadx.gui.treemodel.JClass
;
public
class
BreakpointManager
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
BreakpointManager
.
class
);
private
static
Gson
gson
=
null
;
private
static
final
Type
TYPE_TOKEN
=
new
TypeToken
<
Map
<
String
,
List
<
FileBreakpoint
>>>()
{
}.
getType
();
...
...
@@ -56,8 +60,8 @@ public class BreakpointManager {
try
{
byte
[]
bytes
=
Files
.
readAllBytes
(
savePath
);
bpm
=
gson
.
fromJson
(
new
String
(
bytes
,
StandardCharsets
.
UTF_8
),
TYPE_TOKEN
);
}
catch
(
IO
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Failed to read breakpoints config: {}"
,
savePath
,
e
);
}
}
if
(
bpm
==
null
)
{
...
...
@@ -147,8 +151,8 @@ public class BreakpointManager {
private
static
void
sync
()
{
try
{
Files
.
write
(
savePath
,
gson
.
toJson
(
bpm
).
getBytes
(
StandardCharsets
.
UTF_8
));
}
catch
(
IO
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Failed to write breakpoints config: {}"
,
savePath
,
e
);
}
}
...
...
jadx-gui/src/main/java/jadx/gui/device/debugger/DbgUtils.java
浏览文件 @
01f47282
...
...
@@ -6,6 +6,8 @@ import java.util.Map;
import
java.util.Map.Entry
;
import
org.jetbrains.annotations.Nullable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
jadx.api.JavaClass
;
import
jadx.api.ResourceFile
;
...
...
@@ -18,6 +20,7 @@ import jadx.gui.treemodel.JNode;
import
jadx.gui.ui.MainWindow
;
public
class
DbgUtils
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
DbgUtils
.
class
);
private
static
Map
<
ClassInfo
,
Smali
>
smaliCache
=
Collections
.
emptyMap
();
...
...
@@ -156,7 +159,7 @@ public class DbgUtils {
return
androidManifest
.
loadContent
().
getText
().
getCodeStr
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"AndroidManifest.xml search error"
,
e
);
}
return
""
;
}
...
...
jadx-gui/src/main/java/jadx/gui/device/debugger/DebugController.java
浏览文件 @
01f47282
...
...
@@ -13,6 +13,9 @@ import java.util.concurrent.Executors;
import
javax.swing.tree.DefaultMutableTreeNode
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
io.reactivex.annotations.NonNull
;
import
io.reactivex.annotations.Nullable
;
...
...
@@ -42,6 +45,8 @@ import jadx.gui.ui.panel.JDebuggerPanel.ValueTreeNode;
import
static
jadx
.
gui
.
device
.
debugger
.
SmaliDebugger
.
RuntimeType
;
public
final
class
DebugController
implements
SmaliDebugger
.
SuspendListener
,
IDebugController
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
DebugController
.
class
);
private
static
final
String
ONCREATE_SIGNATURE
=
"onCreate(Landroid/os/Bundle;)V"
;
private
static
final
Map
<
String
,
RuntimeType
>
TYPE_MAP
=
new
HashMap
<>();
private
static
final
RuntimeType
[]
POSSIBLE_TYPES
=
{
RuntimeType
.
OBJECT
,
RuntimeType
.
INT
,
RuntimeType
.
LONG
};
...
...
@@ -924,16 +929,17 @@ public final class DebugController implements SmaliDebugger.SuspendListener, IDe
private
void
logErr
(
Exception
e
,
String
extra
)
{
debuggerPanel
.
log
(
e
.
getMessage
());
debuggerPanel
.
log
(
extra
);
e
.
printStackTrace
(
);
LOG
.
error
(
extra
,
e
);
}
private
void
logErr
(
Exception
e
)
{
debuggerPanel
.
log
(
e
.
getMessage
());
e
.
printStackTrace
(
);
LOG
.
error
(
"Debug error"
,
e
);
}
private
void
logErr
(
String
e
)
{
debuggerPanel
.
log
(
e
);
LOG
.
error
(
"Debug error: {}"
,
e
);
}
private
void
scrollToPos
(
long
codeOffset
)
{
...
...
jadx-gui/src/main/java/jadx/gui/device/debugger/SmaliDebugger.java
浏览文件 @
01f47282
...
...
@@ -17,6 +17,9 @@ import java.util.concurrent.Executors;
import
java.util.concurrent.SynchronousQueue
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
io.github.hqktech.JDWP
;
import
io.github.hqktech.JDWP.ArrayReference.Length.LengthReplyData
;
import
io.github.hqktech.JDWP.ByteBuffer
;
...
...
@@ -78,6 +81,7 @@ import jadx.gui.utils.ObjectPool;
public
class
SmaliDebugger
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
SmaliDebugger
.
class
);
private
final
JDWP
jdwp
;
private
int
localTcpPort
;
private
InputStream
inputStream
;
...
...
@@ -375,7 +379,7 @@ public class SmaliDebugger {
try
{
resume
();
}
catch
(
SmaliDebuggerException
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Resume failed"
,
e
);
}
}
});
...
...
@@ -410,13 +414,13 @@ public class SmaliDebugger {
eventListenerMap
.
remove
(
reqID
);
}
}
catch
(
SmaliDebuggerException
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Method entry failed"
,
e
);
}
finally
{
if
(!
removeListener
)
{
try
{
resume
();
}
catch
(
SmaliDebuggerException
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Resume failed"
,
e
);
}
}
}
...
...
@@ -690,7 +694,7 @@ public class SmaliDebugger {
printUnexpectedID
(
res
.
getID
());
}
}
catch
(
SmaliDebuggerException
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Error in debugger decoding loop"
,
e
);
if
(!
errFromCallback
)
{
// fatal error
break
;
}
...
...
@@ -721,8 +725,8 @@ public class SmaliDebugger {
sendCommand
(
buf
,
res
->
{
try
{
store
.
put
(
res
);
}
catch
(
Interrupted
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Command send failed"
,
e
);
}
});
Integer
id
=
syncQueueID
.
getAndAdd
(
1
);
...
...
@@ -757,11 +761,7 @@ public class SmaliDebugger {
for
(
JDWP
.
EventRequestDecoder
event
:
data
.
events
)
{
EventListenerAdapter
listener
=
eventListenerMap
.
get
(
event
.
getRequestID
());
if
(
listener
==
null
)
{
try
{
printUnexpectedID
(
event
.
getRequestID
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
LOG
.
error
(
"Missing handler for id: {}"
,
event
.
getRequestID
());
continue
;
}
if
(
event
instanceof
VMStartEvent
)
{
...
...
jadx-gui/src/main/java/jadx/gui/device/protocol/ADB.java
浏览文件 @
01f47282
...
...
@@ -14,11 +14,16 @@ import java.util.concurrent.ExecutorService;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.TimeUnit
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
io.reactivex.annotations.NonNull
;
import
jadx.core.utils.StringUtils
;
public
class
ADB
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ADB
.
class
);
private
static
final
int
DEFAULT_PORT
=
5037
;
private
static
final
String
DEFAULT_ADDR
=
"localhost"
;
...
...
@@ -138,8 +143,8 @@ public class ADB {
try
{
proc
.
waitFor
(
3
,
TimeUnit
.
SECONDS
);
// for listening to a port, 3 sec should be more than enough.
proc
.
exitValue
();
}
catch
(
Interrupted
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Start server error"
,
e
);
proc
.
destroyForcibly
();
return
false
;
}
...
...
@@ -155,10 +160,9 @@ public class ADB {
Socket
sock
=
new
Socket
(
host
,
port
);
sock
.
close
();
return
true
;
}
catch
(
IO
Exception
e
)
{
e
.
printStackTrace
()
;
}
catch
(
Exception
e
)
{
return
false
;
}
return
false
;
}
/**
...
...
@@ -404,8 +408,8 @@ public class ADB {
if
(
list
.
size
()
!=
0
)
{
androidReleaseVer
=
list
.
get
(
0
);
}
}
catch
(
IO
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Failed to get android release version"
,
e
);
androidReleaseVer
=
""
;
}
return
androidReleaseVer
;
...
...
@@ -510,8 +514,8 @@ public class ADB {
if
(
jdwpListenerSock
!=
null
)
{
try
{
jdwpListenerSock
.
close
();
}
catch
(
IO
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"JDWP socket close failed"
,
e
);
}
}
this
.
jdwpListenerSock
=
null
;
...
...
jadx-gui/src/main/java/jadx/gui/ui/TabbedPane.java
浏览文件 @
01f47282
...
...
@@ -195,7 +195,7 @@ public class TabbedPane extends JTabbedPane {
jumpPos
.
setPos
(
offs
);
codeArea
.
scrollToPos
(
offs
);
}
catch
(
BadLocationException
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Failed to jump to position: {}"
,
pos
,
e
);
codeArea
.
scrollToLine
(
line
);
}
}
...
...
jadx-gui/src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java
浏览文件 @
01f47282
...
...
@@ -142,6 +142,7 @@ public abstract class AbstractCodeArea extends RSyntaxTextArea {
return
lastText
;
}
@Nullable
public
String
getWordUnderCaret
()
{
return
getWordByPosition
(
getCaretPosition
());
}
...
...
@@ -156,7 +157,7 @@ public abstract class AbstractCodeArea extends RSyntaxTextArea {
}
start
++;
}
catch
(
BadLocationException
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Failed to find word start"
,
e
);
start
=
-
1
;
}
return
start
;
...
...
@@ -171,29 +172,26 @@ public abstract class AbstractCodeArea extends RSyntaxTextArea {
}
while
(
end
<
max
&&
!
StringUtils
.
isWordSeparator
(
getText
(
end
,
1
).
charAt
(
0
)));
}
}
catch
(
BadLocationException
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Failed to find word end"
,
e
);
end
=
max
;
}
return
end
;
}
@Nullable
public
String
getWordByPosition
(
int
pos
)
{
String
text
;
int
len
=
getDocument
().
getLength
();
int
start
=
getWordStart
(
pos
);
int
end
=
getWordEnd
(
pos
,
len
);
try
{
if
(
end
>
start
)
{
text
=
getText
(
start
,
end
-
start
);
}
else
{
text
=
null
;
if
(
end
<=
start
)
{
return
null
;
}
return
getText
(
start
,
end
-
start
);
}
catch
(
BadLocationException
e
)
{
e
.
printStackTrace
();
System
.
out
.
printf
(
"start: %d end: %d%n"
,
start
,
end
);
text
=
null
;
LOG
.
error
(
"Failed to get word at pos: {}, start: {}, end: {}"
,
pos
,
start
,
end
,
e
);
return
null
;
}
return
text
;
}
/**
...
...
jadx-gui/src/main/java/jadx/gui/ui/codearea/SmaliArea.java
浏览文件 @
01f47282
...
...
@@ -32,6 +32,8 @@ import org.fife.ui.rtextarea.GutterIconInfo;
import
org.fife.ui.rtextarea.IconRowHeader
;
import
org.fife.ui.rtextarea.RTextArea
;
import
org.fife.ui.rtextarea.RTextAreaUI
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
jadx.gui.device.debugger.BreakpointManager
;
import
jadx.gui.device.debugger.DbgUtils
;
...
...
@@ -44,6 +46,8 @@ import jadx.gui.utils.NLS;
import
jadx.gui.utils.UiUtils
;
public
final
class
SmaliArea
extends
AbstractCodeArea
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
SmaliArea
.
class
);
private
static
final
long
serialVersionUID
=
1334485631870306494L
;
private
static
final
Icon
ICON_BREAKPOINT
=
UiUtils
.
openSvgIcon
(
"debugger/db_set_breakpoint"
);
...
...
@@ -260,8 +264,8 @@ public final class SmaliArea extends AbstractCodeArea {
int
line
;
try
{
line
=
getLineOfOffset
(
pos
);
}
catch
(
BadLocationException
badLocationException
)
{
badLocationException
.
printStackTrace
(
);
}
catch
(
BadLocationException
e
)
{
LOG
.
error
(
"Failed to get line by offset: {}"
,
pos
,
e
);
return
;
}
BreakpointLine
bpLine
=
bpMap
.
remove
(
line
);
...
...
@@ -287,7 +291,7 @@ public final class SmaliArea extends AbstractCodeArea {
int
line
=
getLineOfOffset
(
pos
);
runningHighlightTag
=
addLineHighlight
(
line
,
DEBUG_LINE_COLOR
);
}
catch
(
BadLocationException
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Failed to get line by offset: {}"
,
pos
,
e
);
}
}
...
...
@@ -296,7 +300,7 @@ public final class SmaliArea extends AbstractCodeArea {
int
line
=
getLineOfOffset
(
pos
);
bpMap
.
computeIfAbsent
(
line
,
k
->
new
BreakpointLine
(
line
)).
setDisabled
(
true
);
}
catch
(
BadLocationException
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Failed to get line by offset: {}"
,
pos
,
e
);
}
}
...
...
@@ -377,7 +381,7 @@ public final class SmaliArea extends AbstractCodeArea {
try
{
iconInfo
=
gutter
.
addLineTrackingIcon
(
line
,
ICON_BREAKPOINT_DISABLED
);
}
catch
(
BadLocationException
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Failed to add line tracking icon"
,
e
);
}
}
}
else
{
...
...
@@ -387,7 +391,7 @@ public final class SmaliArea extends AbstractCodeArea {
iconInfo
=
gutter
.
addLineTrackingIcon
(
line
,
ICON_BREAKPOINT
);
highlightTag
=
addLineHighlight
(
line
,
BREAKPOINT_LINE_COLOR
);
}
catch
(
BadLocationException
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Failed to remove line tracking icon"
,
e
);
}
}
}
...
...
jadx-gui/src/main/java/jadx/gui/ui/dialog/ADBDialog.java
浏览文件 @
01f47282
...
...
@@ -10,7 +10,6 @@ import java.awt.Label;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.Socket
;
import
java.util.ArrayList
;
import
java.util.Collections
;
...
...
@@ -36,6 +35,9 @@ import javax.swing.tree.DefaultTreeModel;
import
javax.swing.tree.TreePath
;
import
javax.swing.tree.TreeSelectionModel
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
jadx.core.utils.StringUtils
;
import
jadx.core.utils.exceptions.JadxRuntimeException
;
import
jadx.gui.device.debugger.DbgUtils
;
...
...
@@ -44,11 +46,14 @@ import jadx.gui.treemodel.JClass;
import
jadx.gui.ui.MainWindow
;
import
jadx.gui.ui.panel.IDebugController
;
import
jadx.gui.utils.NLS
;
import
jadx.gui.utils.SystemInfo
;
import
jadx.gui.utils.UiUtils
;
import
static
jadx
.
gui
.
device
.
protocol
.
ADB
.
Device
.
ForwardResult
;
public
class
ADBDialog
extends
JDialog
implements
ADB
.
DeviceStateListener
,
ADB
.
JDWPProcessListener
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ADBDialog
.
class
);
private
static
final
long
serialVersionUID
=
-
1111111202102181630L
;
private
static
final
ImageIcon
ICON_DEVICE
=
UiUtils
.
openSvgIcon
(
"adb/androidDevice"
);
private
static
final
ImageIcon
ICON_PROCESS
=
UiUtils
.
openSvgIcon
(
"adb/addToWatch"
);
...
...
@@ -185,8 +190,8 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
if
(
deviceSocket
!=
null
)
{
try
{
deviceSocket
.
close
();
}
catch
(
IO
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Failed to close device socket"
,
e
);
}
deviceSocket
=
null
;
}
...
...
@@ -197,13 +202,7 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
}
private
void
detectADBPath
()
{
boolean
isWinOS
;
try
{
isWinOS
=
System
.
getProperty
(
"os.name"
).
startsWith
(
"Windows"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
;
}
boolean
isWinOS
=
SystemInfo
.
IS_WINDOWS
;
String
slash
=
isWinOS
?
"\\"
:
"/"
;
String
adbName
=
isWinOS
?
"adb.exe"
:
"adb"
;
String
sdkPath
=
System
.
getenv
(
"ANDROID_HOME"
);
...
...
@@ -244,9 +243,9 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
}
else
{
tip
=
NLS
.
str
(
"adb_dialog.start_fail"
,
portTextField
.
getText
());
}
}
catch
(
Exception
e
xcept
)
{
tip
=
except
.
getMessage
(
);
except
.
printStackTrac
e
();
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Failed to start adb server"
,
e
);
tip
=
e
.
getMessag
e
();
}
UiUtils
.
showMessageBox
(
mainWindow
,
tip
);
tipLabel
.
setText
(
tip
);
...
...
@@ -265,8 +264,8 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
}
else
{
tip
=
NLS
.
str
(
"adb_dialog.connect_fail"
);
}
}
catch
(
IO
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Failed to connect to adb"
,
e
);
tip
=
e
.
getMessage
();
UiUtils
.
showMessageBox
(
mainWindow
,
tip
);
}
...
...
@@ -346,26 +345,25 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
}
private
static
boolean
attachProcess
(
MainWindow
mainWindow
)
{
boolean
ok
=
false
;
if
(
debugSetter
==
null
)
{
return
ok
;
return
false
;
}
debugSetter
.
clearForward
();
String
rst
=
debugSetter
.
forwardJDWP
();
if
(!
rst
.
isEmpty
())
{
UiUtils
.
showMessageBox
(
mainWindow
,
rst
);
return
ok
;
return
false
;
}
try
{
ok
=
mainWindow
.
getDebuggerPanel
().
showDebugger
(
return
mainWindow
.
getDebuggerPanel
().
showDebugger
(
debugSetter
.
name
,
debugSetter
.
device
.
getDeviceInfo
().
adbHost
,
debugSetter
.
forwardTcpPort
,
debugSetter
.
ver
);
}
catch
(
Exception
except
)
{
except
.
printStackTrace
();
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Failed to attach to process"
,
e
);
return
false
;
}
return
ok
;
}
public
static
boolean
launchForDebugging
(
MainWindow
mainWindow
,
String
fullAppPath
,
boolean
autoAttach
)
{
...
...
@@ -379,7 +377,7 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
return
attachProcess
(
mainWindow
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Failed to launch app"
,
e
);
}
}
return
false
;
...
...
@@ -416,8 +414,8 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
private
void
listenJDWP
(
ADB
.
Device
device
)
{
try
{
device
.
listenForJDWP
(
this
);
}
catch
(
IO
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Failed listen for JDWP"
,
e
);
}
}
...
...
@@ -451,8 +449,8 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
* otherwise we may not get its real name but the <pre-initialized> state text.
*/
procs
=
device
.
getProcessList
();
}
catch
(
IOException
|
Interrupted
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Failed to get device process list"
,
e
);
procs
=
Collections
.
emptyList
();
}
List
<
String
>
procList
=
new
ArrayList
<>(
id
.
size
());
...
...
@@ -470,7 +468,7 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
try
{
node
=
getDeviceNode
(
device
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Failed to find device"
,
e
);
return
;
}
node
.
tNode
.
removeAllChildren
();
...
...
@@ -521,7 +519,7 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
try
{
device
.
launchApp
(
fullName
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"Failed to launch app: {}"
,
fullName
,
e
);
UiUtils
.
showMessageBox
(
mainWindow
,
e
.
getMessage
());
}
}
...
...
@@ -652,8 +650,8 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
resultDesc
=
rst
.
desc
;
break
;
}
while
(
true
);
}
catch
(
IO
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"JDWP forward error"
,
e
);
}
if
(
StringUtils
.
isEmpty
(
resultDesc
))
{
resultDesc
=
NLS
.
str
(
"adb_dialog.forward_fail"
);
...
...
@@ -676,14 +674,14 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
try
{
device
.
removeForward
(
field
.
substring
(
"tcp:"
.
length
()));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
LOG
.
error
(
"JDWP remove forward error"
,
e
);
}
}
}
}
}
}
catch
(
IO
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"JDWP clear forward error"
,
e
);
}
}
...
...
@@ -698,8 +696,8 @@ public class ADBDialog extends JDialog implements ADB.DeviceStateListener, ADB.J
return
!
s
.
contains
(
tcpPort
);
}
}
}
catch
(
IO
Exception
e
)
{
e
.
printStackTrace
(
);
}
catch
(
Exception
e
)
{
LOG
.
error
(
"ADB list forward error"
,
e
);
}
return
false
;
}
...
...
jadx-gui/src/main/java/jadx/gui/ui/popupmenu/VarTreePopupMenu.java
浏览文件 @
01f47282
...
...
@@ -10,6 +10,9 @@ import javax.swing.AbstractAction;
import
javax.swing.JMenuItem
;
import
javax.swing.JPopupMenu
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.gui.ui.MainWindow
;
import
jadx.gui.ui.dialog.SetValueDialog
;
...
...
@@ -18,6 +21,8 @@ import jadx.gui.utils.NLS;
import
jadx.gui.utils.UiUtils
;
public
class
VarTreePopupMenu
extends
JPopupMenu
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
VarTreePopupMenu
.
class
);
private
static
final
long
serialVersionUID
=
-
1111111202103170724L
;
private
final
MainWindow
mainWindow
;
...
...
@@ -63,14 +68,14 @@ public class VarTreePopupMenu extends JPopupMenu {
private
static
final
long
serialVersionUID
=
-
1111111202103171120L
;
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
public
void
actionPerformed
(
ActionEvent
e
vent
)
{
try
{
mainWindow
.
getDebuggerPanel
()
.
getDbgController
()
.
modifyRegValue
(
valNode
,
ArgType
.
INT
,
0
);
}
catch
(
Exception
e
xcept
)
{
except
.
printStackTrace
(
);
UiUtils
.
showMessageBox
(
mainWindow
,
e
xcept
.
getMessage
());
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Change to zero failed"
,
e
);
UiUtils
.
showMessageBox
(
mainWindow
,
e
.
getMessage
());
}
}
});
...
...
@@ -78,14 +83,14 @@ public class VarTreePopupMenu extends JPopupMenu {
private
static
final
long
serialVersionUID
=
-
1111111202103171121L
;
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
public
void
actionPerformed
(
ActionEvent
e
vent
)
{
try
{
mainWindow
.
getDebuggerPanel
()
.
getDbgController
()
.
modifyRegValue
(
valNode
,
ArgType
.
INT
,
1
);
}
catch
(
Exception
e
xcept
)
{
except
.
printStackTrace
(
);
UiUtils
.
showMessageBox
(
mainWindow
,
e
xcept
.
getMessage
());
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Change to one failed"
,
e
);
UiUtils
.
showMessageBox
(
mainWindow
,
e
.
getMessage
());
}
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录