简体   繁体   English

GDB 不起作用 - 不是可执行格式?

[英]GDB doesn't work - not executable format?

When trying to run gdb with gdb ./mm.c I'm getting the following error:尝试使用gdb ./mm.c运行 gdb 时,出现以下错误:

"0x7ffee71424c0s": not in executable format: file format not recognise

Does someone recognise this error and can help me to fix it?有人认出这个错误并且可以帮助我修复它吗?

C is (usually) a compiled language (vs. interpreted language such as (usually) JavaScript). C 语言(通常)是一种编译语言(相对于解释性语言,例如(通常)JavaScript)。

Your computer "speaks" 0 s and 1 s, not for and if .您的计算机“说话” 0 s 和1 s,而不是forif
The source code you write (the for s and if s) needs to be translated (compiled) to the proper 0 s and 1 s.您编写的源代码( for s 和if s)需要被翻译(编译)为正确的0 s 和1 s。 That is the job of the compiler.这就是编译器的工作。

gcc -Wall -Wextra nm.c -O0 -ggdb -oexefile
^^^                                             compile
                  ^^^^                          the fors and ifs in nm.c
                                 ^^^^^^^^^      into 0s and 1s in exefile
    ^^^^^^^^^^^^^                               warn about most common mistakes
                       ^^^                      do not optimize
                           ^^^^^                and output debug information for gdb

Then the job of the debugger is to show the 0 s and 1 s (grouped back to the original source lines when possible) as they execute, statement by statement然后调试器的工作是显示0 s 和1 s(在可能的情况下组合回原始源代码行),因为它们逐个语句执行

gdb ./exefile

With optimizations, the compiler would (very possibly) make 0 s and 1 s with no relation to the original for s and if s, making it impossible for gdb to associate them with original for and if statements.通过优化,编译器(很可能)使0 s 和1 s 与原始for s 和if s 无关,从而使 gdb 无法将它们与原始的forif语句相关联。

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

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