<trclass="memdesc:a6556a8ed7c7c5727a109397c6a43c446"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Reads the Mach-O image file’s load commands from another process. <ahref="#a6556a8ed7c7c5727a109397c6a43c446">More...</a><br/></td></tr>
<trclass="memdesc:a9b98ab3b8c98c6ef584681baa355ca3a"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the mapped size of the Mach-O image’s <code>__TEXT</code> segment. <ahref="#a9b98ab3b8c98c6ef584681baa355ca3a">More...</a><br/></td></tr>
<trclass="memdesc:a0216e421b0f2677f3841b72e80cba832"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the Mach-O image’s “slide,” the difference between its actual load address and its preferred load address. <ahref="#a0216e421b0f2677f3841b72e80cba832">More...</a><br/></td></tr>
<trclass="memdesc:a687d6ad610407967e283d8ba8b6e2db4"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Obtain segment information by segment name. <ahref="#a687d6ad610407967e283d8ba8b6e2db4">More...</a><br/></td></tr>
<trclass="memdesc:a1917ca481052f1d2de7163cb6f8701cc"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Obtain section information by segment and section name. <ahref="#a1917ca481052f1d2de7163cb6f8701cc">More...</a><br/></td></tr>
<trclass="memdesc:ac9a2388f42c8d4c5c01ca007e93079fc"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Obtain section information by section index. <ahref="#ac9a2388f42c8d4c5c01ca007e93079fc">More...</a><br/></td></tr>
<trclass="memdesc:adbaaf5a08d6e67fe7128d171cd11b176"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Looks up a symbol in the image’s symbol table. <ahref="#adbaaf5a08d6e67fe7128d171cd11b176">More...</a><br/></td></tr>
<trclass="memdesc:a42cdb8f4d8dc4ab9b768b1219133ab2c"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns a Mach-O dylib image’s current version. <ahref="#a42cdb8f4d8dc4ab9b768b1219133ab2c">More...</a><br/></td></tr>
<trclass="memdesc:a72201407e48e5deb91f60f8bb7029f7a"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Obtains the module’s <aclass="el"href="structcrashpad_1_1CrashpadInfo.html"title="A structure that can be used by a Crashpad-enabled program to provide information to the Crashpad cra...">CrashpadInfo</a> structure. <ahref="#a72201407e48e5deb91f60f8bb7029f7a">More...</a><br/></td></tr>
<divclass="textblock"><p>A reader for Mach-O images mapped into another process. </p>
<p>This class is capable of reading both 32-bit (<code>mach_header</code>/<code>MH_MAGIC</code>) and 64-bit (<code>mach_header_64</code>/<code>MH_MAGIC_64</code>) images based on the bitness of the remote process.</p>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="classcrashpad_1_1MachOImageAnnotationsReader.html"title="A reader for annotations stored in a Mach-O image mapped into another process. ">MachOImageAnnotationsReader</a></dd></dl>
</div><h2class="groupheader">Member Function Documentation</h2>
<p>This is the value passed as <em>address</em> to <aclass="el"href="classcrashpad_1_1MachOImageReader.html#a6556a8ed7c7c5727a109397c6a43c446"title="Reads the Mach-O image file’s load commands from another process. ">Initialize()</a>. </p>
<p>Returns a Mach-O dylib image’s current version. </p>
<p>This information comes from the <code>dylib_current_version</code> field of a dylib’s <code>LC_ID_DYLIB</code> load command. For dylibs without this load command, <code>0</code> will be returned.</p>
<p>This method may only be called on Mach-O images for which <aclass="el"href="classcrashpad_1_1MachOImageReader.html#a8cd79040c190b0f165fdb915bc469e8b"title="Returns the Mach-O file type. ">FileType()</a> returns <code>MH_DYLIB</code>. </p>
<p>The dynamic linker is normally /usr/lib/dyld.</p>
<p>For executable images (those with file type <code>MH_EXECUTE</code>), this is the name provided in the <code>LC_LOAD_DYLINKER</code> load command, if any. For dynamic linker images (those with file type <code>MH_DYLINKER</code>), this is the name provided in the <code>LC_ID_DYLINKER</code> load command. In other cases, this will be empty. </p>
<p>This value comes from the <code>filetype</code> field of the <code>mach_header</code> or <code>mach_header_64</code>. Common values include <code>MH_EXECUTE</code>, <code>MH_DYLIB</code>, <code>MH_DYLINKER</code>, and <code>MH_BUNDLE</code>. </p>
<p>Obtains the module’s <aclass="el"href="structcrashpad_1_1CrashpadInfo.html"title="A structure that can be used by a Crashpad-enabled program to provide information to the Crashpad cra...">CrashpadInfo</a> structure. </p>
<dlclass="section return"><dt>Returns</dt><dd><code>true</code> on success, <code>false</code> on failure. If the module does not have a <code>__DATA,crashpad_info</code> section, this will return <code>false</code> without logging any messages. Other failures will result in messages being logged. </dd></dl>
<p>Obtain section information by section index. </p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">index</td><td>The index of the section to return, in the order that it appears in the segment load commands. This is a 1-based index, matching the section number values used for <code>nlist::n_sect</code>. </td></tr>
<tr><tdclass="paramdir">[out]</td><tdclass="paramname">containing_segment</td><td>The segment that contains the section. This parameter can be <code>nullptr</code>. The caller does not take ownership; the lifetime of the returned object is scoped to the lifetime of this <aclass="el"href="classcrashpad_1_1MachOImageReader.html"title="A reader for Mach-O images mapped into another process. ">MachOImageReader</a> object. </td></tr>
<tr><tdclass="paramdir">[out]</td><tdclass="paramname">address</td><td>The actual address that the section was loaded at in memory, taking any “slide” into account if the section did not load at its preferred address as stored in the Mach-O image file. This parameter can be <code>nullptr</code>.</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>A pointer to the section information. If <em>index</em> is out of range, logs a warning and returns <code>nullptr</code>. The caller does not take ownership; the lifetime of the returned object is scoped to the lifetime of this <aclass="el"href="classcrashpad_1_1MachOImageReader.html"title="A reader for Mach-O images mapped into another process. ">MachOImageReader</a> object.</dd></dl>
<p>No parameter is provided for the section’s size, because it can be obtained from the returned process_types::section::size field.</p>
<dlclass="section note"><dt>Note</dt><dd>The process_types::section::addr field gives the section’s preferred load address as stored in the Mach-O image file, and is not adjusted for any “slide” that may have occurred when the image was loaded. Use <em>address</em> to obtain the section’s actual load address. </dd>
Unlike <aclass="el"href="classcrashpad_1_1MachOImageSegmentReader.html#a370e8711294ba506de99e093ac879357"title="Obtain section information by section index. ">MachOImageSegmentReader::GetSectionAtIndex()</a>, this method accepts out-of-range values for <em>index</em>, and returns <code>nullptr</code> instead of aborting execution upon encountering an out-of-range value. This is because a Mach-O image file’s symbol table refers to this per-module section index, and an out-of-range index in that case should be treated as a data error (where the data is beyond this code’s control) and handled non-fatally by reporting the error to the caller. </dd></dl>
<p>Obtain section information by segment and section name. </p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">segment_name</td><td>The name of the segment to search for, for example, <code>"__TEXT"</code>. </td></tr>
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">section_name</td><td>The name of the section within the segment to search for, for example, <code>"__text"</code>. </td></tr>
<tr><tdclass="paramdir">[out]</td><tdclass="paramname">address</td><td>The actual address that the section was loaded at in memory, taking any “slide” into account if the section did not load at its preferred address as stored in the Mach-O image file. This parameter can be <code>nullptr</code>.</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>A pointer to the section information if it was found, or <code>nullptr</code> if it was not found. The caller does not take ownership; the lifetime of the returned object is scoped to the lifetime of this <aclass="el"href="classcrashpad_1_1MachOImageReader.html"title="A reader for Mach-O images mapped into another process. ">MachOImageReader</a> object.</dd></dl>
<p>No parameter is provided for the section’s size, because it can be obtained from the returned process_types::section::size field.</p>
<dlclass="section note"><dt>Note</dt><dd>The process_types::section::addr field gives the section’s preferred load address as stored in the Mach-O image file, and is not adjusted for any “slide” that may have occurred when the image was loaded. Use <em>address</em> to obtain the section’s actual load address. </dd></dl>
<p>Obtain segment information by segment name. </p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">segment_name</td><td>The name of the segment to search for, for example, <code>"__TEXT"</code>.</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>A pointer to the segment information if it was found, or <code>nullptr</code> if it was not found. The caller does not take ownership; the lifetime of the returned object is scoped to the lifetime of this <aclass="el"href="classcrashpad_1_1MachOImageReader.html"title="A reader for Mach-O images mapped into another process. ">MachOImageReader</a> object. </dd></dl>
<p>Reads the Mach-O image file’s load commands from another process. </p>
<p>This method must only be called once on an object. This method must be called successfully before any other method in this class may be called.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">process_reader</td><td>The reader for the remote process. </td></tr>
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">address</td><td>The address, in the remote process’ address space, where the <code>mach_header</code> or <code>mach_header_64</code> at the beginning of the image to be read is located. This address can be determined by reading the remote process’dyld information (see snapshot/mac/process_types/dyld_images.proctype). </td></tr>
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">name</td><td>The module’s name, a string to be used in logged messages. This string is for diagnostic purposes and to relax otherwise strict parsing rules for common modules with known defects.</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd><code>true</code> if the image was read successfully, including all load commands. <code>false</code> otherwise, with an appropriate message logged. </dd></dl>
<p>Looks up a symbol in the image’s symbol table. </p>
<p>This method is capable of locating external defined symbols. Specifically, this method can look up symbols that have these charcteristics:</p><ul>
<li><code>N_STAB</code> (debugging) and <code>N_PEXT</code> (private external) must not be set.</li>
<li><code>N_EXT</code> (external) must be set.</li>
<li>The type must be <code>N_ABS</code> (absolute) or <code>N_SECT</code> (defined in section).</li>
</ul>
<p><code>N_INDR</code> (indirect), <code>N_UNDF</code> (undefined), and <code>N_PBUD</code> (prebound undefined) symbols cannot be located through this mechanism.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramdir">[in]</td><tdclass="paramname">name</td><td>The name of the symbol to look up, “mangled” or “decorated” appropriately. For example, use <code>"_main"</code> to look up the symbol for the C <code>main()</code> function, and use <code>"__Z4Funcv"</code> to look up the symbol for the C++ <code>Func()</code> function. Contrary to <code>dlsym()</code>, the leading underscore must not be stripped when using this interface. </td></tr>
<tr><tdclass="paramdir">[out]</td><tdclass="paramname">value</td><td>If the lookup was successful, this will be set to the value of the symbol, adjusted for any “slide”as needed. The value can be used as an address in the remote process’ address space where the pointee of the symbol exists in memory.</td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd><code>true</code> if the symbol lookup was successful and the symbol was found. <code>false</code> otherwise, including error conditions (for which a warning message will be logged), modules without symbol tables, and symbol names not found in the symbol table.</dd></dl>
<dlclass="section note"><dt>Note</dt><dd>Symbol values returned via this interface are adjusted for “slide” as appropriate, in contrast to the underlying implementation, <aclass="el"href="classcrashpad_1_1MachOImageSymbolTableReader.html#ac85da22c3a7915bb5869a77765c9ffbc"title="Looks up a symbol in the image’s symbol table. ">MachOImageSymbolTableReader::LookUpExternalDefinedSymbol()</a>.</dd></dl>
<dlclass="section warning"><dt>Warning</dt><dd>Symbols that are resolved by running symbol resolvers (<code>.symbol_resolver</code>) are not properly handled by this interface. The address of the symbol resolver is returned because that’s what shows up in the symbol table, rather than the effective address of the resolved symbol as used by dyld after running the resolver. The only way to detect this situation would be to read the <code>LC_DYLD_INFO</code> or <code>LC_DYLD_INFO_ONLY</code> load command if present and looking for the <code>EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER</code> flag, but that would just be able to detect symbols with a resolver, it would not be able to resolve them from out-of-process, so it’s not currently done. </dd></dl>
<p>Returns the mapped size of the Mach-O image’s <code>__TEXT</code> segment. </p>
<p>Note that this is returns only the size of the <code>__TEXT</code> segment, not of any other segment. This is because the interface only allows one load address and size to be reported, but Mach-O image files may consist of multiple discontiguous segments. By convention, the <code>__TEXT</code> segment is always mapped at the beginning of a Mach-O image file, and it is the most useful for the expected intended purpose of collecting data to obtain stack backtraces. The implementation insists during initialization that the <code>__TEXT</code> segment be mapped at the beginning of the file.</p>
<p>In practice, discontiguous segments are only found for images that have loaded out of the dyld shared cache, but the <code>__TEXT</code> segment’s size is returned for modules that loaded with contiguous segments as well for consistency. </p>
<p>Returns the Mach-O image’s “slide,” the difference between its actual load address and its preferred load address. </p>
<p>“Slide” is computed by subtracting the <code>__TEXT</code> segment’s preferred load address from its actual load address. It will be reported as a positive offset when the actual load address is greater than the preferred load address. The preferred load address is taken to be the segment’s reported <code>vmaddr</code> value. </p>
<p>This information comes from a Mach-O image’s <code>LC_SOURCE_VERSION</code> load command. For Mach-O images without this load command, <code>0</code> will be returned. </p>
<p>This information comes from a Mach-O image’s <code>LC_UUID</code> load command. For Mach-O images without this load command, a zeroed-out <aclass="el"href="structcrashpad_1_1UUID.html"title="A universally unique identifier (UUID). ">UUID</a> value will be returned. </p>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>snapshot/mac/mach_o_image_reader.h</li>
<li>snapshot/mac/mach_o_image_reader.cc</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hrclass="footer"/><addressclass="footer"><small>
Generated by  <ahref="http://www.doxygen.org/index.html">