Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

C/++/# What are the "debugging symbols"?

  1. Jul 18, 2017 #1

    ORF

    User Avatar

    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
     
  2. jcsd
  3. Jul 18, 2017 #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: Jul 18, 2017
  4. Jul 18, 2017 #3

    rcgldr

    User Avatar
    Homework Helper

  5. Jul 19, 2017 #4

    ORF

    User Avatar

  6. Jul 19, 2017 #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.
     
  7. Sep 7, 2017 #6

    Svein

    User Avatar
    Science Advisor

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: What are the "debugging symbols"?
  1. What is AI? (Replies: 6)

  2. What code is this? (Replies: 6)

  3. What is a DST? (Replies: 1)

Loading...