[erlang-questions] Erlang C NIF access to process struct

Mikael Pettersson mikpelinux@REDACTED
Sun Nov 5 10:34:47 CET 2017


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
https://github.com/erlang/otp/pull/1619.

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.

On Sun, Nov 5, 2017 at 4:39 AM, Boshan Sun <sunboshan@REDACTED> wrote:

> Hi all,
>
> In Erlang, you can use `hipe_bifs:show_heap(self()).` to debug the
> process's heap.
>
> From: 0x000000001ee5c6e0 to 0x000000001ee5c748
>  |         H E A P         |
>  |            Address |           Contents |
>  |--------------------|--------------------|
> 4 | 0x000000001ee5c6e0 | 0x000000000000004f |
> [] | 0x000000001ee5c6e8 | 0xfffffffffffffffb |
> 3 | 0x000000001ee5c6f0 | 0x000000000000003f |
> [4] | 0x000000001ee5c6f8 | 0x000000001ee5c6e1 |
>  |--------------------|--------------------|
>
> However the implementation is for 32-bits machine, and the table is kind
> of off for a 64-bits erlang.
>
> I want to write a C NIF to print similar heap information. What I need is
> the address of `process -> heap` and the heap size so I can get the
> heap's information.
>
> My question is, is there a way to get a pointer to the given process via
> pid in C NIF?
>
> In NIF doc there's enif_get_local_pid
> <http://erlang.org/doc/man/erl_nif.html#enif_get_local_pid> , how does
> this pid translate to the process pointer?
>
> Thanks!
>
> Boshan
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20171105/e854a74f/attachment.htm>


More information about the erlang-questions mailing list