Lab4Lab XXXXXXXXXXIntroduction to Valgrind CIS2500 Winter 2021 This lab is about a command-line tool tool called Valgrind. It is a very useful tool to detect memory errors and to...

1 answer below »
can you do for me this assignment I want it to be done in 8 hours


Lab4 Lab 4 Introduction to Valgrind CIS2500 Winter 2021 This lab is about a command-line tool tool called Valgrind. It is a very useful tool to detect memory errors and to detect memory leaks. To run valgrind, first you must compile your code and create an executable. Now you can run valgrind on the executable. For example, if a.out is the name of my executable, I will run vagrind as: $ valgrind ./a.out You can also run it using flags such as -g. To learn more on the syntax of valgrind, you can run the man command: $ man valgrind In general, it reports a heap summary, a leak summary and an error summary. Part I (ungraded part): Read more on valgrind and understand the leak summary, especially how it calculates the “definitely lost” and “indirectly lost” bytes. Note that some memory leak occurs when we use standard libraries such as stdio.h. 1. Example report on heap, leak and error report: For example, it reports the following for the “Hello world” program given in the textbox on the right-hand side: 2. Example on initialization error: Valgrind is also useful in finding initialization errors. For example, it reports the following for the program given in the textbox on the right-hand side. As you can see line 8 is attempting to print arr [1] that has not been initialized – and valgrind reports this error, including the line number. Part II (graded part): You are given 3 program files. You must run each file using valgrind, understand the report it generates and fix the memory / initialization issues with it. For each given source file, you must submit (a) the output generated by valgrind To capture the output, you can use valgrind to log the report to a file (e.g. log_file1), instead of displaying it on standard output. valgrind --log-file=log_file1 ./a.out (b) Improved program file such that • “definitely lost” and “indirectly lost” bytes is zero. • Source File is free of any initialization error Part III (Submission): There are a total of 6 files to submit (2 for each program file). You must create a tar file that consists of these 6 files. A tar file can be created using the following command. Here -c is for create, v for verbose and f for filename. The following command will compress all files in the current folder to a file called lab3.tar. tar -cvf lab3.tar * The following command will compress files file1 and log_file1 to a file called lab3.tar. tar -cvf lab3.tar file1 log_file1 To learn more on the tar command, man it! At the end, submit the tar file lab3.tar to Gitlab. /*Note*\ Replace lab3.tar by lab4.tar at all places in this document
Answered 1 days AfterMar 13, 2023

Answer To: Lab4Lab XXXXXXXXXXIntroduction to Valgrind CIS2500 Winter 2021 This lab is about a...

Mohith answered on Mar 13 2023
40 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here