4

How can I list all loaded libraries of a process in FreeBSD? On Linux I can use /proc

cat /proc/$pid/maps

on Solaris there is pldd

pldd $pid

For FreeBSD /proc also works:

cat /proc/$pid/map

however, /proc is not mounted by default. As this is used in an autodetection tool on customers' systems, I'm looking for something (tool or file) that works out of the box. I'm assuming there must be an additional interface to process data on FreeBSD because top works even without mounted /proc.

  • Pldd on Solaris works based on /proc, I would assume that you cannot find a non-/proc based method on FreeBSD either. – schily Sep 11 '15 at 9:25
4

procstat is your friend.

You get the info for a specific pid using:

procstat -v $pid

Or if you want for all processes then simply:

procstat -va

It yields an output like this:

$ procstat -v 61303
  PID              START                END PRT  RES PRES REF SHD   FL TP PATH
61303           0x400000           0x438000 r-x   46   47   2   0 CN-- vn /usr/local/bin/ksh
61303           0x638000           0x63c000 rw-    4    4   1   0 CN-- df
61303        0x800638000        0x800655000 r-x   29   30 204   0 CN-- vn /libexec/ld-elf.so.1
61303        0x800655000        0x800675000 rw-   23   23   1   0 CN-- df
61303        0x800855000        0x800857000 rw-    2    2   1   0 CN-- df
61303        0x800857000        0x8009cd000 r-x  293  329 218 102 CN-- vn /lib/libc.so.7
61303        0x8009cd000        0x800bcd000 ---    0    0   1   0 CN-- df
61303        0x800bcd000        0x800bd9000 rw-   12    0   1   0 C--- vn /lib/libc.so.7
61303        0x800bd9000        0x800c03000 rw-    8    8   1   0 CN-- df
61303        0x801000000        0x801800000 rw-   26   26   1   0 C--- df
61303     0x7ffffffdf000     0x7ffffffff000 rw-    3    3   1   0 C--D df
61303     0x7ffffffff000     0x800000000000 r-x    1    1 208   0 ---- ph

You see the shared libraries (and the binary itself) under PATH

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.