> -----Original Message-----
> From: Jeff Clites [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 07, 2004 12:52 AM
> To: Adam Thomason
> Cc: Internals List
> Subject: Re: [perl #24829] RE: [PATCH] PPC JIT fixes 
> [re-send] (Modified
> by Jeff Clites)
> 
> 1) In gdb, break on runops_jit, then step until jit_code is defined 
> (but not jumpted to yet).
> 
> 2) Dump the assembly by typing "x/40i jit_code". (That is "x" for 
> examine memory at "jit_code", and the "/40i" says to format 
> the output 
> as instructions, and print out 40 of them.) That will at 
> least give you 
> the first chunk of the JIT-produced assembly.
> 
> 3) Continue running. When you crash, use "info reg" to output the 
> registers--the "pc" listed is the program counter, which should tell 
> you the instruction on which you crashed. If the number 
> matches one of 
> the lines printed in (2), then that's where you crashed. If 
> the number 
> is in a completely different range, you probably jumped 
> somewhere from 
> the JIT code before crashing. If so, do (4):

The 40 ops range from 0x200fca28 to 0x200fca90, with 0x200fca94 onward being
".long 0x0".  The pc at failure is 0x7c0802a4.  So it's probably safe to
assume the trouble is pre-pasm.

> (4) Start over, but after step (2), instead of just continuing, step 
> one instruction at a time with "nexti" until you crash. Each time you 
> step it will print out the program counter, so you'll be able 
> to see at 
> which point you jump from the JIT code into the beginning-of-the-end. 
> That will tell us at least where to start looking.

I'm seeing a bunch of different addresses, and I'm not totally sure what's
what.  When the breakpoint hits, it says pc=0x200f7518, but the subsequent
disassembly shows runops_jit at 0x100313e0.  Best I can gather, it's
attempting to branch to _ptrgl from runops_jit, but failing.  Some googling
suggests that _ptrgl is a compiler-inserted routine for triggering indirect
function calls, which jives with the call into jit_code.  I'm rather baffled
how pc becomes 0x7c0802a4 at the point of fault.  See below for a transcript
of the gdb session.

> (Also, as a side note, I believe that before my patches the 
> basic_1.pasm test was working on Mac OS X--about the only one 
> working--so it may be that something completely different is going 
> wrong on AIX. And actually, there's some 
> flush-the-processor-cache code 
> which may be conditionally compiled, so maybe that isn't building in 
> your case, and your jump could end up trying to execute stale 
> data. Or 
> it may be and issue with calling convention differences 
> between AIX and 
> Mac OS X.)

