BUG: AttributeError: 'NoneType' object has no attribute 'c'
See original GitHub issueghidra2dwarf.py> Running...
Traceback (most recent call last):
File "/root/ghidra_scripts/ghidra2dwarf/ghidra2dwarf.py", line 499, in <module>
add_debug_info()
File "/root/ghidra_scripts/ghidra2dwarf/ghidra2dwarf.py", line 138, in add_debug_info
add_function(cu, f, file_index)
File "/root/ghidra_scripts/ghidra2dwarf/ghidra2dwarf.py", line 318, in add_function
d = res.decompiledFunction.c
AttributeError: 'NoneType' object has no attribute 'c'
ghidra2dwarf.py> Finished!
I’m new to Ghidra, so idk if my solution is right, but I found in docs that api got getC
method.
and try to fix:
def add_function(cu, func, file_index):
die = dwarf_new_die(dbg, DW_TAG_subprogram, cu, None, None, None)
loc_expr = dwarf_new_expr(dbg)
dwarf_add_expr_gen(loc_expr, DW_OP_call_frame_cfa, 0, 0)
dwarf_add_AT_location_expr(dbg, die, DW_AT_frame_base, loc_expr)
f_name = func.name
dwarf_add_AT_name(die, f_name)
dwarf_add_AT_string(dbg, die, DW_AT_linkage_name, f_name)
# TODO: Check for multiple ranges
f_start, f_end = get_function_range(func)
t = func.returnType
ret_type_die = add_type(cu, func.returnType)
dwarf_add_AT_reference(dbg, die, DW_AT_type, ret_type_die)
dwarf_add_AT_targ_address(dbg, die, DW_AT_low_pc, f_start, 0)
dwarf_add_AT_targ_address(dbg, die, DW_AT_high_pc, f_end - 1, 0)
func_line = len(decomp_lines) + 1
res = get_decompiled_function(func)
if res:
try:
d = res.decompiledFunction.c
except:
d = res.decompiledFunction.getC
else:
return
decomp_lines.extend(d.split("\n"))
dwarf_add_AT_unsigned_const(dbg, die, DW_AT_decl_file, file_index)
dwarf_add_AT_unsigned_const(dbg, die, DW_AT_decl_line, func_line)
dwarf_add_line_entry(dbg, file_index, f_start, func_line, 0, True, False)
add_decompiler_func_info(cu, die, func, file_index, func_line)
return die
But, no luck:
ghidra2dwarf.py> Running...
Traceback (most recent call last):
File "/root/ghidra_scripts/ghidra2dwarf/ghidra2dwarf.py", line 505, in <module>
add_debug_info()
File "/root/ghidra_scripts/ghidra2dwarf/ghidra2dwarf.py", line 138, in add_debug_info
add_function(cu, f, file_index)
File "/root/ghidra_scripts/ghidra2dwarf/ghidra2dwarf.py", line 322, in add_function
d = res.decompiledFunction.getC
AttributeError: 'NoneType' object has no attribute 'getC'
ghidra2dwarf.py> Finished!
I found this in api docs:
// Make calls to the decompiler:
DecompileResults res = ifc.decompileFunction(func,0,taskmonitor);
// Check for error conditions
if (!res.decompileCompleted()) {
system.out.println(res.getErrorMessage());
return;
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:13
Top Results From Across the Web
AttributeError: 'NoneType' object has no attribute 'cget'
NoneType means that instead of an instance of whatever Class or Object you think you're working with, you've actually got None.
Read more >How do I fix : attributeerror: 'nonetype' object has no attribute ...
The message is telling you that info_box.find did not find anythings, so it returned None . And a None object does not have...
Read more >AttributeError: 'NoneType' object has no attribute 'getReleases'
Hi there, I am currently trying to get my experiment to integrate with our Biopac shock hardware via parallel port. I am running...
Read more >Loop error (AttributeError: 'NoneType' object has no attribute ...
The error is telling you that the element referenced by trialList[0] is a None Type, which basically means that the slot in the...
Read more >[FIXED] AttributeError: 'NoneType' object has no attribute ...
Hence, AttributeError: 'NoneType' object has no attribute 'something' error occurs when the type of object you are referencing is None.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should have been fixed by #10.
Feel free to re-open this issue if this is not the case.
Done.