Other gdb ; identify heap memory address of a running program

Goal is to attach to a running process, get the process mappings, identify heap and examine. Within gdb on Linux it's quite comfortable to do info proc map. I have some struggle with this on FreeBSD.
When I attach to a running program and do the (more generic) maintenance info sections:

Code:
(gdb) main info sec
Exec file:
  `/local/test/test', file type elf32-i386-freebsd.
  0x8048134->0x8048149 at 0x00000134: .interp ALLOC LOAD READONLY DATA HAS_CONTENTS
  0x804814c->0x8048164 at 0x0000014c: .note.ABI-tag ALLOC LOAD READONLY DATA HAS_CONTENTS
  0x8048164->0x80482a0 at 0x00000164: .hash ALLOC LOAD READONLY DATA HAS_CONTENTS
  0x80482a0->0x8048520 at 0x000002a0: .dynsym ALLOC LOAD READONLY DATA HAS_CONTENTS
  0x8048520->0x804867a at 0x00000520: .dynstr ALLOC LOAD READONLY DATA HAS_CONTENTS
...
.. I dont see it.

I guess I could use procstat -v <PID> which does provide better information but I was not able to tell "this is heap":

Code:
procstat -v 80900
  PID  START  END PRT  RES PRES REF SHD  FL TP PATH
80900  0x8048000  0x804a000 r-x  2  0  1  0 CN-- vn /local/test/test
80900  0x804a000  0x8400000 rw-  1  0  1  0 ---- df
80900 0x2804a000 0x2805f000 r-x  20  0  1  0 C--- vn /libexec/ld-elf.so.1
80900 0x2805f000 0x28060000 rw-  1  0  1  0 C--- vn /libexec/ld-elf.so.1
80900 0x28060000 0x2806a000 rw-  10  0  1  0 ---- df
80900 0x2806a000 0x28080000 r-x  22  0  1  0 C--- vn /lib/libthr.so.3
80900 0x28080000 0x28082000 rw-  2  0  1  0 C--- vn /lib/libthr.so.3
80900 0x28082000 0x2808a000 rw-  7  0  1  0 ---- df
80900 0x2808a000 0x28197000 r-x  236  0  66  31 CN-- vn /lib/libc.so.7
80900 0x28197000 0x2819e000 rw-  7  0  1  0 C--- vn /lib/libc.so.7
80900 0x2819e000 0x281c8000 rw-  14  0  2  0 ---- df
80900 0x28400000 0x28800000 rw-  11  0  2  0 ---- df
80900 0xbf9df000 0xbf9ff000 rwx  2  0  1  0 ---D df
80900 0xbf9ff000 0xbfa00000 ---  0  0  0  0 ---- --
80900 0xbfbe0000 0xbfc00000 rwx  3  0  1  0 ---D df

I'd like to have a better way of identifying it than "somewhere after the bss section".

I tried to find the memory map (virtual memory layout) of 32b FreeBSD system, something official. What I found was that the memory is divided into classic 1:4 ratio where the upper chunk is reserved for the kernel.

I'd like to know if there's better way of identifying this though.
 
Last edited:
Back
Top