Hello, we know how RISC-V GDB and OpenOCD work together to interact with SHAKTI. So now what is debugging? and how
risc-v gdb is used for that, Lets see!.
Have you seen movies where programmers are shown typing so fast that they could pick the keys apart? If only it were that easy! When in reality, it involves a lot less typing and a lot more staring! Mostly because we don’t know where the problem is. Enters GDB! It gives a faster and a very less frustrating way to debug the program. GDB lets you dissect the program and inspect it part by part. So that you can figure out the exact cause of the error.
Now we are going to see the list of various commands used for debugging in RISC-V GDB.
GDB command completion: Use TAB key
info reg + TAB will complete the command resulting in info registers.
Press TAB twice to see all available options if more than one option is available.
Starting a GDB session:
riscv-unknown-elf-gdb to invoke the gdb session for this
For instance, use
riscv64-unknown-elf-gdb for 64 bit architecture and
riscv32-unknown-elf-gdb for 32 bit.
Quitting a session:
RISC-V GDB Commands:
|Uses the file “filename” as the program to be debugged. Symbols and contents of memory are read.|
|Loads the program into the memory|
|changes the value associated with a variable, memory address, or expression that is accessible according to the scope and visibility rules|
|4. Info Registers|
|Displays the names and values of all registers except floating-point/CSR registers.|
|5. Info all-registers|
|Displays the values of all the registers including floating point and csr registers.|
|Continues running the program until the next breakpoint or error|
|7. Step in / next in|
|Executes one machine instruction, then stops and returns to the debugger|
|Sets a break point at the specified line number or address or a function.|
|9. Info breakpoints|
|Displays information about all the breakpoints set inside a program.|
|10. info breakpoint <breakpoint-number>|
|Displays information about the specific breakpoint|
|Deletes all or specific breakpoint|
|Disables the breakpoint but not delete it from the memory. You can disable the breakpoints entirely or a specific one.|
|Enables the breakpoints previously disabled.|
Step-in and Continue:
Continuing means resuming program execution until your program completes normally. In contrast, stepping means executing just one more “step” of your program, where “step” may mean either one line of source code, or one machine instruction.
Delete and Disable:
delete command deletes the breakpoint whereas
disable command simply disables it, i.e its still available in memory. It can be enabled whenever required using
Continue and jump:
Continuing means resuming program execution until your program completes normally. However jump goes to the specified address and resumes execution.
Learn more about Debugging with GDB,