bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

note from Prof Knuth


From: Maggie McLoughlin
Subject: note from Prof Knuth
Date: Wed, 20 Dec 2000 00:04:09 -0800 (PST)

Here's a small but annoying bug in GDB (or just possibly in GCC).
I have version 4.18, configured as "i386-redhat-linux".
My gcc is "egcs-2.91.66".

Three small files that illustrate the problem are appended below.
File "simple.c" was generated by "ctangle simple simple simple",
from the CWEB source file "simple.w" and the CWEB change file "simple.ch".
The #line directives in simple.c refer back to those source files.

When I invoke GDB from EMACS and say "break main" and then "run", I usually can
single step through my programs using "n" repeatedly, and the other window
shows where I am in the source files.

But in this case, GDB gets lost. When I get to the source line that
prints "The last line", the "n" instruction does not stop after that
instruction; I mean, it executes the change-file line that prints "No, this
one is actually last" without giving me a chance to single-step through
that instruction.

Of course I reduced a huge program down to this simple case, so that you
could diagnose the bug more easily. In the real program, there are
lots of instructions I never get to see when single-stepping. So I'm
hoping you can fix the bug, thereby helping me to debug incredibly
many other CWEB programs in the future, even though the bug looks rather
harmless in this simple case.

The bug appears to go away if I reduce the program even more. For example,
it is evidently necessary to jump back and forth between simple.w and
simple.ch in the place where I've changed "A bad line" to "A good line";
without that change, GDB works as it should when it gets to the other change.

Yours truly, Don Knuth

--------- cut here for "simple.c" -----------------------
/*1:*/
#line 5 "simple.w"

#include <stdio.h> 

main()
{
printf("The first line.\n");
#line 4 "simple.ch"
printf("A good line.\n");
#line 12 "simple.w"
/*2:*/
#line 15 "simple.w"

printf("The last line.\n");

#line 9 "simple.ch"
/*:2*//*3:*/
#line 9 "simple.ch"

printf("No, this one is actually last.\n");

/*:3*/
#line 12 "simple.w"
;
}

/*:1*/
------------------- cut here for "simple.w" -----------------------------
\datethis

@*A curious bug. This program tweaks a bug in \.{gdb}.

@c
#include <stdio.h>

main()
{
  printf("The first line.\n");
  printf("A bad line.\n");
  @<Finish@>;
}

@ @<Finish@>=
printf("The last line.\n");

@*Index.
-------------------- cut here for "simple.ch" ---------------------------
@x change file for restarting POLYSLAVE after a checkpoint
  printf("A bad line.\n");
@y
  printf("A good line.\n");
@z
@x
@*Index.
@y
@ @<Finish@>=
printf("No, this one is actually last.\n");

@*Index.
@z



reply via email to

[Prev in Thread] Current Thread [Next in Thread]