mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-14 12:08:24 +00:00
95 lines
18 KiB
HTML
95 lines
18 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Debug symbols - `DebugInfoBuilder` interface"><title>inkwell::debug_info - Rust</title><script> if (window.location.protocol !== "file:") document.write(`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2">`)</script><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-e935ef01ae1c1829.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="inkwell" data-themes="" data-resource-suffix="" data-rustdoc-version="1.78.0 (9b00956e5 2024-04-29)" data-channel="1.78.0" data-search-js="search-42d8da7a6b9792c2.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../static.files/storage-4c98445ec4002617.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-12cf3b4f4f9dc36d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-04d5337699b92874.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../inkwell/index.html">inkwell</a><span class="version">0.4.0</span></h2></div><h2 class="location"><a href="#">Module debug_info</a></h2><div class="sidebar-elems"><section><ul class="block"><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li><li><a href="#types">Type Aliases</a></li></ul></section><h2><a href="../index.html">In crate inkwell</a></h2></div></nav><div class="sidebar-resizer"></div>
|
||
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../../inkwell/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Module <a href="../index.html">inkwell</a>::<wbr><a class="mod" href="#">debug_info</a><button id="copy-path" title="Copy item path to clipboard"><img src="../../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../../src/inkwell/debug_info.rs.html#1-1606">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Debug symbols - <code>DebugInfoBuilder</code> interface</p>
|
||
<h2 id="example-usage"><a class="doc-anchor" href="#example-usage">§</a>Example usage</h2><h3 id="setting-up-the-module-for-holding-debug-info"><a class="doc-anchor" href="#setting-up-the-module-for-holding-debug-info">§</a>Setting up the module for holding debug info:</h3>
|
||
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">let </span>context = Context::create();
|
||
<span class="kw">let </span>module = context.create_module(<span class="string">"bin"</span>);
|
||
|
||
<span class="kw">let </span>debug_metadata_version = context.i32_type().const_int(<span class="number">3</span>, <span class="bool-val">false</span>);
|
||
module.add_basic_value_flag(
|
||
<span class="string">"Debug Info Version"</span>,
|
||
inkwell::module::FlagBehavior::Warning,
|
||
debug_metadata_version,
|
||
);
|
||
<span class="kw">let </span>builder = context.create_builder();
|
||
<span class="kw">let </span>(dibuilder, compile_unit) = module.create_debug_info_builder(
|
||
<span class="bool-val">true</span>,
|
||
<span class="comment">/* language */ </span>inkwell::debug_info::DWARFSourceLanguage::C,
|
||
<span class="comment">/* filename */ </span><span class="string">"source_file"</span>,
|
||
<span class="comment">/* directory */ </span><span class="string">"."</span>,
|
||
<span class="comment">/* producer */ </span><span class="string">"my llvm compiler frontend"</span>,
|
||
<span class="comment">/* is_optimized */ </span><span class="bool-val">false</span>,
|
||
<span class="comment">/* compiler command line flags */ </span><span class="string">""</span>,
|
||
<span class="comment">/* runtime_ver */ </span><span class="number">0</span>,
|
||
<span class="comment">/* split_name */ </span><span class="string">""</span>,
|
||
<span class="comment">/* kind */ </span>inkwell::debug_info::DWARFEmissionKind::Full,
|
||
<span class="comment">/* dwo_id */ </span><span class="number">0</span>,
|
||
<span class="comment">/* split_debug_inling */ </span><span class="bool-val">false</span>,
|
||
<span class="comment">/* debug_info_for_profiling */ </span><span class="bool-val">false</span>,
|
||
);</code></pre></div>
|
||
<h3 id="creating-function-debug-info"><a class="doc-anchor" href="#creating-function-debug-info">§</a>Creating function debug info</h3>
|
||
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested">ⓘ</a><pre class="rust rust-example-rendered"><code> <span class="kw">let </span>ditype = dibuilder.create_basic_type(
|
||
<span class="string">"type_name"</span>,
|
||
<span class="number">0_u64</span>,
|
||
<span class="number">0x00</span>,
|
||
inkwell::debug_info::DIFlags::Public,
|
||
).unwrap();
|
||
<span class="kw">let </span>subroutine_type = dibuilder.create_subroutine_type(
|
||
compile_unit.get_file(),
|
||
<span class="comment">/* return type */ </span><span class="prelude-val">Some</span>(ditype.as_type()),
|
||
<span class="comment">/* parameter types */ </span><span class="kw-2">&</span>[],
|
||
inkwell::debug_info::DIFlags::Public,
|
||
);
|
||
<span class="kw">let </span>func_scope: DISubprogram<<span class="lifetime">'_</span>> = dibuilder.create_function(
|
||
<span class="comment">/* scope */ </span>compile_unit.as_debug_info_scope(),
|
||
<span class="comment">/* func name */ </span><span class="string">"main"</span>,
|
||
<span class="comment">/* linkage_name */ </span><span class="prelude-val">None</span>,
|
||
<span class="comment">/* file */ </span>compile_unit.get_file(),
|
||
<span class="comment">/* line_no */ </span><span class="number">0</span>,
|
||
<span class="comment">/* DIType */ </span>subroutine_type,
|
||
<span class="comment">/* is_local_to_unit */ </span><span class="bool-val">true</span>,
|
||
<span class="comment">/* is_definition */ </span><span class="bool-val">true</span>,
|
||
<span class="comment">/* scope_line */ </span><span class="number">0</span>,
|
||
<span class="comment">/* flags */ </span>inkwell::debug_info::DIFlags::Public,
|
||
<span class="comment">/* is_optimized */ </span><span class="bool-val">false</span>,
|
||
);</code></pre></div>
|
||
<p>The <code>DISubprogram</code> value must be attached to the generated <code>FunctionValue</code>:</p>
|
||
|
||
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="comment">/* after creating function: */
|
||
</span><span class="kw">let </span>fn_val = module.add_function(fn_name_str, fn_type, <span class="prelude-val">None</span>);
|
||
fn_val.set_subprogram(func_scope);</code></pre></div>
|
||
<h3 id="setting-debug-locations"><a class="doc-anchor" href="#setting-debug-locations">§</a>Setting debug locations</h3>
|
||
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">let </span>lexical_block = dibuilder.create_lexical_block(
|
||
<span class="comment">/* scope */ </span>func_scope.as_debug_info_scope(),
|
||
<span class="comment">/* file */ </span>compile_unit.get_file(),
|
||
<span class="comment">/* line_no */ </span><span class="number">0</span>,
|
||
<span class="comment">/* column_no */ </span><span class="number">0</span>);
|
||
|
||
<span class="kw">let </span>loc = dibuilder
|
||
.create_debug_location(<span class="kw-2">&</span>context, <span class="comment">/* line */ </span><span class="number">0</span>, <span class="comment">/* column */ </span><span class="number">0</span>,
|
||
<span class="comment">/* current_scope */ </span>lexical_block.as_debug_info_scope(),
|
||
<span class="comment">/* inlined_at */ </span><span class="prelude-val">None</span>);
|
||
builder.set_current_debug_location(<span class="kw-2">&</span>context, loc);
|
||
|
||
<span class="comment">// Create global variable
|
||
</span><span class="kw">let </span>gv = module.add_global(context.i64_type(), <span class="prelude-val">Some</span>(inkwell::AddressSpace::Global), <span class="string">"gv"</span>);
|
||
|
||
|
||
<span class="kw">let </span>const_v = di.create_constant_expression(<span class="number">10</span>);
|
||
|
||
<span class="kw">let </span>gv_debug = di.create_global_variable_expression(cu.get_file().as_debug_info_scope(), <span class="string">"gv"</span>, <span class="string">""</span>, cu.get_file(), <span class="number">1</span>, ditype.as_type(), <span class="bool-val">true</span>, <span class="prelude-val">Some</span>(const_v), <span class="prelude-val">None</span>, <span class="number">8</span>);
|
||
|
||
<span class="kw">let </span>meta_value: inkwell::values::BasicMetadataValueEnum = gv_debug.as_metadata_value(<span class="kw-2">&</span>context).into();
|
||
<span class="kw">let </span>metadata = context.metadata_node(<span class="kw-2">&</span>[meta_value]);
|
||
gv.set_metadata(metadata, <span class="number">0</span>);<span class="comment">//dbg
|
||
</span></code></pre></div>
|
||
<h3 id="finalize-debug-info"><a class="doc-anchor" href="#finalize-debug-info">§</a>Finalize debug info</h3>
|
||
<p>Before any kind of code generation (including verification passes; they generate code and
|
||
validate debug info), do:</p>
|
||
|
||
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested">ⓘ</a><pre class="rust rust-example-rendered"><code>dibuilder.finalize();</code></pre></div>
|
||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.DIBasicType.html" title="struct inkwell::debug_info::DIBasicType">DIBasicType</a></div><div class="desc docblock-short">A primitive debug info type created by <code>create_basic_type</code> method of <code>DebugInfoBuilder</code></div></li><li><div class="item-name"><a class="struct" href="struct.DICompileUnit.html" title="struct inkwell::debug_info::DICompileUnit">DICompileUnit</a></div><div class="desc docblock-short">Compilation unit scope for debug info</div></li><li><div class="item-name"><a class="struct" href="struct.DICompositeType.html" title="struct inkwell::debug_info::DICompositeType">DICompositeType</a></div><div class="desc docblock-short">A wrapper around an array of types, such as a union or struct.</div></li><li><div class="item-name"><a class="struct" href="struct.DIDerivedType.html" title="struct inkwell::debug_info::DIDerivedType">DIDerivedType</a></div><div class="desc docblock-short">A wrapper around a single type, such as a typedef or member type.</div></li><li><div class="item-name"><a class="struct" href="struct.DIExpression.html" title="struct inkwell::debug_info::DIExpression">DIExpression</a></div><div class="desc docblock-short">https://llvm.org/docs/LangRef.html#diexpression</div></li><li><div class="item-name"><a class="struct" href="struct.DIFile.html" title="struct inkwell::debug_info::DIFile">DIFile</a></div><div class="desc docblock-short">Source file scope for debug info</div></li><li><div class="item-name"><a class="struct" href="struct.DIGlobalVariableExpression.html" title="struct inkwell::debug_info::DIGlobalVariableExpression">DIGlobalVariableExpression</a></div></li><li><div class="item-name"><a class="struct" href="struct.DILexicalBlock.html" title="struct inkwell::debug_info::DILexicalBlock">DILexicalBlock</a></div><div class="desc docblock-short">Lexical block scope for debug info</div></li><li><div class="item-name"><a class="struct" href="struct.DILocalVariable.html" title="struct inkwell::debug_info::DILocalVariable">DILocalVariable</a></div><div class="desc docblock-short">Metadata representing a variable inside a scope</div></li><li><div class="item-name"><a class="struct" href="struct.DILocation.html" title="struct inkwell::debug_info::DILocation">DILocation</a></div><div class="desc docblock-short">A debug location within the source code. Contains the following information:</div></li><li><div class="item-name"><a class="struct" href="struct.DINamespace.html" title="struct inkwell::debug_info::DINamespace">DINamespace</a></div><div class="desc docblock-short">Namespace scope for debug info</div></li><li><div class="item-name"><a class="struct" href="struct.DIScope.html" title="struct inkwell::debug_info::DIScope">DIScope</a></div><div class="desc docblock-short">Any kind of debug information scope (i.e. visibility of a source code symbol). Scopes are
|
||
created by special <code>DebugInfoBuilder</code> methods (eg <code>create_lexical_block</code>) and can be turned
|
||
into a <code>DIScope</code> with the <code>AsDIScope::as_debug_info_scope</code> trait method.</div></li><li><div class="item-name"><a class="struct" href="struct.DISubprogram.html" title="struct inkwell::debug_info::DISubprogram">DISubprogram</a></div><div class="desc docblock-short">Function body scope for debug info</div></li><li><div class="item-name"><a class="struct" href="struct.DISubroutineType.html" title="struct inkwell::debug_info::DISubroutineType">DISubroutineType</a></div><div class="desc docblock-short">Metadata representing the type of a function</div></li><li><div class="item-name"><a class="struct" href="struct.DIType.html" title="struct inkwell::debug_info::DIType">DIType</a></div><div class="desc docblock-short">Any kind of debug info type</div></li><li><div class="item-name"><a class="struct" href="struct.DebugInfoBuilder.html" title="struct inkwell::debug_info::DebugInfoBuilder">DebugInfoBuilder</a></div><div class="desc docblock-short">A builder object to create debug info metadata. Used along with <code>Builder</code> while producing
|
||
IR. Created by <code>Module::create_debug_info_builder</code>. See <code>debug_info</code> module level
|
||
documentation for more.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.DWARFEmissionKind.html" title="enum inkwell::debug_info::DWARFEmissionKind">DWARFEmissionKind</a></div><div class="desc docblock-short">The amount of debug information to emit. Corresponds to <code>LLVMDWARFEmissionKind</code> enum from LLVM.</div></li><li><div class="item-name"><a class="enum" href="enum.DWARFSourceLanguage.html" title="enum inkwell::debug_info::DWARFSourceLanguage">DWARFSourceLanguage</a></div><div class="desc docblock-short">Source languages known by DWARF. Corresponds to <code>LLVMDWARFSourceLanguage</code> enum from LLVM.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.AsDIScope.html" title="trait inkwell::debug_info::AsDIScope">AsDIScope</a></div><div class="desc docblock-short">Specific scopes (i.e. <code>DILexicalBlock</code>) can be turned into a <code>DIScope</code> with the
|
||
<code>AsDIScope::as_debug_info_scope</code> trait method.</div></li><li><div class="item-name"><a class="trait" href="trait.DIFlagsConstants.html" title="trait inkwell::debug_info::DIFlagsConstants">DIFlagsConstants</a></div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.debug_metadata_version.html" title="fn inkwell::debug_info::debug_metadata_version">debug_metadata_version</a></div><div class="desc docblock-short">Gets the version of debug metadata produced by the current LLVM version.</div></li></ul><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="type" href="type.DIFlags.html" title="type inkwell::debug_info::DIFlags">DIFlags</a></div></li><li><div class="item-name"><a class="type" href="type.LLVMDWARFTypeEncoding.html" title="type inkwell::debug_info::LLVMDWARFTypeEncoding">LLVMDWARFTypeEncoding</a></div></li></ul></section></div></main></body></html> |