Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Magic 8 Ball: You are debugging an application in execution using gdb on a 64

ID: 3717456 • Letter: 1

Question

1. Magic 8 Ball: You are debugging an application in execution using gdb on a 64-bit (i.c. pointers use 64 bits), little-endian architecture. The application has a variable called magic8ball - defined as char magic8ball[8][8][8]; Using gdb you find the following information at a particular stage in the application: (gdb) p &magic8ball; S1- (char (*)[8][8][8]) Ox7fffffffe000 And (gdb) x/512bx 0x7fffffffe000 0x7fffffffe000: 0x4e 0x7fffffffe008: 0x4c 0x7fffffffe010: 0x4e 0x7fffffffe018: 0x4e 0x7fffffffe020: 0x59 0x7fffffffe028: 0x4e 0x7fffffffe030: 0x4d 0x7fffffffe038 0x57 0x7fffffffe040: 0x4d 0x7fffffffe048: 0x4e 0x7fffffffe050: 0x52 0x7fffffffe058 0x57 0x7fffffffe060: 0x4e 0x7fffffffe068: 0x4d 0x7fffffffe070: 0x4e 0x7fffffffe078: 0x59 0x7fffffffe080: 0x4c 0x7fffffffe088: 0x4e 0x7fffffffe090: 0x4e 0x7fffffffe098: 0x59 0x7fffffffe0a0 0x4c 0x7fffffffe0a8: 0x59 0x7fffffffe0b0: 0x4e 0x7fffffffe0b8: 0x59 0x7fffffffe0c0: 0x4d 0x7fffffffe0c8: 0x59 0x7fffffffe0d0: 0x4e 0x7fffffffe0d8: 0x57 0x7fffffffe0e0: 0x57 0x7fffffffe0e8: 0x4e 0x7fffffffe0f0: 0x4d 0x7fffffffe0f8: 0x57 0x7fffffffe100: 0x4e 0x7fffffffe108: 0x52 0x7fffffffe110: 0x53 0x7fffffffe118: 0x4e 0x7fffffffe120: 0x59 0x7fffffffe128: 0x4e 0x7fffffffe130: 0x4e 0x7fffffffe138: 0x52 0x7fffffffe140: 0x59 0x7fffffffel48 0x59 0x7fffffffe150: 0x4e 0x00 0x00 0x00 0x00 0x00 0x7f 0x00 0xff 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x72 0x67 0x6e 0x72 0x65 0x67 0x72 0x00 0x00 0x00 0x00 0x7f 0x61 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x73 0x6b 0x00 0x00 0x00 0x00 0x65 0x72 0x67 0x00 0x00 0x00 0x00 0x00 0x00 0x72 0x72 0x61 0x6f 0x67 0x00 0x00 0x75 0x72 0x00 0x00 0x7f 0xff 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x73 0x68 0xff

Explanation / Answer

Good you have mentioned that it is little endian architecture. It make me sure the tell that the value of your question.

The variable magic8ball, is 3D array of size 8 amd will have the total bytes (512), as char hold one bytes on main mamory(RAM).

GDB server traces the dump memory on dynamically or after the run by core file.

so, $ p &magic8ball. =====> this address show the pointer to an 3d array base.
will print the pointer(address). and if you need magic8ball[3][4] will show the pointer of one dimensional array.

And let me tell you the address. As it looks contiguous address so easy to tell also.

Here we can see total 64 one dimensional arrary. and magic8ball[0][0] will tell the first array and second row - magic8ball[0][1] ----- so till magic8ball[2][7] will be there 3*8=24 rows. and for [3][0] to [3][4] will be 29the row, and need to tell the address of 29th array.

Answer. - 0x7fffffffe0e0.

there can be also the way to manually caluculate 29th 8th byte and tell the address.

Thanks. Kindly let me know for any clarifications.