After adapting this answer, I wrote the following loop to simply print an array in gdb in a script called "gdb_script.gs". What am I doing wrong?
set $end=64
while ($i<$end)
print $i
print volfrac($i, :, 1)
set $i=$i+1
end
where volfrac(:,:,:) is a fortran array. I am getting the error:
gdb_script.gs:14: Error in sourced command file:
A syntax error in expression, near `<$end)'.
(gdb) print /x volfrac[0][0][0] $5 = 0xdeadbeef (gdb) print /x volfrac[0][0] $6 = {0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x0, 0x0, 0x0, 0x0} (gdb) print /x volfrac[0] $7 = {{0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, (gdb) print /x volfrac $8 = {{{ ...
The usual way to examine data in your program is with the print command (abbreviated p ), or its synonym inspect . It evaluates and prints the value of an expression of the language your program is written in (see section Using GDB with Different Languages). expr is an expression (in the source language).
Quitting GDB To exit GDB, use the quit command (abbreviated q ), or type an end-of-file character (usually C-d ). If you do not supply expression , GDB will terminate normally; otherwise it will terminate using the result of expression as the error code.
set $i = 0
p $i++
keep pressing Enter this is one of the easiest logic I found
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With