1

Wikipedia says:

A debug symbol is information that expresses which programming-language constructs generated a specific piece of machine code in a given executable module.

  1. Any examples of what kind of programming-language constructs are used for the purpose?

  2. What is the meaning of "constructs" in this context? Functions?

Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411

1 Answers1

4

The programming language constructs reffered to are things like if statements, while loops, assignment statements, etc etc.

Debug symbols are usually files that map addresses of executable chunks of machine bytecode with the original source code file and line number they represent. This is what allows you to do things like put a breakpoint on an if statement, and have the machine stop when the execution reached that particular bit of bytecode.

Omer Raviv
  • 11,409
  • 5
  • 43
  • 82
  • You mean to say the each line of the source code is mapped with its corresponding machine code? Can you get into details of this please? And what is bytecode? You mean binary language? – Aquarius_Girl Sep 07 '11 at 04:34
  • 1
    Yes, that's what I meant. By bytecode I meant machine-code. I think the most important things to know is that when you put a breakpoint on a line of code, the debugger uses the debug symbol to find what location of that code line within the machine code, and asks the CPU to stop there. For more details about what exactly is contained in the debug symbols (in VC++ compiler, but I guess gdb isn't that much different), see http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/05/11/pdb-files-what-every-developer-must-know.aspx (and scroll down to "A native C++ PDB file contains") – Omer Raviv Sep 07 '11 at 05:44
  • Wow, so you mean to say that when I write `b 10` which means that set the breakpoint on line 10 of the source file, GDB looks for the corresponding debug symbol in the final executable, and bookmarks it. And how "exactly" it is done internally should be none of my business? – Aquarius_Girl Sep 07 '11 at 06:07
  • 1
    Well, if you're interested in how exactly it works internally, you can read about it on http://stackoverflow.com/questions/3915511/how-do-breakpoints-work-in-c-code, or perhaps google "how do breakpoints work". – Omer Raviv Sep 07 '11 at 06:45
  • Fine, but whatever I have understood is that completely correct? – Aquarius_Girl Sep 07 '11 at 06:56