• TI-Nspire emulator 5 1
Currently:  

Author Topic: TI-Nspire emulator  (Read 333084 times)

0 Members and 2 Guests are viewing this topic.

Offline antoniovazquezblanco

  • LV3 Member (Next: 100)
  • ***
  • Posts: 46
  • Rating: +0/-0
    • View Profile
Re: TI-Nspire emulator
« Reply #270 on: June 24, 2014, 06:10:44 pm »
Some debug as requested :)

Code: [Select]
Program received signal SIGSEGV, Segmentation fault.
0x004018e5 in write_word ()
(gdb) b data_abort
Breakpoint 1 at 0x40aa00: file emu.c, line 112.
(gdb) c
Continuing.
21:57:04.050,14-06-24,0000001605,refreshApList
←[0m21:57:04.160,14-06-24,0000001616,Doc open complete in 0.85000002 seconds for
: ndless/ndless_installer.tns
←[0m21:57:04.160,14-06-24,0000001616,Memory avail before open: 35822688.  Memory
 avail after open: 34665812.  Memory used: 1156876
←[0mIME: non-ALPHA key pressed

Program received signal SIGSEGV, Segmentation fault.
0x004018e5 in write_word ()
(gdb) c
Continuing.

Breakpoint 1, data_abort (mva=16843021, status=1 '\001') at emu.c:112
warning: Source file is more recent than executable.
112     void data_abort(u32 mva, u8 status) {
(gdb) n
113             logprintf(LOG_CPU, "Data abort: address=%08x status=%02x\n", mva
, status);
(gdb) n
114             fix_pc_for_fault();
(gdb) n
118             cpu_exception(EX_DATA_ABORT);
(gdb) print restart_after_exception
$1 = {2686664, 16, 10767564, 13045723, 2686540, 4276596, 2686616, 0,
  1447244336, 0, 0, 0, 0, 0, 0, 0}
(gdb) info registers
eax            0x4      4
ecx            0xc784e1e        209210910
edx            0x48dd8e4        76404964
ebx            0x1      1
esp            0x28fdec 0x28fdec
ebp            0x28fe04 0x28fe04
esi            0x101010d        16843021
edi            0xa44ccc 10767564
eip            0x40aa32 0x40aa32 <data_abort+50>
eflags         0x216    [ PF AF IF ]
cs             0x23     35
ss             0x2b     43
ds             0x2b     43
es             0x2b     43
fs             0x53     83
gs             0x2b     43
(gdb) n
115             arm.reg[15] += 8;
(gdb) n
116             arm.fault_address = mva;
(gdb) n
117             arm.data_fault_status = status;
(gdb) n
118             cpu_exception(EX_DATA_ABORT);
(gdb) n
119             longjmp(restart_after_exception, 0);
(gdb) print restart_after_exception
$2 = {2686664, 16, 10767564, 13045723, 2686540, 4276596, 2686616, 0,
  1447244336, 0, 0, 0, 0, 0, 0, 0}
(gdb) info registers
eax            0x102fd904       271571204
ecx            0x0      0
edx            0x20000013       536870931
ebx            0x1      1
esp            0x28fdec 0x28fdec
ebp            0x28fe04 0x28fe04
esi            0x101010d        16843021
edi            0xa44ccc 10767564
eip            0x40aa51 0x40aa51 <data_abort+81>
eflags         0x202    [ IF ]
cs             0x23     35
ss             0x2b     43
ds             0x2b     43
es             0x2b     43
fs             0x53     83
gs             0x2b     43
(gdb) n
0x00401982 in longjmp ()
(gdb) print restart_after_exception
$3 = {2686664, 16, 10767564, 13045723, 2686540, 4276596, 2686616, 0,
  1447244336, 0, 0, 0, 0, 0, 0, 0}
(gdb) info registers
eax            0x102fd904       271571204
ecx            0x40aa65 4237925
edx            0x20000013       536870931
ebx            0x1      1
esp            0x28fdec 0x28fdec
ebp            0x28fe04 0x28fe04
esi            0x101010d        16843021
edi            0xa44ccc 10767564
eip            0x401982 0x401982 <longjmp+1>
eflags         0x202    [ IF ]
cs             0x23     35
ss             0x2b     43
ds             0x2b     43
es             0x2b     43
fs             0x53     83
gs             0x2b     43
(gdb) n
Single stepping until exit from function longjmp,
which has no line number information.
main (argc=0, argv=0x0) at emu.c:550
550             while (!exiting) {
(gdb) print restart_after_exception
$4 = {2686664, 16, 10767564, 13045723, 2686540, 4276596, 2686616, 0,
  1447244336, 0, 0, 0, 0, 0, 0, 0}
(gdb) info registers
eax            0x0      0
ecx            0xa44040 10764352
edx            0x20000013       536870931
ebx            0x28fec8 2686664
esp            0x10     0x10
ebp            0xa44ccc 0xa44ccc <arm+204>
esi            0xc70fdb 13045723
edi            0x28fe4c 2686540
eip            0x414174 0x414174 <main+2068>
eflags         0x202    [ IF ]
cs             0x23     35
ss             0x2b     43
ds             0x2b     43
es             0x2b     43
fs             0x53     83
gs             0x2b     43
(gdb) n
551                     sched_process_pending_events();
(gdb) print restart_after_exception
$5 = {2686664, 16, 10767564, 13045723, 2686540, 4276596, 2686616, 0,
  1447244336, 0, 0, 0, 0, 0, 0, 0}
(gdb) info registers
eax            0x0      0
ecx            0xa44040 10764352
edx            0x20000013       536870931
ebx            0x28fec8 2686664
esp            0x10     0x10
ebp            0xa44ccc 0xa44ccc <arm+204>
esi            0xc70fdb 13045723
edi            0x28fe4c 2686540
eip            0x414181 0x414181 <main+2081>
eflags         0x246    [ PF ZF IF ]
cs             0x23     35
ss             0x2b     43
ds             0x2b     43
es             0x2b     43
fs             0x53     83
gs             0x2b     43
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
main (argc=0, argv=0x0) at emu.c:551
551                     sched_process_pending_events();
(gdb)

It took me a while see it... I'm a noob with this code...
Now what? Have you reported to mingw? Any hotfix?

My version is the following in case it is useful:
Code: [Select]
Using built-in specs.
COLLECT_GCC=i686-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-w64-mingw32/4.9.0/lto-wrapper
Target: i686-w64-mingw32
Configured with: /build/mingw-w64-gcc/src/gcc-4.9.0/configure --prefix=/usr --libexecdir=/usr/lib --target=i686-w64-mingw32 --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada
--enable-shared --enable-static --enable-threads=posix --enable-fully-dynamic-string --enable-libstdcxx-time=yes --with-system-zlib --enable-cloog-backend=isl
--disable-cloog-version-check --disable-isl-version-check --enable-lto --disable-dw2-exceptions --enable-libgomp --disable-multilib --enable-checking=release

Thread model: posix
gcc version 4.9.0 (GCC)
« Last Edit: June 25, 2014, 02:18:29 pm by antoniovazquezblanco »

Offline antoniovazquezblanco

  • LV3 Member (Next: 100)
  • ***
  • Posts: 46
  • Rating: +0/-0
    • View Profile
Re: TI-Nspire emulator
« Reply #271 on: June 25, 2014, 05:30:35 am »
By the way. Given that we have two repos with similar content now, I think we should merge them into one and start working in one organization repo with some conventions like for example git-flow.

What do you think?


Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: TI-Nspire emulator
« Reply #272 on: June 25, 2014, 11:25:06 am »
OMG anyone else getting the huge horizontal scrollbar on this page?

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: TI-Nspire emulator
« Reply #273 on: June 25, 2014, 11:51:22 am »
I get it as well, three times my screen's size O.o
It also seems to happen for unusually big images.

Quote
By the way. Given that we have two repos with similar content now, I think we should merge them into one and start working in one organization repo with some conventions like for example git-flow.
Yup, I think the same. My changes are smaller: A message if ndless wasn't detected at gdb connection and prefixing emu output with "[nspire_emu]".

Quote
It took me a while see it... I'm a noob with this code...
Now what? Have you reported to mingw? Any hotfix?
Maybe it got corrupted somehow. Can you step through setjmp or look when 0x10/16 gets written into restart_after_exception[1]?

Offline antoniovazquezblanco

  • LV3 Member (Next: 100)
  • ***
  • Posts: 46
  • Rating: +0/-0
    • View Profile
Re: TI-Nspire emulator
« Reply #274 on: June 25, 2014, 02:17:42 pm »
Wow... debuging... kills me...

Code: [Select]
Starting program: c:\Users\............................\nspire_emu\src/nspire_emu.exe -1=boot1cx.img -f=flash.bin
[New Thread 1600.0x710]
[New Thread 1600.0x884]
[New Thread 1600.0xa1c]
Hardware watchpoint 1: restart_after_exception[1]

Old value = 0
New value = 16
0x75e9e27e in setjmp3 () from C:\Windows\SysWOW64\msvcrt.dll
(gdb)
(gdb) c
Continuing.

...................................................................... (Tons of output...)


Program received signal SIGSEGV, Segmentation fault.
0x004018e5 in write_word ()
(gdb)
Continuing.

Program received signal SIGSEGV, Segmentation fault.
main (argc=0, argv=0x0) at emu.c:551
551                     sched_process_pending_events();
(gdb)

Ummm.... 0x75e9e27e in setjmp3 () from C:\Windows\SysWOW64\msvcrt.dll???????????

Code: [Select]
$ gdb nspire_emu.exe
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from c:\Users\....................\nspire_emu\src\nspire_emu.exe...done.
(gdb) b main:546
Breakpoint 1 at 0x41396c: file emu.c, line 260.
(gdb) b emu.c:546
Breakpoint 2 at 0x414140: file emu.c, line 546.
(gdb) watch  restart_after_exception[1]
Hardware watchpoint 3: restart_after_exception[1]
(gdb) run -1=boot1cx.img -f=flash.bin
Starting program: c:\Users\..................\nspire_emu\src/ns
pire_emu.exe -1=boot1cx.img -f=flash.bin
[New Thread 2604.0x804]

Breakpoint 1, main (argc=3, argv=0xc429e0) at emu.c:260
warning: Source file is more recent than executable.
260             char *preload_filename[4] = { NULL };
(gdb) c
Continuing.
[New Thread 2604.0x3ac]
[New Thread 2604.0x94c]

Breakpoint 2, main (argc=3, argv=0xc429e0) at emu.c:546
546             sched_update_next_event(0);
(gdb) n
543             sched_items[SCHED_THROTTLE].clock = CLOCK_27M;
(gdb)
544             sched_items[SCHED_THROTTLE].proc = throttle_interval_event;
(gdb)
546             sched_update_next_event(0);
(gdb)
548             setjmp(restart_after_exception);
(gdb) si
0x00414168      548             setjmp(restart_after_exception);
(gdb)
0x0041416f      548             setjmp(restart_after_exception);
(gdb)
0x004138a8 in _setjmp3 ()
(gdb)
0x75e9e275 in setjmp3 () from C:\Windows\SysWOW64\msvcrt.dll
(gdb)
0x75e9e279 in setjmp3 () from C:\Windows\SysWOW64\msvcrt.dll
(gdb)
0x75e9e27b in setjmp3 () from C:\Windows\SysWOW64\msvcrt.dll
(gdb)
Hardware watchpoint 3: restart_after_exception[1]

Old value = 0
New value = 16
0x75e9e27e in setjmp3 () from C:\Windows\SysWOW64\msvcrt.dll
(gdb) disassemble setjmp3
Dump of assembler code for function setjmp3:
   0x75e9e275 <+0>:     mov    0x4(%esp),%edx
   0x75e9e279 <+4>:     mov    %ebp,(%edx)
   0x75e9e27b <+6>:     mov    %ebx,0x4(%edx)
=> 0x75e9e27e <+9>:     mov    %edi,0x8(%edx)
   0x75e9e281 <+12>:    mov    %esi,0xc(%edx)
   0x75e9e284 <+15>:    mov    %esp,0x10(%edx)
   0x75e9e287 <+18>:    mov    (%esp),%eax
   0x75e9e28a <+21>:    mov    %eax,0x14(%edx)
   0x75e9e28d <+24>:    movl   $0x56433230,0x20(%edx)
   0x75e9e294 <+31>:    movl   $0x0,0x24(%edx)
   0x75e9e29b <+38>:    mov    %fs:0x0,%eax
   0x75e9e2a1 <+44>:    mov    %eax,0x18(%edx)
   0x75e9e2a4 <+47>:    cmp    $0xffffffff,%eax
   0x75e9e2a7 <+50>:    je     0x75ed992d <setjmp+56>
   0x75e9e2ad <+56>:    mov    0x8(%esp),%ecx
   0x75e9e2b1 <+60>:    or     %ecx,%ecx
   0x75e9e2b3 <+62>:    jne    0x75ed9939 <setjmp+68>
   0x75e9e2b9 <+68>:    mov    0xc(%eax),%eax
   0x75e9e2bc <+71>:    mov    %eax,0x1c(%edx)
   0x75e9e2bf <+74>:    sub    %eax,%eax
   0x75e9e2c1 <+76>:    ret
   0x75e9e2c2 <+77>:    nop
   0x75e9e2c3 <+78>:    nop
   0x75e9e2c4 <+79>:    nop
   0x75e9e2c5 <+80>:    nop
   0x75e9e2c6 <+81>:    nop
End of assembler dump.
(gdb)

By the way, I've already merged your changes.
Sorry about the scroll. I'm going to edit my post now... xD
« Last Edit: June 25, 2014, 02:19:36 pm by antoniovazquezblanco »

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: TI-Nspire emulator
« Reply #275 on: June 25, 2014, 02:24:32 pm »
Hmm. do __builtin_setjmp and __builtin_longjmp work? I tried it, it didn't make any difference, but I'd want to know whether they also call msvcrt.dll., probably 'cause I forgot copying nspire_emu.exe..
On http://sourceforge.net/p/mingw-w64/mailman/message/31232870 someone seems to have the same issue, even with MinGW 4.8.2, where the bug should have been fixed. It also happens only on 64-bit..
Could you try using the __builtins and -fno-omit-frame-pointer just in case and then look at the write to restart_after_exception (or not, if it works :D )?

Edit: You forgot
Code: [Select]
emuprintf("Ndless not detected or too old. Debugging of applications not available!\n"); :P

Edit2: Compiled, tested: WORKS!
« Last Edit: June 25, 2014, 02:33:21 pm by Vogtinator »

Offline antoniovazquezblanco

  • LV3 Member (Next: 100)
  • ***
  • Posts: 46
  • Rating: +0/-0
    • View Profile
Re: TI-Nspire emulator
« Reply #276 on: June 25, 2014, 02:42:43 pm »
Compiled with __builtin_... + no -fno-omit-frame-pointer and it worked both in wine and windows 8.1  ;D

I will commit the mising line now.

We should report the issue...

Thanks! :)

Offline antoniovazquezblanco

  • LV3 Member (Next: 100)
  • ***
  • Posts: 46
  • Rating: +0/-0
    • View Profile
Re: TI-Nspire emulator
« Reply #277 on: June 25, 2014, 04:00:28 pm »

Offline antoniovazquezblanco

  • LV3 Member (Next: 100)
  • ***
  • Posts: 46
  • Rating: +0/-0
    • View Profile
Re: TI-Nspire emulator
« Reply #278 on: June 26, 2014, 10:56:08 am »
For those who know the code of the project better than me, is apb.c code any useful? Can it be deleted? Old makefile didnt compile it and all the functions defined in there are duplicated. It is something someone is actually working on or it is something outdated?

I would also like to specify some kind of coding guidelines as sometimes things are very messy because of a non unified style. What do you think?

Thanks!
« Last Edit: June 26, 2014, 11:22:58 am by antoniovazquezblanco »

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: TI-Nspire emulator
« Reply #279 on: June 26, 2014, 12:56:52 pm »
It's pretty awesome to see someone porting Nspire-emu to Linux by the way. You're doing a great job.

Offline antoniovazquezblanco

  • LV3 Member (Next: 100)
  • ***
  • Posts: 46
  • Rating: +0/-0
    • View Profile
Re: TI-Nspire emulator
« Reply #280 on: June 26, 2014, 01:00:59 pm »
It's pretty awesome to see someone porting Nspire-emu to Linux by the way. You're doing a great job.

Lets say "trying to" port... :)

There's a long way ahead and any help would be apreciated. Really anything from suggestions, to actual code. Greetings help a lot :)

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: TI-Nspire emulator
« Reply #281 on: June 26, 2014, 01:02:52 pm »
Well I could do some testing if you tell me what you need but I can't contribute any code unfortunately. First because I don't know any x86, second because I'm not really interested in making more than scripts on PCs. :P

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: TI-Nspire emulator
« Reply #282 on: June 26, 2014, 01:04:36 pm »
An important question is where to start. First GUI, then "kernel"?
I'd go for the first, as that could be tested with wine accurately.

Quote
Greetings help a lot :)
Well, have some:
Hi! Hi! Hi! Hi! Hello! Hello! Hello! Hello! Hello! Hello! Hey! Hey! Hey! 'sup? 'sup? 'sup? 'sup? :P

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: TI-Nspire emulator
« Reply #283 on: June 26, 2014, 01:06:39 pm »
Hum, I'd rather call it a core than a kernel. :P

Offline antoniovazquezblanco

  • LV3 Member (Next: 100)
  • ***
  • Posts: 46
  • Rating: +0/-0
    • View Profile
Re: TI-Nspire emulator
« Reply #284 on: June 26, 2014, 01:19:50 pm »
An important question is where to start. First GUI, then "kernel"?
I'd go for the first, as that could be tested with wine accurately.

Quote
Greetings help a lot :)
Well, have some:
Hi! Hi! Hi! Hi! Hello! Hello! Hello! Hello! Hello! Hello! Hey! Hey! Hey! 'sup? 'sup? 'sup? 'sup? :P

How the hell could I have...??? Greetings instead of congratulations...?  ???

As for what first I think I have seen some code in your repo wich involved using Qt. I have very little idea about that so if you were able to start thinking about how things could be implemented it could help me a lot. On the other hand there are some ugly things around there and I feel like the code should be a bit more organized so I think I will be spending some time with that. apb.c code for example, I don't know if it is usefull for anyone, data types are a mess, I would like to parse arguments from command line with optarg for simplicity (maybe a gui if no argument is provided...), etc.

I've been filling some of this things in my repo issues list in order not to forguet them.
https://github.com/antoniovazquezblanco/nspire_emu/issues?state=open
Pick one if you feel in the mood :).

Some "core" code has ben initially ported to linux (see os/os-linux.c) but a lot is missing.