Strange debugging issue

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Strange debugging issue

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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Strange debugging issue

Jonas Maebe-2

On 05 Apr 2010, at 16:17, 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_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Strange debugging issue

John Coppens
On Mon, 5 Apr 2010 16:21:33 +0200
Jonas Maebe <[hidden email]> 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.

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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Strange debugging issue

Jonas Maebe-2

On 05 Apr 2010, at 16:27, 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_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Strange debugging issue

John Coppens
In reply to this post by Jonas Maebe-2
On Mon, 5 Apr 2010 16:21:33 +0200
Jonas Maebe <[hidden email]> wrote:

> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Strange debugging issue

Jonas Maebe-2

On 05 Apr 2010, at 16:36, John Coppens wrote:

> 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_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Strange debugging issue

John Coppens
On Mon, 5 Apr 2010 17:04:55 +0200
Jonas Maebe <[hidden email]> wrote:

> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal