Previous: , Up: Python API   [Contents][Index]


23.3.2.45 Core Files In Python

When a core file is loaded into an inferior (see Inferiors In Python) for examination (see core-file command), information about the core file is contained in a gdb.Corefile object.

The gdb.Corefile for an inferior can be accessed using the Inferior.corefile attribute. This will be None if no core file is loaded.

A gdb.Corefile object has the following attributes:

Variable: Corefile.filename

This read only attribute contains a non-empty string, the file name of the core file. Attempting to access this attribute on an invalid gdb.Corefile object will raise a RuntimeError exception.

A gdb.Corefile object has the following methods:

Function: Corefile.is_valid ()

Returns True if the gdb.Corefile object is valid, False if not. A gdb.Corefile object will become invalid when the core file is unloaded from the inferior using the core-file command (see core-file command), or if the inferior in which the core file is loaded is deleted. All other gdb.Corefile methods and attributes will throw an exception if it is invalid at the time the method is called, or the attribute accessed.

Function: Corefile.mapped_files ()

Return a list of gdb.CorefileMappedFile (see below) objects representing files that were mapped into the process when the core file was created. This information is read from the ‘NT_FILE’ core file note on Linux. Not every target supports accessing this information, for targets without support, an empty list will be returned.

One may add arbitrary attributes to gdb.Corefile objects in the usual Python way. This is useful if, for example, one needs to do some extra record keeping associated with the corefile. See choosing attribute names, for guidance on selecting a suitable name for new attributes.

The Corefile.mapped_files () method returns a list of gdb.CorefileMappedFile objects. Each of these objects represents a file that was fully, or partially, mapped into the processes address space when the core file was created.

A gdb.CorefileMappedFile object has the following attributes:

Variable: CorefileMappedFile.filename

This read only attribute contains a non-empty string, the file name of the mapped file.

Variable: CorefileMappedFile.build_id

This read only attribute contains a non-empty string or None. This is the build-id of the mapped file extracted from the core file, or None if there was no build-id, or GDB was unable to extract the build-id.

Variable: CorefileMappedFile.is_main_executable

This read only attribute is True if GDB believes this mapping represents the main executable for which this core file was created. This will be False for all other mappings.

Variable: CorefileMappedFile.regions

This read only attribute contains a list of gdb.CorefileMappedFileRegion objects. Each of these objects describes a region of the file that was mapped into the process when the core file was created, further details are given below.

The gdb.CorefileMappedFileRegion object describes which part of a file that was mapped into a process when the core file was created.

A gdb.CorefileMappedFile object has the following attributes:

Variable: CorefileMappedFileRegion.start

This read only attribute contains the start address of this mapping within the inferior.

Variable: CorefileMappedFileRegion.end

This read only attribute contains end address of this mapping within the inferior.

Variable: CorefileMappedFileRegion.file_offset

This read only attribute contains the offset within the mapped file for this mapping.


Previous: , Up: Python API   [Contents][Index]