<div dir="ltr"><div><div>The "off" table is due to a glitch in the output routine.  The too short "H  E A P" banner is indeed a 32-vs-64 bit bug.  I fixed both in <a href="https://github.com/erlang/otp/pull/1619">https://github.com/erlang/otp/pull/1619</a>.<br></div><br></div>WRT accessing the current "struct process", I haven't looked in detail, but in general the NIF interface wants to abstract away representational details and replace them function calls (actual runtime function calls, not just function-like macros).  I don't see direct accesses to "struct process" fitting into that.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 5, 2017 at 4:39 AM, Boshan Sun <span dir="ltr"><<a href="mailto:sunboshan@gmail.com" target="_blank">sunboshan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all, <div><br></div><div>In Erlang, you can use `hipe_bifs:show_heap(self()).` to debug the process's heap.<br><br><div><font face="monospace, monospace">From: 0x000000001ee5c6e0 to 0x000000001ee5c748</font></div><div><font face="monospace, monospace"> |         H E A P         |</font></div><div><font face="monospace, monospace"> |            Address |           Contents |</font></div><div><font face="monospace, monospace"> |--------------------|-------<wbr>-------------|</font></div><div><font face="monospace, monospace">4 | 0x000000001ee5c6e0 | 0x000000000000004f |</font></div><div><font face="monospace, monospace">[] | 0x000000001ee5c6e8 | 0xfffffffffffffffb |</font></div><div><font face="monospace, monospace">3 | 0x000000001ee5c6f0 | 0x000000000000003f |</font></div><div><font face="monospace, monospace">[4] | 0x000000001ee5c6f8 | 0x000000001ee5c6e1 |</font></div><div><font face="monospace, monospace"> |--------------------|-------<wbr>-------------|</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">However the implementation is for 32-bits machine, and the table is kind of off for a 64-bits erlang.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">I want to write a C NIF to print similar heap information. What I need is the address of `</font><font face="monospace, monospace">process -> heap</font><font face="arial, helvetica, sans-serif">` and the heap size so I can get the heap's information. <br><br>My question is, is there a way to get a pointer to the given process via pid in C NIF?</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">In NIF doc there's <a href="http://erlang.org/doc/man/erl_nif.html#enif_get_local_pid" target="_blank">enif_get_local_pid</a> , how does this pid translate to the process pointer?</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Thanks!</font></div><span class="HOEnZb"><font color="#888888"><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Boshan</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div></font></span></div>
<br>______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>