Sun Studio 12 Update 1: Debugging a Program With dbx

mmapfile Command

The mmapfile command views the contents of memory mapped files that are missing from a core dump. It is valid only in native mode.

Solaris core files do not contain any memory segments that are read-only. Executable read-only segments (that is, text) are dealt with automatically and dbx resolves memory accesses against these by looking into the executable and the relevant shared objects.

Syntax

mmapfile mmapped_file address offset length

View contents of memory mapped files missing from core dump.

where:

mmapped_file is the file name of a file that was memory mapped during a core dump.

address is the starting address of the address space of the process.

length is length in bytes of the address space to be viewed.

offset is the offset in bytes to the starting address in mmapped_file.

Example

Read-only data segments typically occur when an application memory maps a database. For example:

caddr_t vaddr = NULL;
off_t offset = 0;
size_t = 10 * 1024;
int fd;
fd = open("../DATABASE", ...)
vaddr = mmap(vaddr, size, PROT_READ, MAP_SHARED, fd, offset);
index = (DBIndex *) vaddr;

To be able to access the database through the debugger as memory you would type:

mmapfile ../DATABASE $[vaddr] $[offset] $[size]

Then you could look at your database contents in a structured way by typing:

print *index