Note that there are some explanatory texts on larger screens.

plurals
  1. POgdb "Program exited normally" when it shouldn't
    primarykey
    data
    text
    <p>I'm debugging some ANSI C code with gcc44 and gdb, on a 64bit Linux CentOS 5.7 server.</p> <p>Around the middle of one of my functions, I have a for loop that loops 192 times (there are 2 lines of code in the loop). If I setup gdb with a breakpoint at the start of the for loop, I can step through the for loop all 192 times and it exits the for loop and continues into the next line of code after the for loop. This is all stepping through the code in gdb using "s" or "n". Everything works fine. </p> <p>Now, instead of stepping through the for loop using "s" or "n" to get to the next line of code after the for loop, I start gdb and then set a breakpoint at the line just after the end of the for loop. If I then press "c" in gdb, it gives me "Program exited normally". I expected gdb to stop at this breakpoint located on the line of code just after the for loop. (!?)</p> <p>As another experiment, I learned that gdb DOES successfully stop on any breakpoint set on any line <em>after</em> the line of code immediately following the for loop. </p> <p>Maybe others have had this experience judging by questions such as this (there are 2 additional references therein):</p> <p><a href="https://stackoverflow.com/questions/4872633/gdb-error-program-exited-normally">gdb error &quot;Program exited normally&quot;</a></p> <p>It's repeatable in gdb. Without digging into the code in question, anyone seen this behavior before and/or have any idea what I could check? </p> <p>EDIT 1</p> <p>If I include a <code>printf("\n");</code> on the breakpoint line that gives problems above, moving what used to be on that line to one line below this printf code, then everything works fine (e.g. gdb stops on the printf line). </p> <p>I can even set a breakpoint successfully on the previously-problematic line of code in question, which is now the next line after the printf line. Weird!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload