<div dir="ltr">could you share the output of ghc --info?</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 8, 2014 at 12:10 AM, Michael Jones <span dir="ltr"><<a href="mailto:mike@proclivis.com" target="_blank">mike@proclivis.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am having problems building a GHC cross compiler for Linux (Yocto on a Wandboard) running on a Cortex A9, and need some advice on how to debug it.<br>
<br>
The cross compiler produces an executable that runs on the Target, but fails to print. So I need help coming up with a strategy to narrow down the root cause.<br>
<br>
Some details:<br>
<br>
The application:<br>
<br>
main = do<br>
putStrLn "Haskell start"<br>
<br>
<br>
The command line options work. The program runs, and I can step through assembly. Debug data is printed to the console. But putStrLn fails, and program enters an infinite loop.<br>
<br>
I compile my app as follows:<br>
<br>
arm-unknown-linux-gnueabi-ghc -debug -static Main.hs<br>
<br>
Using -threaded does not fix the problem.<br>
<br>
Let me compare debug data from a run on my HOST, with a run on my TARGET. First, a run from my HOST:<br>
<br>
created capset 0 of type 2<br>
created capset 1 of type 3<br>
cap 0: initialised<br>
assigned cap 0 to capset 0<br>
assigned cap 0 to capset 1<br>
cap 0: created thread 1<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (suspended while making a foreign call)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (finished)<br>
cap 0: created thread 2<br>
cap 0: running thread 2 (ThreadRunGHC)<br>
cap 0: thread 2 stopped (finished)<br>
cap 0: starting GC<br>
cap 0: GC working<br>
cap 0: GC idle<br>
cap 0: GC done<br>
cap 0: GC idle<br>
cap 0: GC done<br>
cap 0: GC idle<br>
cap 0: GC done<br>
cap 0: GC idle<br>
cap 0: GC done<br>
cap 0: all caps stopped for GC<br>
cap 0: finished GC<br>
removed cap 0 from capset 0<br>
removed cap 0 from capset 1<br>
cap 0: shutting down<br>
deleted capset 0<br>
deleted capset 1<br>
<br>
And, it prints properly. So this is my referenced for what it should do on the TARGET.<br>
<br>
When I run on my TARGET, I get:<br>
<br>
created capset 0 of type 2<br>
created capset 1 of type 3<br>
cap 0: initialised<br>
assigned cap 0 to capset 0<br>
assigned cap 0 to capset 1<br>
cap 0: created thread 1<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (yielding)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (yielding)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (yielding)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (yielding)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (yielding)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (yielding)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (stack overflow)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (stack overflow)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (stack overflow)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (yielding)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (stack overflow)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (stack overflow)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (stack overflow)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (yielding)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (stack overflow)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (heap overflow)<br>
cap 0: starting GC<br>
cap 0: GC working<br>
cap 0: GC idle<br>
cap 0: GC done<br>
cap 0: GC idle<br>
cap 0: GC done<br>
cap 0: GC idle<br>
cap 0: GC done<br>
cap 0: all caps stopped for GC<br>
cap 0: finished GC<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (yielding)<br>
cap 0: running thread 1 (ThreadRunGHC)<br>
cap 0: thread 1 stopped (stack overflow)<br>
...<br>
<br>
And the debug data goes on forever, just as debugging assembly demonstrated an infinite loop.<br>
<br>
Clearly, the following does not occur:<br>
<br>
cap 0: thread 1 stopped (suspended while making a foreign call)<br>
<br>
And there are overflows.<br>
<br>
If I had to guess, it is possible that some code is in a loop retrying to foreign call, and failing. Certainly, it is in some kind of a loop, because I found a place I can put a break point and and telling GDB to continue will cause the break over and over at the same place. So somewhere there is a loop.<br>
<br>
I can step through the application with GDB and see names of files and offsets in assembly. But without a true source code debug, that is a bit rough, especially for someone that does not know the RTS code. If there was a way to compile such that C source code was available and a place to break, that would help. However, I suspect since it never makes a foreign call, there is no place in C to place the breakpoint anyway. So I am also assuming there is no direct way to debug with GDB.<br>
<br>
But, I can see debug output printed to the console. My hope is there is a way to enable more printing, or a place I can add more print functions to help find the problem.<br>
<br>
So I think I need one of the following:<br>
<br>
- A solution from someone that has seen this before, perhaps on the iPhone<br>
- How to enable more debug logging<br>
- Where in the source code to add debug statements to narrow down the problem<br>
<br>
Thanks for any help you can give.<br>
<br>
Mike<br>
<br>
<br>
_______________________________________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
</blockquote></div><br></div>