I am trying to figure out why gdb is not behaving as expected. Not sure what triggered this. After seeing this problem, I wrote a minimal version of the main function. It finished the last line and exited properly. After adding one more function, the jumping came back. Even after commenting out the added line the jumping back does not go away.
I am not sure this is related the the linking to my own library even after commenting out most of the code (not a single line reference my own library), the build process still use the linking (automake):
LDADD = ../libmyown.la
This line was used to add libs to to many other programs built in this directory. I tested different versions of gdb and gcc, with the latest being 8.2 for both programs. Have used the -g -O0, -ggdb -O0 option. I have seen postings in Stackoverflow about this type of behavior. Not sure I am hitting this behavior or it was some bug in my own library whose linking caused this jumping back behavior. Although this posting appears to be redundant, but I am trying to provide more context information. Hopefully some else of myself will find a solution and help others.
Except for the jumping problem in gdb, the binary program execute properly.
Here is a slightly expanded version of the main demonstrating the jumping issue:
Breakpoint 1, main (argc=1, argv=0x7fffffffdeb8) at alnlocalmany.cpp:66
66 if (isDNA(reffile)) {
(gdb) n
67 alignDNAMany(reffile, dbfile, outfile);
(gdb)
68 return 0;
(gdb) s
39 string reffile, dbfile, outfile;
(gdb) s
73 }
(gdb) s
0x00007ffff6d97b97 in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) s
Single stepping until exit from function __libc_start_main,
which has no line number information.
[Inferior 1 (process 15621) exited normally]
Note it jump from 68 to 39 (first line in main) then 73 (ending curly bracket of main)