lightning
[Top][All Lists]
Advanced

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

Re: [Lightning] Porting GNU Smalltalk to lightning 2


From: Paulo César Pereira de Andrade
Subject: Re: [Lightning] Porting GNU Smalltalk to lightning 2
Date: Wed, 22 Oct 2014 16:31:16 -0200

  I made a mirror of GNU smalltalk at https://github.com/pcpa/smalltalk
and created the scratch-lightning-branch branch.

  Cut&paste of the initial commit message on that branch:

====================
Experimental branch to adapt to GNU lightning 2.

  Suggested steps to test are:

$ cd
$ git clone git://git.savannah.gnu.org/lightning.git
$ cd lightning
$ ./configure --prefix=/usr --enable-assertions --enable-disassembler
$ make CFLAGS="-O0 -g3"
$ sudo make install

$ cd
$ https://github.com/pcpa/smalltalk.git
<< edit libgst/xlat.c and replace "/home/pcpa/github/smalltalk/.libs/gst"
    with your path layout >>
$ cd smalltalk
$ autoreconf -ifs
$ ./configure --enable-jit
$ make CFLAGS="-O0 -g3"
<< as of this commit it will fail
   to debug I suggest >>
$ libtool --mode=execute gdb gst
<< in gdb you can run something like "r > log.txt"
   so that you can open log.txt and see or edit the disassemble, etc
   for example, do a global replace in that file of an address to
   a symbolic name >>

As of the time of this commit, it enters an infinite loop in x86_64.
Upon interruption it prints this stack frame:

---%<---
nil did not understand selector #signal

(ip 8)SmallInteger(Object)>>#userInterrupt
(ip 0)IdentityDictionary(LookupTable)>>#primAt:
(ip 26)IdentityDictionary>>#findIndex:
(ip 6)IdentityDictionary(LookupTable)>>#at:put:
(ip 8)[] in Date class>>#initDayNameDict
(ip 26)Array(SequenceableCollection)>>#do:
(ip 4)[] in Date class>>#initDayNameDict
(ip 26)Array(SequenceableCollection)>>#keysAndValuesDo:
(ip 10)Date class>>#initDayNameDict
(ip 24)Date class>>#initialize
(ip 28)ObjectMemory class>>#initialize
(ip 6)UndefinedObject>>#executeStatements
(ip 0)<bottom>
nil

/home/pcpa/github/smalltalk/kernel/ObjMemory.st:650: Aborted
(ip 8)SmallInteger(Object)>>#userInterrupt
(ip 0)IdentityDictionary(LookupTable)>>#primAt:
(ip 26)IdentityDictionary>>#findIndex:
(ip 6)IdentityDictionary(LookupTable)>>#at:put:
(ip 8)[] in Date class>>#initDayNameDict
(ip 26)Array(SequenceableCollection)>>#do:
(ip 4)[] in Date class>>#initDayNameDict
(ip 26)Array(SequenceableCollection)>>#keysAndValuesDo:
(ip 10)Date class>>#initDayNameDict
(ip 24)Date class>>#initialize
(ip 28)ObjectMemory class>>#initialize
(ip 6)UndefinedObject>>#executeStatements
(ip 0)<bottom>
---%<---


But, on i586 it builds gst, but does finish a make command, the
make command fails as:

---%<---
Message new "<-0xce55b20>" did not understand selector
/root/smalltalk-2/kernel/CFuncs.st:128: Aborted
/root/smalltalk-2/kernel/CFuncs.st:128: Error occurred while not in
byte code interpreter!!
/root/smalltalk-2/libgst/.libs/libgst.so.7(+0x8cc73)[0xf76c7c73]
[0xf7738cc0]
[0xf7738cf0]
/lib/libc.so.6(gsignal+0x47)[0xf71b5657]
/lib/libc.so.6(abort+0x149)[0xf71b6f59]
/root/smalltalk-2/libgst/.libs/libgst.so.7(+0x23514)[0xf765e514]
/lib/libsigsegv.so.2(+0xb31)[0xf762bb31]
[0xf7738cd0]
/root/smalltalk-2/libgst/.libs/libgst.so.7(+0x71fcd)[0xf76acfcd]
/root/smalltalk-2/libgst/.libs/libgst.so.7(+0xa366f)[0xf76de66f]
---%<---

But, on i586, running under gdb, after the debug/disassemble messages,
it greets with:

---%<---
GNU Smalltalk ready

st>
---%<---