One of the first things I did to get the port to work was introduce the
'#ifndef __IBMC__' guard in ppc_sync_cache in jit/ppc/jit_emit.h, just to get
the file to compile (xlC doesn't support any form of inlined asm).  Might the
absence of the sync cause the trouble?  If so, now is probably the time to
patch up the build system to support assembling a separate .s file containing
the necessary snippet.  I can look into doing that, and calling it from
ppc_sync_cache, but I've no idea if there's any trouble w.r.t not inlining
that piece, so help would be appreciated.

Adam

------------------------------------------------------------------------------

gdb transcript, w/ some gratuitous whitespace:

GNU gdb 6.0
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-ibm-aix4.3.3.0"...

(gdb) b src/interpreter.c:423
Breakpoint 1 at 0x10031404: file src/interpreter.c, line 423.

(gdb) r -d -j -v t/op/basic_1.pasm
Starting program: /auto/actinium-data01/thomason/parrot/working/parrot -d -j -v 
t/op/basic_1.pasm
debug = 0x1
Reading t/op/basic_1.pasm
using optimization '0' (0)
Starting parse...
3 lines compiled.
Running...
*** Parrot VM: JIT core ***
*** Parrot VM: Setting up ARGV array in P5.  Current argc: 1 ***
        0: t/op/basic_1.pasm

Section:
NOT JITTED block 0
                OP0: ext   1    noop
                        map_branch: 00
        begin:  0x200f7518      (1)
        end:    0x200f7518      (1)
        I registers used:       0
        N registers used:       0
        Jit opcodes:    0
        Total opcodes:  1

Section:
JITTED block 1
                OP1: ext   0    end
                        map_branch: 00
        begin:  0x200f751c      (0)
        end:    0x200f751c      (0)
        I registers used:       0
        N registers used:       0
        Jit opcodes:    1
        Total opcodes:  1

Section:
NOT JITTED block 0
                OP0: ext   1    noop
                        map_branch: 00
        begin:  0x200f7518      (1)
        end:    0x200f7518      (1)
        I registers used:       0
        N registers used:       0
        Jit opcodes:    0
        Total opcodes:  1

Section:
JITTED block 1
                OP1: ext   0    end
                        map_branch: 00
        begin:  0x200f751c      (0)
        end:    0x200f751c      (0)
        I registers used:       0
        N registers used:       0
        Jit opcodes:    1
        Total opcodes:  1

Total size 108 bytes

Breakpoint 1, runops_jit (interpreter=0x20051438, pc=0x200f7518) at 
src/interpreter.c:423
423         (jit_code) (interpreter, pc);

(gdb) x/30i jit_code
0x200fca28:     mflr    r0
0x200fca2c:     stmw    r13,-76(r1)
0x200fca30:     stw     r0,8(r1)
0x200fca34:     stwu    r1,-144(r1)
0x200fca38:     xor     r31,r31,r31
0x200fca3c:     mr      r13,r3
0x200fca40:     lwz     r12,768(r13)
0x200fca44:     lwz     r14,24(r12)
0x200fca48:     lwz     r12,748(r13)
0x200fca4c:     lwz     r15,220(r12)
0x200fca50:     subf    r12,r15,r4
0x200fca54:     add     r12,r14,r12
0x200fca58:     lwz     r12,0(r12)
0x200fca5c:     mtctr   r12
0x200fca60:     bctrl
0x200fca64:     ori     r12,r31,0
0x200fca68:     add     r3,r15,r12
0x200fca6c:     mr      r4,r13
0x200fca70:     ori     r12,r31,26308
0x200fca74:     oris    r12,r12,8195
0x200fca78:     mtctr   r12
0x200fca7c:     bctrl
0x200fca80:     lwz     r1,0(r1)
0x200fca84:     lwz     r0,8(r1)
0x200fca88:     mtlr    r0
0x200fca8c:     lmw     r13,-76(r1)
0x200fca90:     blr
0x200fca94:     .long 0x0
0x200fca98:     .long 0x0
0x200fca9c:     .long 0x0

(gdb) disass runops_jit
Dump of assembler code for function runops_jit:
0x100313e0 <runops_jit+0>:      mflr    r0
0x100313e4 <runops_jit+4>:      stwu    r1,-80(r1)
0x100313e8 <runops_jit+8>:      stw     r0,88(r1)
0x100313ec <runops_jit+12>:     stw     r3,104(r1)
0x100313f0 <runops_jit+16>:     stw     r4,108(r1)
0x100313f4 <runops_jit+20>:     lwz     r3,104(r1)
0x100313f8 <runops_jit+24>:     lwz     r4,108(r1)
0x100313fc <runops_jit+28>:     bl      0x100329a4 <init_jit>
0x10031400 <runops_jit+32>:     stw     r3,64(r1)
0x10031404 <runops_jit+36>:     lwz     r3,104(r1)
0x10031408 <runops_jit+40>:     lwz     r4,108(r1)
0x1003140c <runops_jit+44>:     lwz     r11,64(r1)
0x10031410 <runops_jit+48>:     bl      0x10001948 <_ptrgl>
0x10031414 <runops_jit+52>:     lwz     r2,20(r1)
0x10031418 <runops_jit+56>:     li      r3,0
0x1003141c <runops_jit+60>:     b       0x10031420 <runops_jit+64>
0x10031420 <runops_jit+64>:     lwz     r0,88(r1)
0x10031424 <runops_jit+68>:     mtlr    r0
0x10031428 <runops_jit+72>:     addi    r1,r1,80
0x1003142c <runops_jit+76>:     blr
0x10031430 <runops_jit+80>:     .long 0x0
0x10031434 <runops_jit+84>:     .long 0x2041
0x10031438 <runops_jit+88>:     lwz     r0,513(r0)
0x1003143c <runops_jit+92>:     .long 0x0
0x10031440 <runops_jit+96>:     .long 0x50
0x10031444 <runops_jit+100>:    .long 0xa7275
0x10031448 <runops_jit+104>:    xoris   r15,r19,28787
0x1003144c <runops_jit+108>:    rlwnm   r10,r27,r13,5,26
End of assembler dump.

(gdb) nexti
0x10031408      423         (jit_code) (interpreter, pc);

(gdb) nexti

0x1003140c      423         (jit_code) (interpreter, pc);
(gdb) nexti

0x10031410      423         (jit_code) (interpreter, pc);
(gdb) nexti

Program received signal SIGSEGV, Segmentation fault.
0x7c0802a4 in ?? ()

(gdb) info reg
r0             0x7c0802a6       2080899750
r1             0x2ff222b0       804397744
r2             0xbda1ffb4       -1113456716
r3             0x20051438       537203768
r4             0x200f7518       537883928
r5             0x8      8
r6             0xa80    2688
r7             0x0      0
r8             0x10007167       268464487
r9             0x10007167       268464487
r10            0x200fce70       537906800
r11            0x90010008       -1878982648
r12            0x1008d318       269013784
r13            0xdeadbeef       -559038737
r14            0x5      5
r15            0x2ff22560       804398432
r16            0x2ff22578       804398456
r17            0x200340cc       537084108
r18            0xdeadbeef       -559038737
r19            0xdeadbeef       -559038737
r20            0xdeadbeef       -559038737
r21            0xdeadbeef       -559038737
r22            0xdeadbeef       -559038737
r23            0xdeadbeef       -559038737
r24            0xdeadbeef       -559038737
r25            0xdeadbeef       -559038737
r26            0xdeadbeef       -559038737
r27            0xdeadbeef       -559038737
r28            0xdeadbeef       -559038737
r29            0xdeadbeef       -559038737
r30            0x101747f0       269961200
r31            0x200329b8       537078200
pc             0x7c0802a4       2080899748
ps             0x4000d0b0       1073795248
cr             0x22424044       574767172
lr             0x10031414       268637204
ctr            0x7c0802a6       2080899750
xer            0x20000000       536870912
fpscr          0x82024000       -2113781760
vscr           0x0      0
vrsave         0x0      0

(gdb) x/10i _ptrgl
0x10001948 <_ptrgl>:    lwz     r0,0(r11)
0x1000194c <_ptrgl+4>:  stw     r2,20(r1)
0x10001950 <_ptrgl+8>:  mtctr   r0
0x10001954 <_ptrgl+12>: lwz     r2,4(r11)
0x10001958 <_ptrgl+16>: lwz     r11,8(r11)
0x1000195c <_ptrgl+20>: bctr
0x10001960 <_ptrgl+24>: .long 0x0
0x10001964 <_ptrgl+28>: .long 0xca040
0x10001968 <_ptrgl+32>: .long 0x0
0x1000196c <_ptrgl+36>: .long 0x18

(gdb) 

Reply via email to