to creat a executable file that can debug, one can use '-g' flag
TBH, at the very beginning, it is quite annoying to use command interface to do the debugging, but
gfortran -g a.F90 -o ab
1. use gdb (15-06-29)
if gdb does not diplay the line properly, use -ggdb flag instead.it is also found that the files has to be compiled by the same compiler in the same machine to ensure the readability of the code.
gfortran -ggdb a.f -o a.out
then use the following command to start debug processes.
gdb ab
other useful command:
break main
run [r]
step [s] (step into the subroutine)
print a [p a]
where
quit
next (n) go to the next line without step into subfunctions just over the current
n 5 go to the next for 5 times
next (n) go to the next line without step into subfunctions just over the current
n 5 go to the next for 5 times
2. Info command
info b see all the breaking points info breakpoints check all of the breakpoints
frame display current line
finish stepout
https://www.google.com.au/url?sa=t&rct=j&q=&esrc=s&source=web&cd=5&ved=0CDcQFjAE&url=http%3A%2F%2Fdarkdust.net%2Ffiles%2FGDB%2520Cheat%2520Sheet.pdf&ei=HH4zVZnBO4PsmAXPz4HoCQ&usg=AFQjCNHCDpbVUfxmJyacITfnesZ0PKBKqg&sig2=ImgMp83YjaeYNoztPgTw-w&bvm=bv.91071109,d.dGY&cad=rja
http://stackoverflow.com/questions/501486/getting-gdb-to-save-a-list-of-breakpoints
save breakpoints a.txt
how to load break points --
source a.txt
Error: Dummy argument 'cherin' of procedure 'readif' at (1) has an attribute that requires an explicit interface for this procedure
info line shows where current script is stoped at
delete 1 delete break point 1 from list info b
disable 1
enable 1
disable disable all break points
break sutra.f:333 %stop at line 333 of file sutra.fdelete 1 delete break point 1 from list info b
disable 1
enable 1
disable disable all break points
frame display current line
finish stepout
https://www.google.com.au/url?sa=t&rct=j&q=&esrc=s&source=web&cd=5&ved=0CDcQFjAE&url=http%3A%2F%2Fdarkdust.net%2Ffiles%2FGDB%2520Cheat%2520Sheet.pdf&ei=HH4zVZnBO4PsmAXPz4HoCQ&usg=AFQjCNHCDpbVUfxmJyacITfnesZ0PKBKqg&sig2=ImgMp83YjaeYNoztPgTw-w&bvm=bv.91071109,d.dGY&cad=rja
http://stackoverflow.com/questions/501486/getting-gdb-to-save-a-list-of-breakpoints
save breakpoints a.txt
how to load break points --
source a.txt
Error: Dummy argument 'cherin' of procedure 'readif' at (1) has an attribute that requires an explicit interface for this procedure
set breakpoint pending on
No symbol table is loaded. Use the "file" command.
(1) if something is wrong in the source code. one does not need to quit gdb. instead, just correct the file, make it with debug flag, and rerun simulation in gdb using r.
No symbol table is loaded. Use the "file" command.
2. Correct the program. (15-06-29)
TIPS:(1) if something is wrong in the source code. one does not need to quit gdb. instead, just correct the file, make it with debug flag, and rerun simulation in gdb using r.
- Start the program being debugged.Example 1. The program is printch, which can take an optional command line argument. Start it running with no command line argument.
(gdb)
Example 2. Start printch running with command line argument A.r
(gdb)
r A
- Execute a single statement. If the statement is a function call, just single step into the function.
(gdb)
s
- Execute a single statement. If the statement is a function call, execute the entire function and return to the statement just after the call; that is, step over the function.
(gdb)
n
- Execute from the current point up to the next breakpoint if there is one, otherwise execute until the program terminates.
(gdb)
c
- Execute the rest of the current function; that is, step out of the function.
(gdb)
finish
No comments:
Post a Comment