Is it true that binary files like executables are composed of symbols and debug symbol is one kind of them?
How to understand the symbol?
Is it true that binary files like executables are composed of symbols and debug symbol is one kind of them?
How to understand the symbol?
A very high level explanation follows:
Firstly symbols are not in C++ world alone. They exist in binaries of several high level languages like C, C++ etc when built with some specified settings. Let's take the definition
'int i = 2;'
In the binary, 'i' is just a memory location (e.g. 0x10203040) which is being initialized with 2. There is no memory location called 'i'. The name 'i' is assigned to that memory location by virtue of debug symbols that are loaded with binaries (when built with certain flags), which maintain a map of 'memory location' to the 'source level names'.
As an example, the PE file format has provision for Debug Directory which stores information about debug symbols. These are very useful while debugging because in absence of such debug symbols, debugging just in terms of binray 0s and 1s would be a really very very challening task. So when you debug such a binary (which has the above definition of 'i') which has been built with debug flags, the debugger knows that the memory location '0x10203040' corresponds to 'i' by virtue of the Debug Directory in the PE file.
Erm, no. Executable files contain machine code. And initialization values for global variables. On Windows, the debugging information is normally stored in a separate file, a .pdb. A piece of debug data from that file about a function or a variable in your program is called a symbol.
The dbghelp API is described here.