Open unknown321 opened 10 months ago
It is, unfortunately, the intended behavior right now due to lazy programming. I never fixed it because on IDA Pro, it was fast enough (1 second or less) that I never fixed it. The problem is coming from here: https://github.com/mahaloz/decomp2dbg/blob/08f3b1133986847c54abe43797d9203a2c9d0685/decomp2dbg/clients/gdb/gdb_client.py#L58
Nothing is cached on the client side. Things are cached server-side, but that is useless since, as you know, objcopy will be invoked many times. A way to fix would be to make a simple dict that stores things after they are sent. If the dict ever matches what was sent, don't invoke the native_symbol_add
code below the line above. That should at least get rid of the many run objcopy
. If you PR this, I will approve it.
Closed by #88, but a full fix should be fully implemented when #84 is implemented.
--- a/decomp2dbg/clients/gdb/gdb_client.py
+++ b/decomp2dbg/clients/gdb/gdb_client.py
@@ -91,6 +91,10 @@ class GDBDecompilerClient(DecompilerClient):
if new_entry:
syms_to_add.append(symbol)
+ if len(syms_to_add) == 0:
+ syms_to_add.append(("test123", int("0xdeadf00d",0), "function", 8))
+ print("add test123")
+
try:
(gdb) attach 341338
Attaching to process 341338
Reading symbols from /usr/bin/less...
0x00007fd1e18a809d in __GI___libc_read (fd=3, buf=0x7ffe00f9db67, nbytes=1) at ../sysdeps/unix/sysv/linux/read.c:26
(gdb) pipe info functions | wc -l
8013
(gdb) decompiler connect ghidra
[+] Connected to decompiler!
(gdb) pipe info functions | grep FUN_00105020
0xbaa8e020 FUN_00105020
(gdb) ni
0x00007fd1e18a809d 26 in ../sysdeps/unix/sysv/linux/read.c
add test123
[*] Decompiler failed to get a response from decompiler on 0x2a5426e1f09d with: int exceeds XML-RPC limits, are you in a library function?
───────────────────────────────────────────────
[!] Unable to decompile function
───────────────────────────────────────────────
(gdb) pipe info functions | wc -l
8014
(gdb) pipe info functions | grep test123
0x9956800c test123
(gdb) pipe info functions | grep FUN_00105020
(gdb)
It happens because all temporary symbol files are removed; there is no file to add symbol to, so a new empty file is created.
https://github.com/mahaloz/decomp2dbg/blob/main/decomp2dbg/clients/gdb/symbol_mapper.py#L259
Potential fix: don't remove symbol files, create only one file and increment on it. You'll also need to remove syms from obj which were removed from decompiler.
I suggest rolling back #88.
Rip np, I'll roll back
Ghidra decompiled ~95k symbols from my library which are reloaded on any gdb command. It takes about 5 seconds to invoke objcopy ~60 times:
Symbols in Ghidra are not modified by me, why load them again? Is this a correct behaviour?