Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
75d8a01c
Commit
75d8a01c
authored
Jul 28, 2014
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: improve error reporting
parent
0968f75e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
40 deletions
+29
-40
ClassGen.java
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
+7
-1
MethodGen.java
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
+21
-38
NameGen.java
jadx-core/src/main/java/jadx/core/codegen/NameGen.java
+1
-1
No files found.
jadx-core/src/main/java/jadx/core/codegen/ClassGen.java
View file @
75d8a01c
...
...
@@ -252,8 +252,8 @@ public class ClassGen {
}
private
void
addMethod
(
CodeWriter
code
,
MethodNode
mth
)
throws
CodegenException
{
MethodGen
mthGen
=
new
MethodGen
(
this
,
mth
);
if
(
mth
.
getAccessFlags
().
isAbstract
()
||
mth
.
getAccessFlags
().
isNative
())
{
MethodGen
mthGen
=
new
MethodGen
(
this
,
mth
);
mthGen
.
addDefinition
(
code
);
if
(
cls
.
getAccessFlags
().
isAnnotation
())
{
Object
def
=
annotationGen
.
getAnnotationDefaultValue
(
mth
.
getName
());
...
...
@@ -270,6 +270,12 @@ public class ClassGen {
code
.
startLine
(
"/* Code decompiled incorrectly, please refer to instructions dump. */"
);
ErrorsCounter
.
methodError
(
mth
,
"Inconsistent code"
);
}
MethodGen
mthGen
;
if
(
badCode
||
mth
.
contains
(
AType
.
JADX_ERROR
))
{
mthGen
=
MethodGen
.
getFallbackMethodGen
(
mth
);
}
else
{
mthGen
=
new
MethodGen
(
this
,
mth
);
}
if
(
mthGen
.
addDefinition
(
code
))
{
code
.
add
(
' '
);
}
...
...
jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
View file @
75d8a01c
...
...
@@ -9,7 +9,6 @@ import jadx.core.dex.instructions.args.ArgType;
import
jadx.core.dex.instructions.args.RegisterArg
;
import
jadx.core.dex.nodes.InsnNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.regions.Region
;
import
jadx.core.dex.trycatch.CatchAttr
;
import
jadx.core.dex.visitors.DepthTraversal
;
import
jadx.core.dex.visitors.FallbackModeVisitor
;
...
...
@@ -151,49 +150,33 @@ public class MethodGen {
}
public
void
addInstructions
(
CodeWriter
code
)
throws
CodegenException
{
if
(
mth
.
contains
(
AType
.
JADX_ERROR
))
{
code
.
startLine
(
"throw new UnsupportedOperationException(\"Method not decompiled: "
);
code
.
add
(
mth
.
toString
());
code
.
add
(
"\");"
);
JadxErrorAttr
err
=
mth
.
get
(
AType
.
JADX_ERROR
);
code
.
startLine
(
"/* JADX: method processing error */"
);
Throwable
cause
=
err
.
getCause
();
if
(
cause
!=
null
)
{
code
.
newLine
();
code
.
add
(
"/*"
);
code
.
startLine
(
"Error: "
).
add
(
Utils
.
getStackTrace
(
cause
));
code
.
add
(
"*/"
);
if
(
mth
.
contains
(
AType
.
JADX_ERROR
)
||
mth
.
contains
(
AFlag
.
INCONSISTENT_CODE
)
||
mth
.
getRegion
()
==
null
)
{
code
.
startLine
(
"throw new UnsupportedOperationException(\"Method not decompiled: "
)
.
add
(
mth
.
toString
())
.
add
(
"\");"
);
if
(
mth
.
contains
(
AType
.
JADX_ERROR
))
{
JadxErrorAttr
err
=
mth
.
get
(
AType
.
JADX_ERROR
);
code
.
startLine
(
"/* JADX: method processing error */"
);
Throwable
cause
=
err
.
getCause
();
if
(
cause
!=
null
)
{
code
.
newLine
();
code
.
add
(
"/*"
);
code
.
startLine
(
"Error: "
).
add
(
Utils
.
getStackTrace
(
cause
));
code
.
add
(
"*/"
);
}
}
makeMethodDump
(
code
);
}
else
if
(
mth
.
contains
(
AFlag
.
INCONSISTENT_CODE
))
{
code
.
startLine
(
"/*"
);
addFallbackMethodCode
(
code
);
code
.
startLine
(
"*/"
);
code
.
newLine
();
}
else
{
Region
startRegion
=
mth
.
getRegion
();
if
(
startRegion
!=
null
)
{
(
new
RegionGen
(
this
)).
makeRegion
(
code
,
startRegion
);
}
else
{
addFallbackMethodCode
(
code
);
}
RegionGen
regionGen
=
new
RegionGen
(
this
);
regionGen
.
makeRegion
(
code
,
mth
.
getRegion
());
}
}
private
void
makeMethodDump
(
CodeWriter
code
)
{
code
.
startLine
(
"/*"
);
getFallbackMethodGen
(
mth
).
addDefinition
(
code
);
code
.
add
(
" {"
);
code
.
incIndent
();
addFallbackMethodCode
(
code
);
code
.
decIndent
();
code
.
startLine
(
'}'
);
code
.
startLine
(
"*/"
);
}
public
void
addFallbackMethodCode
(
CodeWriter
code
)
{
if
(
mth
.
getInstructions
()
==
null
)
{
// load original instructions
...
...
@@ -212,7 +195,7 @@ public class MethodGen {
return
;
}
if
(
mth
.
getThisArg
()
!=
null
)
{
code
.
startLine
(
getFallbackMethodGen
(
mth
).
nameGen
.
useArg
(
mth
.
getThisArg
())).
add
(
" = this;"
);
code
.
startLine
(
nameGen
.
useArg
(
mth
.
getThisArg
())).
add
(
" = this;"
);
}
addFallbackInsns
(
code
,
mth
,
insnArr
,
true
);
}
...
...
@@ -248,7 +231,7 @@ public class MethodGen {
/**
* Return fallback variant of method codegen
*/
private
static
MethodGen
getFallbackMethodGen
(
MethodNode
mth
)
{
static
MethodGen
getFallbackMethodGen
(
MethodNode
mth
)
{
ClassGen
clsGen
=
new
ClassGen
(
mth
.
getParentClass
(),
null
,
true
);
return
new
MethodGen
(
clsGen
,
mth
);
}
...
...
jadx-core/src/main/java/jadx/core/codegen/NameGen.java
View file @
75d8a01c
...
...
@@ -91,7 +91,7 @@ public class NameGen {
String
name
=
arg
.
getName
();
if
(
fallback
)
{
String
base
=
"r"
+
arg
.
getRegNum
();
if
(
name
!=
null
)
{
if
(
name
!=
null
&&
!
name
.
equals
(
"this"
)
)
{
return
base
+
"_"
+
name
;
}
return
base
;
...
...
Write
Preview
Markdown
is supported
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