简体   繁体   English

我可以使用 Go dlv exec ./go-server 反编译所有 go 代码吗?

[英]Can I use Go dlv exec ./go-server to decompile all go code?

Supposed a go-server file was compiled by Windows system with linux OS, and Can I use Go dlv exec ./go-server to decompile all go code?假设一个 go-server 文件是由 linux 操作系统的 Windows 系统编译的,我可以使用 Go dlv exec ./go-server 来反编译所有的 go 代码吗?

When I try to break some points, I got below message, but it didn't print the code, is there any way to decompile it except for IDA , cause it's too expensive to but it.当我尝试打破一些要点时,我收到以下消息,但它没有打印代码,除了IDA之外,有没有办法反编译它,因为它太贵了。

(dlv) b main.main
Breakpoint 1 set at 0x845ecf for main.main() E:/Code/GoCode/go-server/main.go:10
(dlv) c
> main.main() D:/Go/main.go:10 (hits goroutine(1):1 total:1) (PC: 0x845ecf)
Warning: debugging optimized function
(dlv) n
> main.main() D:/Go/main.go:11 (PC: 0x845ee6)
Warning: debugging optimized function
(dlv) n
Config file: ./dev.json Load success!
> main.main() D:/Go/main.go:12 (PC: 0x845f00)
Warning: debugging optimized function

No, dlv does not have a decompiler, although Go has much more metadata about the program at runtime in comparison with C or C++ it's very hard to revert the compilation process, it's unlikely you will end up with anything alike the original program in source code from a decompiler.不,dlv 没有反编译器,尽管与 C 或 C++ 相比,Go 在运行时有更多关于程序的元数据,但很难恢复编译过程,你不太可能最终得到与源代码中的原始程序类似的任何东西从反编译器。

I think what you're questioning is that if you can debug with source code listing from another host, note that usually debuggers do not decompile the program (unless they're meant for debugging without source code, like IDA), instead compilers create metadata with references for each instruction to the original source code file along with its lines, then debuggers can load this source code file and build its features like source code level stepping from there, what you need is to copy all the source code to your Linux machine somewhere on its file system, and configure dlv to know how to locate this source code:我认为您要问的是,如果您可以使用来自另一台主机的源代码列表进行调试,请注意通常调试器不会反编译程序(除非它们用于在没有源代码的情况下进行调试,例如 IDA),而是编译器创建元数据每条指令都引用原始源代码文件及其行,然后调试器可以加载此源代码文件并构建其功能,例如从那里进行源代码级步进,您需要将所有源代码复制到您的 Linux 机器在其文件系统的某处,并配置 dlv 以了解如何找到此源代码:

config substitute-path E:/Code/GoCode/go-server/ /home/user/somewhere/

Keep in mind that you need to maintain the executable in sync with the original source code it was compiled with, otherwise the debugger may display wrong line offsets请记住,您需要保持可执行文件与编译它的原始源代码同步,否则调试器可能会显示错误的行偏移

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM