See the User Manual on the documentation page of GDB:
https://www.sourceware.org/gdb/documentation/
You can also search for some tutorials.
This sample is from the official documentation:
https://sourceware.org/gdb/current/onlinedocs/gdb.html/Sample-Session.html#Sample-Session. It will allow you to see a basic example of stepping through the code and printing the values of variables located on the stack.