Retrieving the memory map of its own process in QNX

青春壹個敷衍的年華 提交于 2019-12-13 05:21:59

问题


In Linux if we look at the /proc/self/maps:

00400000-004ef000 r-xp 00000000 08:01 12845058                           /bin/bash
006ef000-006f0000 r--p 000ef000 08:01 12845058                           /bin/bash
006f0000-006f9000 rw-p 000f0000 08:01 12845058                           /bin/bash
006f9000-006ff000 rw-p 00000000 00:00 0
00d5a000-010a2000 rw-p 00000000 00:00 0                                  [heap]
7f6fe582a000-7f6fe5835000 r-xp 00000000 08:01 1048595                    /lib/x86_64-linux-gnu/libnss_files-2.19.so
7f6fe5835000-7f6fe5a34000 ---p 0000b000 08:01 1048595                    /lib/x86_64-linux-gnu/libnss_files-2.19.so
7f6fe5a34000-7f6fe5a35000 r--p 0000a000 08:01 1048595                    /lib/x86_64-linux-gnu/libnss_files-2.19.so
7f6fe5a35000-7f6fe5a36000 rw-p 0000b000 08:01 1048595                    /lib/x86_64-linux-gnu/libnss_files-2.19.so

I want information like pathname and starting address for Qnx. How can I get that information?

My analysis says that there is not /proc/self/maps file in Qnx.


回答1:


We have self file in QNX too !!

The address space is represented by a binary file called "as" in every folder in /proc. /proc/self/as contains the address space of the current process.

Problem is that its not human readable directly. You need to use devctl() to read it. Below is the link for all the devctl commands regarding address space decoding.

http://www.qnx.com/developers/docs/6.5.0_sp1/index.jsp?topic=%2Fcom.qnx.doc.neutrino_cookbook%2Fs3_procfs.html

Example - devctl("/proc/self/as",DCMD_PROC_TIDSTATUS,&debug_data, sizeof(debug_data)

This command will give you debug data of the thread in a struct _debug_thread_info structure.

Similarly DCMD_PROC_PAGEDATA and DCMD_PROC_MAPINFO can be used to get the segment mapping ( in linux maps file does this) information of a process's address space.

Hope this helps.




回答2:


Try to use this:

pidin -p<process> mapinfo


来源:https://stackoverflow.com/questions/34587285/retrieving-the-memory-map-of-its-own-process-in-qnx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!