C Programming:  Need help in how to create the code instrumentation in c.  We will rely on gcc's option -finstrument-functions to execute code to collect data at the start and end of invoking any function in a program. This is also called code profiling. For this, you need to implement the following functions in this unit:  void __cyg_profile_func_enter(void *this_fn, void *call_site); void __cyg_profile_func_exit(void *this_fn, void *call_site); When we compile our programs with the above-mentioned option, function__cyg_profile_func_enter() will be called at the beginning of all functions in our program and function __cyg_profile_func_exit() will be called at the end of those functions. Parameters this_fn and call_site indicate pointers to the code segment that refer to the profiled function and the instruction that has invoked the profiled function. We can implement various functionalities using these enter/exit functions to help us analyze the function calls in our program. In this project, you will collect information about stack frames and simple execution time of each function. you need to collect the following information for each call. It is recommended that you maintain a linked list of structures to hold and update the information for each function call. You may choose to store additional information as needed too. Check the test.c program yourself and observe how the executable with code instrumentation behaves differently.  Here is the test.c file:  #include #include void f1(int x) {   for (int i = 0; i < 100000; i++) { // Just a busy loop to waste some CPU time     asm("");   }   char buffer[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // Local array that is updated later in the function   int local_int = 0x89abcdef; // a recognizable local variable on the stack   for (int i = 0; i < sizeof(buffer); i++) { // Update and print the buffer     buffer[i] = x;     printf("%u ", buffer[i]);   }   printf("\n");   if (x > 1) { // Recursively call f1()     f1(x - 1);   } } int main(void) {   f1(3);   f1(1);   return 0; } Please show the code and the full output in the terminal. There must be no error in the code.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

C Programming: 

Need help in how to create the code instrumentation in c. 

We will rely on gcc's option -finstrument-functions to execute code to collect data at the start and end of invoking any function in a program. This is also called code profiling. For this, you need to implement the following functions in this unit: 

void __cyg_profile_func_enter(void *this_fn, void *call_site);
void __cyg_profile_func_exit(void *this_fn, void *call_site);

When we compile our programs with the above-mentioned option, function__cyg_profile_func_enter() will be called at the beginning of all functions in our program and function __cyg_profile_func_exit() will be called at the end of those functions. Parameters this_fn and call_site indicate pointers to the code segment that refer to the profiled function and the instruction that has invoked the profiled function.

We can implement various functionalities using these enter/exit functions to help us analyze the function calls in our program. In this project, you will collect information about stack frames and simple execution time of each function. you need to collect the following information for each call. It is recommended that you maintain a linked list of structures to hold and update the information for each function call. You may choose to store additional information as needed too. Check the test.c program yourself and observe how the executable with code instrumentation behaves differently. 

Here is the test.c file: 

#include <stdio.h>
#include <unistd.h>

void f1(int x) {
  for (int i = 0; i < 100000; i++) { // Just a busy loop to waste some CPU time
    asm("");
  }

  char buffer[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // Local array that is updated later in the function
  int local_int = 0x89abcdef; // a recognizable local variable on the stack

  for (int i = 0; i < sizeof(buffer); i++) { // Update and print the buffer
    buffer[i] = x;
    printf("%u ", buffer[i]);
  }
  printf("\n");

  if (x > 1) { // Recursively call f1()
    f1(x - 1);
  }
}

int main(void) {
  f1(3);
  f1(1);
  return 0;
}

Please show the code and the full output in the terminal. There must be no error in the code. 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Please write this code in one file and execute the same output. Make sure to show the full code and output in the terminal. 

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Header Files
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY