Skip to content

Commit f9701d8

Browse files
Add an analysis option
1 parent 327080e commit f9701d8

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/main/java/golanganalyzerextension/FunctionModifier.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ public class FunctionModifier extends GolangBinary {
3030
boolean rename_option=false;
3131
boolean param_option=false;
3232
boolean comment_option=false;
33+
boolean extended_option=false;
3334

34-
public FunctionModifier(Program program, TaskMonitor monitor, MessageLog log, boolean rename_option, boolean param_option, boolean comment_option, boolean debugmode) {
35+
public FunctionModifier(Program program, TaskMonitor monitor, MessageLog log, boolean rename_option, boolean param_option, boolean comment_option, boolean extended_option, boolean debugmode) {
3536
super(program, monitor, log, debugmode);
3637

3738
this.rename_option=rename_option;
3839
this.param_option=param_option;
3940
this.comment_option=comment_option;
41+
this.extended_option=extended_option;
4042

4143
if(!rename_option && !param_option && !comment_option) {
4244
return;
@@ -52,7 +54,9 @@ public FunctionModifier(Program program, TaskMonitor monitor, MessageLog log, bo
5254
return;
5355
}
5456

55-
init_hardcode_functions();
57+
if(extended_option) {
58+
init_hardcode_functions();
59+
}
5660

5761
ok=true;
5862
}

src/main/java/golanganalyzerextension/GolangAnalyzerExtensionAnalyzer.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class GolangAnalyzerExtensionAnalyzer extends AbstractAnalyzer {
1616
boolean param_option=true;
1717
boolean comment_option=true;
1818
boolean datatype_option=true;
19+
boolean extended_option=true;
1920
boolean debugmode_option=false;
2021

2122
public GolangAnalyzerExtensionAnalyzer() {
@@ -44,6 +45,7 @@ public void registerOptions(Options options, Program program) {
4445
options.registerOption("Modify arguments", param_option, null, "Modify function arguments");
4546
options.registerOption("Add comment", comment_option, null, "Add source file and line information to comments");
4647
options.registerOption("Add data type", datatype_option, null, "Add data type");
48+
options.registerOption("Extended analysis", extended_option, null, "Analyze functions in detail");
4749
options.registerOption("Debug mode", debugmode_option, null, "Debug mode");
4850
}
4951

@@ -54,14 +56,15 @@ public void optionsChanged(Options options, Program program) {
5456
param_option=options.getBoolean("Modify arguments", param_option);
5557
comment_option=options.getBoolean("Add comment", comment_option);
5658
datatype_option=options.getBoolean("Add data type", datatype_option);
59+
extended_option=options.getBoolean("Extended analysis", extended_option);
5760
debugmode_option=options.getBoolean("Debug mode", debugmode_option);
5861
}
5962

6063
@Override
6164
public boolean added(Program program, AddressSetView set, TaskMonitor monitor, MessageLog log)
6265
throws CancelledException {
6366
try {
64-
FunctionModifier func_modifier=new FunctionModifier(program, monitor, log, rename_option, param_option, comment_option, debugmode_option);
67+
FunctionModifier func_modifier=new FunctionModifier(program, monitor, log, rename_option, param_option, comment_option, extended_option, debugmode_option);
6568
func_modifier.modify();
6669

6770
StructureManager struct_manager=new StructureManager(program, monitor, log, datatype_option, debugmode_option);

src/main/java/golanganalyzerextension/GolangFunction.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
// debug/gosym/pclntab.go
3030
public class GolangFunction extends GolangBinary {
3131
List<String> file_name_list=null;
32+
boolean extended_option=false;
3233

3334
Address info_addr=null;
3435
long func_size=0;
@@ -44,6 +45,7 @@ public GolangFunction(FunctionModifier obj, Address func_info_addr, long func_si
4445
super(obj);
4546

4647
this.file_name_list=obj.file_name_list;
48+
this.extended_option=obj.extended_option;
4749
this.info_addr=func_info_addr;
4850
this.func_size=func_size;
4951
this.frame_map = new TreeMap<>();
@@ -57,6 +59,7 @@ public GolangFunction(FunctionModifier obj, Address func_info_addr, long func_si
5759

5860
public GolangFunction(FunctionModifier obj, Function func, String func_name, List<Parameter> params) {
5961
super(obj);
62+
this.extended_option=obj.extended_option;
6063

6164
this.func_addr=func.getEntryPoint();
6265
this.func=func;
@@ -232,7 +235,7 @@ boolean init_params() {
232235
if(!is_reg_arg_x86) {
233236
is_reg_arg_x86=check_inst_reg_arg_x86(inst, args_num);
234237
}
235-
if(!is_checked_builtin_reg) {
238+
if(extended_option && !is_checked_builtin_reg) {
236239
is_checked_builtin_reg=check_inst_builtin_reg_arg(inst, builtin_reg_state, builtin_reg_arg);
237240
}
238241
inst=inst.getNext();

0 commit comments

Comments
 (0)