What are the "debugging symbols"?

  • Thread starter ORF
  • Start date
  • Tags
    Symbols
In summary, debugging symbols are extra information that a debugger can use to help track down problems in the code.
  • #1
ORF
170
18
Hello

What are the "debugging symbols" ?

I have a naive idea about what the debugging symbols are, but based only in my short experience: for me, they are a kind of flags that can be read during the execution of the program, so you can track the execution.

I have also discovered that if you remove this symbols (I'm not sure if they are the same "symbols" as the debugging ones, or they are different) from a shared library can not be integrated dynamically in you program.

A reference to a web where this stuff is explained could be enough.

Thank you for your time.

Regards,
ORF
 
Technology news on Phys.org
  • #2
I am not certain what you mean by "debugging symbol", but I'll take some guesses. My examples will be for C programming using the Microsoft Visual Studio.
While developing code, you can use a "Release" build or a "Debug" build. The "Debug" build gives you several advantages in tracking down problems in the code:
1) Often, some or call compiler optimization are turned off. This will allow you to step through the code executing one line of source at a time and seeing the resulting changes in variable as they occur.
2) "Debug" libraries will be used.
3) The symbol "_DEBUG" will be defined. Otherwise the symbol "NDEBUG" is defined.
4) In older versions of the Microsoft development environments and in some other development environments, local symbols are not available in the Release build. And so debugging that code is more difficult because, as it executes, it cannot be linked to the source code.

Item 3 above allows code such as this:
#if defined(_DEBUG)
{
double debug_r;
debug_r = sqrt(x*x+y*y);
printf("Debug: Radius is now %f\n");
}
#endif /* _DEBUG */

That code will only be compiled for a debug build. It presumable provides assistance in tracking what is happening in the code and assists in locating bugs.

There is another term "debug symbols" (similar to your "debugging symbols"). They are the compiler-generated and builder maintained list of variables names and statement indices that allow a debugger to show you the source code and variable names that are being worked with as you debug.

For example:
int a;
a = b+1;

At debug time, the debugger will have access to symbols telling it where in memory it will find the code for "a = b+1;" and where that same code can be found in the source files. It will also have information about the context of variables "a" and "b" are where they are stored - an absolute memory location, or a location relative to the stack or frame pointer.
 
Last edited:
  • Like
Likes ORF
  • #4
  • #5
Debugging symbols are extra information compiled into the binary that allows a debugger to identify things about the source code. This allows the debugger to give useful information when you are stepping through the code one instruction at a time. The information can include the names of variables and even the source code of the program associated with the binary executable code that it generates.

In some cases, the information is added to the binary by adding a compiler flag during compilation. For gcc and g++, the -g flag adds debugging symbols into the binary. This does significantly increase the size of the binary, and tools are provided for stripping out that information. After stripping, debugging no longer provide information about the source code from which the program came.

There may be other schemes for storing the symbols separately from the binary, but I am not familiar with those methods.
 
  • Like
Likes ORF

Related to What are the "debugging symbols"?

1. What are debugging symbols?

Debugging symbols refer to the additional information that is added to a compiled program or binary file. They provide information about the source code, such as variable names, function names, and line numbers, which can aid in debugging and troubleshooting.

2. How are debugging symbols generated?

Debugging symbols are generated during the compilation process of a program. The compiler includes the symbols in the compiled binary file, along with the machine code, to create an executable program that can be run by the computer.

3. Why are debugging symbols important?

Debugging symbols are important because they allow developers to easily trace and identify errors or bugs in their code. Without them, it can be challenging to pinpoint the exact location of an issue, making the debugging process much more time-consuming and difficult.

4. Can debugging symbols be removed from a compiled program?

Yes, debugging symbols can be removed from a compiled program to reduce its size and make it more difficult for others to reverse engineer the code. However, this also means that the program will be more challenging to debug if any issues arise.

5. Are debugging symbols only useful for developers?

No, debugging symbols can also be useful for users who encounter errors or crashes while using a program. The symbols can provide more detailed information about the error, which can help in troubleshooting and resolving the issue.

Similar threads

  • Programming and Computer Science
Replies
11
Views
1K
Replies
11
Views
2K
  • Electrical Engineering
Replies
2
Views
2K
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • Programming and Computer Science
Replies
5
Views
3K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
3
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
Back
Top