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

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

Re: `print' does not print


From: Ralf Fassel
Subject: Re: `print' does not print
Date: Fri, 22 Mar 2002 15:22:25 +0100

* Eli Zaretskii
| To do that, you could either (a) use some utility, such as truss or
| strace, to report system calls issued by Emacs;

This is `par' on IRIX, which shows close(4) and close(5), but no (!)
write:
   ...
  579mS                 : open("/disk4/tmp/ralf/Software/emacs-21.2/foo", 
O_RDONLY, 0) = 5
  579mS                 : close(5) OK
  580mS                 : open("/disk4/tmp/ralf/Software/emacs-21.2/foo", 
O_RDONLY, 0) = 5
  580mS                 : close(5) OK
  582mS                 : open("/disk4/tmp/ralf/Software/emacs-21.2/foo", 
O_RDONLY, 0) = 5
  582mS                 : close(5) OK
finish

If I compile print.c alone with cc, and all the rest with gcc, I see
  ...
  575mS                 : open("/disk4/tmp/ralf/Software/emacs-21.2/foo", 
O_RDONLY, 0) = 5
  575mS                 : close(5) OK
  576mS                 : open("/disk4/tmp/ralf/Software/emacs-21.2/foo", 
O_RDONLY, 0) = 5
  576mS                 : close(5) OK
  578mS                 : open("/disk4/tmp/ralf/Software/emacs-21.2/foo", 
O_RDONLY, 0) = 5
  581mS                 : close(5) OK
  587mS                 : write(1, "\n", 1) = 1
  603mS                 : write(1, ""21.2.3"\n", 9) = 9
finish

The CPP-preprocessed print.c shows the `fwrite' call in both cases,
and the code is the same (apart from whitespace diff) after
preprocessing.

| or (b) invoke fwrite from GDB at the beginning of the Emacs `main'
| function (put a breakpoint in `main' to stop Emacs there), and see
| what it returns.

    % gdb ./emacs
    ...
    (gdb) br main
    Breakpoint 3 at 0x10162410: file emacs.c, line 708.
    (gdb) br print.c:333
    Breakpoint 4 at 0x1024c220: file print.c, line 333.
    (gdb) run -batch -no-site-file -l ../foo

    Breakpoint 3, main (argc=0, argv=0x0, envp=0x0) at emacs.c:708
    708 {
    (gdb) call printf("hello\n")
    hello
    $1 = 6
    (gdb) call fwrite("hello\n",6,1,(&__iob[1]))
    hello
    $2 = 1
    (gdb) c
Both of these seem to work when called via gdb.

    Breakpoint 4, printchar (ch=10, fun=273132596) at print.c:333
    333           fwrite (str, 1, len, stdout);
    (gdb) call fwrite (str, 1, len,(&__iob[1]) )

    $3 = 1
Seems to have worked, newline is printed.
    (gdb) p str
    $4 = "\n\000\000"
    (gdb) n
    334           noninteractive_need_newline = 1;
Nothing is printed in this step.

    (gdb) c

    Breakpoint 4, printchar (ch=34, fun=273132596) at print.c:333
    333           fwrite (str, 1, len, stdout);
    (gdb) p str
    $5 = "\"\000\002\""
    (gdb) call fwrite (str, 1, len,(&__iob[1]) )
    $6 = 1
Nothing is printed yet due to line buffering on stdout, see below.
    (gdb) n
    334           noninteractive_need_newline = 1;
    (gdb) disable 4
    (gdb) c
    "
This is the quote from further abvove, fflushed on exit, but nothing
else is printed.
    Program exited normally.
    (gdb) 

So the calls via gdb seem to work, while the calls from emacs itself
don't.  I do not understand this at all.

R'



reply via email to

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