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
  • Using PuTTY Linux Server Task Compiling:             1) Download the two files from blackboard, driver.cpp, and...

    Using PuTTY Linux Server Task Compiling:             1) Download the two files from blackboard, driver.cpp, and circle.h             2) Create a new directory to store the files in             3) Compile the code a) Run the command g++ driver.cpp -o executable_name, this will compile the code both for driver.cpp and the referenced file circle.h note: -o parameter specifies a new name for the executable, if you do not specify the “-o” parameter the default name of the executable is “a.out”...

  • 1 What is the output of the following program if the user inputs 5 followed by...

    1 What is the output of the following program if the user inputs 5 followed by 7? var num1 = parseFloat(window.prompt("Enter a number")); var num2 = parseFloat(window.prompt("Enter another number")); var diff = num1 - num2, sum = num1 + num2, product = num1 * num2, quotient = num1 / num2; if (diff > 0) { if (sum > 10) { if (product > 25) { if (quotient > 1) { document.writeln("Case 1"); } } else { document.writeln("Case 2"); } }...

  • No matter which editor you’re using, there are debugging tools that can help simplify the process...

    No matter which editor you’re using, there are debugging tools that can help simplify the process of hunting down logic errors. In Eclipse and BlueJ, you just need to toggle a breakpoint in the gutter of the text area; this should place a blue circle next to the line of code your debugger will execute up to. Then to debug, instead of play, click on the “little bug” icon next to play. Say yes to the perspective change dialog, and...

  • Write a java program to do BFS topological sort . your program must be able to...

    Write a java program to do BFS topological sort . your program must be able to catch the loop. m у 2.

  • For each problem, you must: Write a Python program Test, debug, and execute the Python program...

    For each problem, you must: Write a Python program Test, debug, and execute the Python program Save your program in a .py file and submit your commented code to your Student Page. Note regarding comments: For every class, method or function you create, you must provide a brief description of the what the code does as well as the specific details of the interface (input and output) of the function or method. (25 pts.) Write a program that reads in...

  • Why must we be able to distinguish between LIFO and FIFO? What importance does this hold...

    Why must we be able to distinguish between LIFO and FIFO? What importance does this hold in the accounting field?

  • c++ language Step 1. Try to execute the following program (CP11E02) and record the results. #include...

    c++ language Step 1. Try to execute the following program (CP11E02) and record the results. #include <iostream.h> #include <string.h> class tv show private: char title[30]; int length; // 30 or 60 minutes char kind; // Ccomedy, d-drama, i - infomercial public: tv_show(char til),int I, char k) // constructor (strcpy(title, s); length = 1 kind=k; void main(void) tv show one("One Day to Live", 60,'d'); tv show two("Enemies".30,'c'), Step 2. Modify the statement tv_show one("One Day to Live",60,'d'); to read tv_show one;...

  • Your program must prompt the user to enter a string. The program must then test the...

    Your program must prompt the user to enter a string. The program must then test the string entered by the user to determine whether it is a palindrome. A palindrome is a string that reads the same backwards and forwards, such as "radar", "racecar", and "able was I ere I saw elba". It is customary to ignore spaces, punctuation, and capitalization when looking for palindromes. For example, "A man, a plan, a canal. Panama!" is considered to be a palindrome....

  • Please help as much as you can it’s pretty much just terms What is the main purpose of the python-requests module? What kinds of requests can it make, and what types of responses might be returne...

    Please help as much as you can it’s pretty much just terms What is the main purpose of the python-requests module? What kinds of requests can it make, and what types of responses might be returned? Text? HTML? JSON? Images? What is JSON? How does it compare to CSV? Whern processed using the json.loads) method, what Python data structure does the imported JSON get imported as. What is an HTML Document Object Model (DOM) and how does that relate to...

  • 1.Explain why computers have both main memory and secondary storage. 2.Explain the operations carried out by...

    1.Explain why computers have both main memory and secondary storage. 2.Explain the operations carried out by the preprocessor, compiler, and linker. 3.Explain what is stored in a source file, an object file, and an executable file. 4.What is an algorithm? 5.Describe difference between program line and a statement. 6.Is a syntax error found by the compiler or when the program is running? 7.What two units does the CPU consist of? 8.What happens to a variable’s current contents when a new...

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