Question

a) Why must a program specifically be compiled for debugging to be able to execute that...

a) Why must a program specifically be compiled for debugging to be able to execute that program in a debugger? What two things does the compiler do to assist a debugger?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Why a program must specifically be compiled for debugging to be able to execute that program in a debugger:
In the three-stage compiler structure, especially in the third-stage or the back end, debug data may also be required to be generated facilitating debugging. The high-level programming languages include the #line directive generated by the compiler to support debugging of the original source and also available is the wide platform of the compilers.

In Perl programming language, the debugger is not a separate program the way it is in the compiled environment. Program or the code must first compile correctly for the debugger to work on it. Instead, -d switch tells the compiler to insert source information into the parse trees it is about to hand off to the interpreter. Next, when the interpreter starts up, it preloads a special specific programming language such as Perl library file containing the debugger.

In general, the program must be compiled using GCC, LLVM, etc with the "-g" flag for a debug compilation, thereafter it will then be able to debug the program through a debugger such as GDB. When a program is run under GDB and compile it, debugging information such as its arguments is first generated, so later the program can be debugged. GNU C compiler (GCC) is used to compile a program which supports `-g' with or without `-O', making it possible to debug optimized code.

The two things the compiler does to assist a debugger:
* The compiler emits a mapping from the line numbers in the program to the assembly instruction/s it maps to. As a result, the debugger only does a reverse map of this showing the program source line corresponding to the instruction indeed being executed.
* The compiler emits information on the memory location or register reference where a variable resides at a particular point in the program execution. GDB knows where the variable is currently residing which could be in a register or memory. As compiler does register allocation, it knows where a variable is located at a particular point in the program.
* Compiler expresses debug-info for debuggers to use.

Add a comment
Answer #2

Why a program must specifically be compiled for debugging to be able to execute that program in a debugger:
In the three-stage compiler structure, especially in the third-stage or the back end, debug data may also be required to be generated facilitating debugging. The high-level programming languages include the #line directive generated by the compiler to support debugging of the original source and also available is the wide platform of the compilers.

In Perl programming language, the debugger is not a separate program the way it is in the compiled environment. Program or the code must first compile correctly for the debugger to work on it. Instead, -d switch tells the compiler to insert source information into the parse trees it is about to hand off to the interpreter. Next, when the interpreter starts up, it preloads a special specific programming language such as Perl library file containing the debugger.

In general, the program must be compiled using GCC, LLVM, etc with the "-g" flag for a debug compilation, thereafter it will then be able to debug the program through a debugger such as GDB. When a program is run under GDB and compile it, debugging information such as its arguments is first generated, so later the program can be debugged. GNU C compiler (GCC) is used to compile a program which supports `-g' with or without `-O', making it possible to debug optimized code.

The two things the compiler does to assist a debugger:
* The compiler emits a mapping from the line numbers in the program to the assembly instruction/s it maps to. As a result, the debugger only does a reverse map of this showing the program source line corresponding to the instruction indeed being executed.
* The compiler emits information on the memory location or register reference where a variable resides at a particular point in the program execution. GDB knows where the variable is currently residing which could be in a register or memory. As compiler does register allocation, it knows where a variable is located at a particular point in the program.
* Compiler expresses debug-info for debuggers to use.

Add a comment
Know the answer?
Add Answer to:
a) Why must a program specifically be compiled for debugging to be able to execute that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT