Basically, according to my knowledge,
If we use GDB to debug execute code compiled from C source code, compiler will leave the source code Path in the ELF/PE file, so GDB will use the source code to facilitate our debug process.
But how can GDB provide the asm code info in the above process? I give a example captured on my computer as below:
So my questions are:
Could anyone give me some help? Thank you!
Remember that the "compiler" (e.g. gcc) does several things:
By far the most complex part of this is the compilation-proper phase.
Remember also that assembly is more-or-less a direct representation of the machine instructions contained in the object code.
So, to answer your questions:
In other words there a is a 1:many mapping from source code to assembly, meaning that there are many possible permutations of assembly code for given source code, given different compilers, compiler options, etc. This means it is difficult, if not impossible to derive source code from pure object code. Thus for effective debugging of c source code, the source code must be available to GDB, be it embedded or in its original .c form.
Conversely there is much closer to a 1:1 mapping from assembly code to object code, as both more-or-less represent the same thing - the layout of instructions in memory necessary to create the given program. Therefore the disassembly process is much more straightforward than any potential "decompilation" process.