(solved)CS 288 Please see an attachment for details
Problem 1 Write a C program that "examines" the memory storing the input parameters of the main() function (i.e., argy and all command line parameters). The program "examines" the memory in a similar way as what the "examine" gdb command does with the "xb" format, i.e., taking memory space as a bit string and printing out the bytes in this bit string in a hexadecimal format. But your program only "examines" the memory space containing the pointers and strings related to argv. They include the argy variable (first part in the sample output below), the array of pointers (second part in the sample output), and the command line parameters (the third part in the sample output). Assume the executable file of the program is named examine. Executing command "./examine this is CS 288" prints the following output. Do not use the example addresses below. Obtain your own memory addresses and draw them by executing your own program. The output of your program does not have to as the same as below, but somehow you need to be able to convey the memory addresses and data. argv | 00 00 7f fd de 8c fd a8 | 0x7ffdde8cfc90 argv [0] | 00 00 7f fd de 8d 07 25 | 0x7ffdde8cfda8 argv [1] | 00 00 7f fd de 8d 07 2f | 0x7ffdde8cfdb0 argv [2] 00 00 7f fd de 8d 07 34 | 0x7ffdde8cfdb8 argv [3] | 00 00 7f fd de 8d 07 37 | 0x7ffdde8cfdc0 argv [4] | 00 00 7f fd de 8d 07 3a | 0x7ffdde8cfdc8 165 (e) 21(/) 2e(.) 00 (0) 00 (0) 00 (0) 00(0) 00 (0) |0x7ffdde8d0720 174 (t) 00 (0) 65(e) be (n) 69 (i) 6d (m) 61 (a) 78 (x) | 0x7ffdde8d0728 143 (C) 00 (0) 73 (s) 69 (1) 00 ( 0) 73 (s) 69 (1) 68 (h) | 0x7ffdde8d0730 153 (S) 4c (L) 00 ( 0) 38 (8) 38 (8) 32 (2) 00 (0) 53 (S) | 0x7ffdde8d0738 In the above output, each line shows 8 bytes of memory contents in hexadecimal format. There are three parts. The first part (first line) shows in the middle of the line the 8B contents saved in variable argv, which is the starting address of the array of pointers (argv[0], argv[1], ...). The line also shows the variable name on the left before "|', and shows the address of the variable on the right after "|". After an empty line, the second part shows the contents in argv[0], argv[1], etc, which are the memory addresses of the strings containing command line arguments. Also, each line shows variable names on the left and addresses of argv[0], argv[1], etc on the right. The third part is mainly to show the strings containing command line arguments. However, it contains all memory contents arounds these strings to give you a better picture on how these strings are saved in memory. For this, this part starts at a memory address that is aligned to 8B and ends at a memory address aligned to 8B. To contain all the command line arguments, this part starts before the first byte in first command line argument and ends after the last byte (i.e., the NULL character)
Written for
- Institution
-
New Jersey Institute Of Technology
- Course
-
CS 288
Document information
- Uploaded on
- October 30, 2022
- Number of pages
- 3
- Written in
- 2022/2023
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
cs 288 please see an attachment for details