Skip to content

Commit 058504e

Browse files
Fix log
1 parent b5b536e commit 058504e

File tree

1 file changed

+5
-36
lines changed

1 file changed

+5
-36
lines changed

src/main/java/golanganalyzerextension/GolangAnalyzerExtensionAnalyzer.java

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ public boolean canAnalyze(Program program) {
6464
// TODO: Examine 'program' to determine of this analyzer should analyze it. Return true
6565
// if it can.
6666

67-
LanguageID lang=program.getLanguageID();
68-
lang.compareTo(new LanguageID("LE:32"));
69-
70-
log_tmp(lang.getIdAsString());
71-
7267
return true;
7368
}
7469

@@ -95,18 +90,18 @@ public boolean added(Program program, AddressSetView set, TaskMonitor monitor, M
9590
Address base=get_gopclntab(program, monitor);
9691
if(base==null)
9792
{
93+
log.appendMsg("gopclntab not found");
9894
return false;
9995
}
10096
int func_num=0;
10197
try {
10298
// magic and ...
10399
func_num=memory.getInt(base.add(8));
104100
}catch(MemoryAccessException e) {
105-
log_tmp("failed func_num MemoryAccessException");
101+
log.appendException(e);
106102
return false;
107103
}
108104
Address func_list_base=base.add(8+pointer_size);
109-
log_tmp("start loop");
110105
for(int i=0; i<func_num; i++) {
111106
long func_addr_value=0;
112107
long func_info_offset=0;
@@ -130,35 +125,28 @@ public boolean added(Program program, AddressSetView set, TaskMonitor monitor, M
130125
if(func_name_data==null) {
131126
func_name_data=listing.createData(base.add(func_name_offset), new StringDataType());
132127
}else if(!func_name_data.getDataType().isEquivalent((new StringDataType()))) {
133-
log_tmp("failed !func_name_data.getDataType().isEquivalent((new StringDataType()))");
128+
log.appendMsg("The type of func name data is not String");
134129
continue;
135130
}
136-
log_tmp("get name");
137131

138132
args=memory.getInt(base.add(func_info_offset+pointer_size+4));
139-
log_tmp(String.format("get args %d", args));
140133

141-
log_tmp(String.format("entrypoint %x", func_entry_value));
142134
if(func_addr_value!=func_entry_value)
143135
{
144-
log_tmp("wrong func addr");
136+
log.appendMsg(String.format("wrong func addr %x %x", func_addr_value, func_entry_value));
145137
continue;
146138
}
147139
Address func_addr=program.getAddressFactory().getDefaultAddressSpace().getAddress(func_addr_value);
148140
Function func=program.getFunctionManager().getFunctionAt(func_addr);
149-
log_tmp("get func");
150141
String func_name=(String)func_name_data.getValue();
151-
log_tmp(String.format("get func name %s", func_name));
152142
if(func==null) {
153143
CreateFunctionCmd cmd=new CreateFunctionCmd(func_name, func_addr, null, SourceType.ANALYSIS);
154144
cmd.applyTo(program, monitor);
155-
log_tmp("create func");
156145
continue;
157146
}
158147
func.setName(func_name, SourceType.ANALYSIS);
159-
log_tmp("set name");
160148
}catch(Exception e) {
161-
log_tmp("failed"+e.getMessage());
149+
log.appendException(e);
162150
}
163151
}
164152

@@ -188,30 +176,11 @@ Address get_gopclntab(Program program, TaskMonitor monitor) {
188176
while(true) {
189177
find=program.getMemory().findBytes(find, magic, new byte[] {(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff}, true, monitor);
190178
if(find==null) {
191-
log_tmp("not found 0xfbffffff");
192179
break;
193-
}else {
194-
log_tmp(String.format("0xfbffffff %x", find.getOffset()));
195180
}
196181
find=find.add(4);
197182
}
198183

199184
return find;
200185
}
201-
202-
// TODO delete
203-
void log_tmp(String str) {
204-
try {
205-
File file = new File("test.txt");
206-
207-
FileWriter filewriter = new FileWriter(file, true);
208-
209-
filewriter.write("log: ");
210-
filewriter.write(str);
211-
filewriter.write("\n");
212-
213-
filewriter.close();
214-
} catch(IOException e) {
215-
}
216-
}
217186
}

0 commit comments

Comments
 (0)