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 18:47:20 +0100

* Eli Zaretskii
| This gets stranger and stranger...

Indeed :-/

| How about disassembly of printchar?  Does it show the call to fwrite
| in both cases?

You mean the assembler code output as of gcc -S ... print.c?  Yes, it
does show a call to fwrite, although in different syntax for gcc and
cc (which doesn't surprise me).

------------------------------
gcc
    .L22:
    .LM36:

            lw  $2,noninteractive
            beq $2,$0,.L25
    .LM37:

            addu        $2,$fp,24
            move        $4,$2
            li  $5,1                    # 0x1
            lw  $6,32($fp)
            lw  $7,.LC0
            la  $25,fwrite
            jal $31,$25
    .LM38:

            li  $2,1                    # 0x1
            sw  $2,noninteractive_need_newline
    .LM39:
------------------------------
cc:
    .BB25.printchar:    # 0x2c8
            .loc        1 333 4
     # 332      {
     # 333        fwrite (str, 1, len, stdout);
            addiu $4,$sp,0                      #  str
            addiu $5,$0,1                       #  
            lw $6,4($sp)                        #  len
            lw $7,%got_disp(__iob)($gp)         #  __iob
            addiu $7,$7,16                      #  
            lw $25,%call16(fwrite)($gp)         #  fwrite
            jalr $25                            #  fwrite
            nop                                 #  
    .BB26.printchar:    # 0x2e8
            .loc        1 334 4
     # 334        noninteractive_need_newline = 1;
            addiu $8,$0,1                       #  
-------------------------

| What happens if you replace `fwrite' with `fflush' followed by
| `write'?  Does that change anything?

Errr, yes, it does.  If I apply the following diff:
*** print.c~    Wed Aug  1 10:27:38 2001
--- print.c     Fri Mar 22 18:35:49 2002
***************
*** 330,336 ****
        }
        else if (noninteractive)
        {
!         fwrite (str, 1, len, stdout);
          noninteractive_need_newline = 1;
        }
        else
--- 330,339 ----
        }
        else if (noninteractive)
        {
!               fflush(stdout);
!               write (1, str, len);
! 
!               /* fwrite (str, 1, len, stdout); */
          noninteractive_need_newline = 1;
        }
        else

I get
    ./emacs -batch -no-site-file -l foo

    "21.2.1"

I.e. it `works'.

If I put at the start of main:
  write(1,"write\n",6);
  fwrite("frwite\n", 7,1,stdout);
I see the `write', but not the fwrite when I compile with gcc.  I see
both when I compile with cc.
    
| Another idea is to put a breakpoint inside fwrite, and see if it's
| called at all.

While gdb accepts the break command, it does not stop in fwrite in
both cases (gcc and cc).  However, cc-compiled prints, gcc-compiled
does not.

cc:
    (gdb) br fwrite
    Breakpoint 4 at 0xfa52f48: file engine.c, line 592.
    (gdb) c

    "21.2.1"

    Program exited normally.

gcc:
    (gdb) br fwrite
    Breakpoint 4 at 0xfa52f48: file engine.c, line 592.
    (gdb) c

    Program exited normally.
    
I don't know whether it makes much sense to dig deeper here.  While
I'm as curious what is the problem here, maybe I just go and fetch the
CVS version and see what happens there.

R'



reply via email to

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