Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-04

Strange debugging issue

7 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

John Coppens

Hi all,

When trying to debug a series of events in a program, parts of source lines disappear - apart from the fact that the execution secuence seems very off.

This extract from the source file:

      if ch = eofchar then
        sy := sps[ch]
      else begin
        error(erchar);
        nextch;
        goto 1;
      end;

(with ch effectively = eofchar) produces the following:

654 if ch = eofchar then
(gdb) n
655 sy := sps[ch]
(gdb) n
659 to 1;
(gdb) n
661 l_read := true;
(gdb) n
662 n dbg_flags then
(gdb) n
[symbol_read] symbol: eofsy
663 symbol: ', sy);
(gdb) n

I haven't seen this kind of problem before, not in Pascal nor in C. Why is the '... to 1' appearing in the listing?

Using FPC 2.4.0, and gdb 6.8

John

Jonas Maebe
to John Coppens
John Coppens wrote
I haven't seen this kind of problem before, not in Pascal nor in C. Why is the '... to 1' appearing in the listing?

This usually means that you modified the file since it was loaded in the debugger.

Jonas

John Coppens
to Jonas Maebe
Show quoted text 5 lines
> I haven't seen this kind of problem before, not in Pascal nor in C. > Why is the '... to 1' appearing in the listing? This usually means that you modified the file since it was loaded in the debugger.

That was it - but it seems slightly different from C. I actually had to leave gdb and go back (probably could have reloaded).

Doesn't gdb detect source code changes? It's been a while, but I seem to remember gdb warning about the C source file having been changed.

John

Jonas Maebe
to John Coppens
John Coppens wrote
Doesn't gdb detect source code changes? It's been a while, but I seem to remember gdb warning about the C source file having been changed.

GDB warns if *on startup* the time stamp of a source file is newer than that of the binary. If you change a file during a debugging session itself, it doesn't (probably for performance reasons).

Jonas

John Coppens
to Jonas Maebe: This usually means that you modified the file since it was loaded in the debugger. Jonas
This usually means that you modified the file since it was loaded in the debugger.

And it still gives some strange result:

      if ch = eofchar then
        sy := sps[ch]
      else begin
        error(erchar);
        nextch;
        goto 1;
      end;

gives:

654	      if ch = eofchar then
(gdb) n
655	        sy := sps[ch]
(gdb)
659	        goto 1;
(gdb)
661	    symbol_read := true;

Does this have anything to do with optimizations? (the goto isn't actually executed). No optimizations are explicitly enabled.

John

Jonas Maebe
to John Coppens
John Coppens wrote 11 lines
gives: 654 if ch = eofchar then (gdb) n 655 sy := sps[ch] (gdb) 659 goto 1; (gdb) 661 symbol_read := true; Does this have anything to do with optimizations?

Unlikely. You can always disable the explicitly with -O-. Without a compilable example program that demonstrates the problem I cannot help further.

Jonas

John Coppens
to Jonas Maebe
Unlikely. You can always disable the explicitly with -O-. Without a compilable example program that demonstrates the problem I cannot help further.

Ok... Thanks! Will try to extract the important part.

John