[SOLVED] CS382 Lab 4-GDB

25.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon lab4-2lys1y.zip (893.5 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
πŸ”’ Securely Powered by:
Secure Checkout
5/5 - (4 votes)

 

Starting GDB with your program

● Install gdb-multiarch package:
β—‹ sudo apt-get install gdb-multiarch
● Assemble using –g flag and then link
β—‹ aarch64-linux-gnu-as demo.s -g -o demo.o
β—‹ aarch64-linux-gnu-ld demo.o
● Run your program and wait for GDB to connect using the `–g 1234` flag β—‹ qemu-aarch64 -g 1234 a.out
● On another terminal window, run gdb and connect to the program
β—‹ gdb-multiarch –nh -q a.out -ex ‘set disassemble-next-line on’
-ex ‘target remote :1234’
-ex ‘set solib-search-path /usr/aarch64-linux-gnu-lib/’ -ex ‘layout regs’
Note: You can find these steps in section B.3.2 of the textbook, backslashes in the final command simply denote new lines.
Interacting with GDB

● Please read section B.3.3 in the textbook (p.184)
● Breakpoints
β—‹ Use b <label> to pause the program when it reaches the label
β—‹ Ex: b _start to pause at the start of the program
● Moving through the program
β—‹ Resume execution using continue or c
β—‹ Step through the program using step or s
● Panel focus
β—‹ Use focus regs to view the values of the registers
β—‹ Use focus asm to go back to the assembly code panel
Printing Memory

● Read section B.3.4 in the textbook
● To print data stored in memory we use the following command:
β—‹ x/<length><format><unit> address
● If we wanted to print 5 bytes in character from the label hello: β—‹ x/5cb &hello
● To print 2 bytes in decimal from the address stored in x10:
β—‹ x/2db $x10

Starter Code
Task Time
● Come up for attendance before leaving
● Task 1: Calculating Dot Product
β—‹ Use the data in “vec1” and “vec2” to calculate the dot product and store it in “dot”
β—‹ Must be able to assemble, link, and execute without error
β—‹ You are allowed to use the MUL instruction as needed
β—‹ Comment every line
● Task 2: Debugging using GDB
β—‹ Look at appendix B.3
β—‹ Write a report about your program from Task 1

  • lab4-2lys1y.zip