So, there is still some issue to fix on i586, and failure on x86_64
looks like some code path not correct for 64 bit (there are already
some 64-bit issues fixed in this commit).
====================

  I am afraid I understand close to zero of GNU Smalltalk internals, and since
most pointers are opaque, it is very hard to have an idea of what is going on...
But I believe you should have a quite easier time understanding what the
code is doing, while I should have an easier timer parsing the assembly
dumps and maping it to lightning 2 constructs...

  Either way, I believe Holger is the person mostly interested :) so I would
suggest you to run the suggested command line:

$ libtool --mode=execute gdb gst

and in the gdb prompt

(gdb) r > log.txt

in another terminal edit log.txt

You can step in the jit, e.g. add to add a breakpoint, run

(gdb) b *0x123456

where 0x123456 is the address you want to stop. Also in gdb, you can
^C, and if stoping in a C function (otherwise just continue), just see
the return
address and edit  the "log.txt" file to verify where it maps to.

You can add extra jit_note calls, to generate more annotation. Just in
case, this is what it looks like to me right now:

---%<---
$ head -25 log.txt
<main>
# :runNative:589
    0x7ffff7c7e000      sub    $0x30,%rsp
    0x7ffff7c7e004      mov    %rbx,0x28(%rsp)
    0x7ffff7c7e009      mov    %r12,0x20(%rsp)
    0x7ffff7c7e00e      mov    %r13,0x18(%rsp)
    0x7ffff7c7e013      mov    %r14,0x10(%rsp)
    0x7ffff7c7e018      mov    %r15,0x8(%rsp)
    0x7ffff7c7e01d      mov    %rbp,(%rsp)
    0x7ffff7c7e021      mov    %rsp,%rbp
    0x7ffff7c7e024      sub    $0x128,%rsp
    0x7ffff7c7e02b      mov    %rdi,%rax
    0x7ffff7c7e02e      movabs $0x7ffff7fc37c0,%r13
    0x7ffff7c7e038      movabs $0x7ffff7fcb958,%r10
    0x7ffff7c7e042      mov    (%r10),%r14
    0x7ffff7c7e045      rex.W jmpq *%rax
# :doesNotUnderstand:600
    0x7ffff7c7e048      movabs $0x7ffff7fcb958,%rax
    0x7ffff7c7e052      mov    (%rax),%r14
    0x7ffff7c7e055      mov    $0x1,%r11d
    0x7ffff7c7e05b      movabs $0x7ffff7faf310,%r10
    0x7ffff7c7e065      mov    (%r10),%rax
    0x7ffff7c7e068      mov    -0x8(%r14),%r10
    0x7ffff7c7e06c      mov    %rax,%rdi
    0x7ffff7c7e06f      mov    %r11,%rsi
---%<---

---%<---
$ tail -25 log.txt
    0x7fffcea4217f      movabs $0x7ffff7fcb958,%rax
    0x7fffcea42189      mov    %r14,(%rax)
# :7fffef636ab0:1456
    0x7fffcea4218c      mov    $0x8,%eax
    0x7fffcea42191      mov    0x8(%r13),%r10
    0x7fffcea42195      movabs $0x7ffff7ff6700,%r11
    0x7fffcea4219f      mov    %rax,(%r11)
# :7fffef636ab0:1464
    0x7fffcea421a2      rex.WB jmpq *%r10
    0x7fffcea421a5      nopl   (%rax)
# :7fffef636ab0:1472
    0x7fffcea421a8      movabs $0x7ffff7fcb958,%r10
    0x7fffcea421b2      mov    (%r10),%r14
# :7fffef636ab0:2453
    0x7fffcea421b5      mov    (%r14),%rbx
    0x7fffcea421b8      movabs $0x7ffff7d64b5f,%r10
    0x7fffcea421c2      callq  *%r10
    0x7fffcea421c5      movabs $0x7ffff7fcb958,%r10
    0x7fffcea421cf      mov    (%r10),%r14
    0x7fffcea421d2      movabs $0x7ffff7fcb950,%r10
    0x7fffcea421dc      mov    (%r10),%rax
    0x7fffcea421df      mov    %rbx,(%r14)
    0x7fffcea421e2      rex.W jmpq *%rax
# :7fffef636ab0:2504
---%<---

  The first step should be to figure out what is wrong, that makes it "almost"
work on i586 (starts and exists normally, but something is still wrong as the
make command triggers some error), but just enters an infinite loop on x86_64.

Thanks,
Paulo



reply via email to

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