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



