Posts Tagged ‘erts_debug:get_internal_state’


April 7th, 2010 2 comments

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: 查看Erlang运行期内部状态的方法(基于R13B04)

erts_debug:get_internal_state是用来获取Erlang运行期内部信息的主要手段. 但是这个功能是用来给开发人员或者说需要了解系统内部细节的场合, 比如说系统调优.
1. reds_left
2. node_and_dist_references
3. monitoring_nodes
4. next_pid
5. next_port
6. ‘DbTable_words’
7. check_io_debug
8. process_info_args
9. processes
10. processes_bif_info
11. max_atom_out_cache_index
12. nbalance
13. available_internal_state
14. force_heap_frags
15. {process_status, Pid}
16. {link_list, Pid} 或者 {link_list, Port} 或者 {link_list, Nodename}
17. {monitor_list, Pid} 或者 {monitor_list, Nodename}
18. {channel_number, Sysname}
19. {have_pending_exit, Pid}
20. {binary_info, Binary}
21. {dist_port, Sysname}
22. {atom_out_cache_index, Atom}
23. {fake_scheduler_bindings, How} How=spread | processor_spread | thread_spread | default_bind | no_node_processor_spread | no_node_thread_spread | no_spread | unbound

使用此功能的前提是先用erts_debug:set_internal_state(available_internal_state, true). 否者调用get_internal_state会提示失败.

root@ubuntu:~/otp/test# erl -sname x
Erlang R14A (erts-5.8)  [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]

Eshell V5.8  (abort with ^G)
(x@ubuntu)1> erts_debug:get_internal_state(check_io_debug). 
** exception error: undefined function erts_debug:get_internal_state/1
(x@ubuntu)2> erts_debug:set_internal_state(available_internal_state, true).
=ERROR REPORT==== 7-Apr-2010::14:40:41 ===
Process <0.38.0> on node 'x@ubuntu' enabled access to the emulator internal state.
NOTE: This is an erts internal test feature and should *only* be used by OTP test-suites.
(x@ubuntu)3> erts_debug:get_internal_state(check_io_debug). 
--- fds in pollset --------------------------------------
fd=0 type=chr driver_select ev=IN  inport=#Port<0.294> inname=tty_sl -c -e indrv=tty_sl 
fd=3 type=fifo internal ep_ev=IN
fd=4 type=fifo internal 
fd=7 type=sock driver_select ev=IN  inport=#Port<0.62> inname=tcp_inet indrv=tcp_inet 
fd=8 type=sock driver_select ev=IN  inport=#Port<0.65> inname=tcp_inet indrv=tcp_inet 
fd=9 type=fifo driver_select ev=IN  inport=#Port<0.486> inname=inet_gethost 4  indrv=spawn 
fd=10 type=sock driver_select ev=IN  inport=#Port<0.492> inname=tcp_inet indrv=tcp_inet 
fd=11 type=sock driver_select ev=IN  inport=#Port<0.495> inname=tcp_inet indrv=tcp_inet 

used fds=6
internal fds=2
(x@ubuntu)4>  erts_debug:get_internal_state({process_status, self()}).

Post Footer automatically generated by wp-posturl plugin for wordpress.