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 debug symbol is a special kind of symbol that attaches additional information to the symbol table of an object file, such as a shared library or an executable.
A set of special characters generated when a program is compiled and containing information about the location of variables and functions in the resulting binary file, plus other service information. This data set can be used for step-by-step debugging of the program or examining third-party code.
A debugging symbol table is information included in the binary file that maps the compiled instructions to the corresponding line, function, and/or variable in the original source code. This is not something you would want to do with your final builds of any code, as it makes the final executable larger and slower.
Special symbols: There are a variety of special symbols available in C++ like mathematical, logical and relational operators like +,-, *, /, \, ^, %, !, @, #, ^, &, (, ), [, ], ; and many more.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With