| <html lang="en"> |
| <head> |
| <title>Rust - Debugging with GDB</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="Debugging with GDB"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Supported-Languages.html#Supported-Languages" title="Supported Languages"> |
| <link rel="prev" href="Pascal.html#Pascal" title="Pascal"> |
| <link rel="next" href="Modula_002d2.html#Modula_002d2" title="Modula-2"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <!-- |
| Copyright (C) 1988-2019 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with the |
| Invariant Sections being ``Free Software'' and ``Free Software Needs |
| Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,'' |
| and with the Back-Cover Texts as in (a) below. |
| |
| (a) The FSF's Back-Cover Text is: ``You are free to copy and modify |
| this GNU Manual. Buying copies from GNU Press supports the FSF in |
| developing GNU and promoting software freedom.'' |
| --> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="Rust"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="Modula_002d2.html#Modula_002d2">Modula-2</a>, |
| Previous: <a rel="previous" accesskey="p" href="Pascal.html#Pascal">Pascal</a>, |
| Up: <a rel="up" accesskey="u" href="Supported-Languages.html#Supported-Languages">Supported Languages</a> |
| <hr> |
| </div> |
| |
| <h4 class="subsection">15.4.8 Rust</h4> |
| |
| <p><span class="sc">gdb</span> supports the <a href="https://www.rust-lang.org/">Rust Programming Language</a>. Type- and value-printing, and expression |
| parsing, are reasonably complete. However, there are a few |
| peculiarities and holes to be aware of. |
| |
| <ul> |
| <li>Linespecs (see <a href="Specify-Location.html#Specify-Location">Specify Location</a>) are never relative to the current |
| crate. Instead, they act as if there were a global namespace of |
| crates, somewhat similar to the way <code>extern crate</code> behaves. |
| |
| <p>That is, if <span class="sc">gdb</span> is stopped at a breakpoint in a function in |
| crate ‘<samp><span class="samp">A</span></samp>’, module ‘<samp><span class="samp">B</span></samp>’, then <code>break B::f</code> will attempt |
| to set a breakpoint in a function named ‘<samp><span class="samp">f</span></samp>’ in a crate named |
| ‘<samp><span class="samp">B</span></samp>’. |
| |
| <p>As a consequence of this approach, linespecs also cannot refer to |
| items using ‘<samp><span class="samp">self::</span></samp>’ or ‘<samp><span class="samp">super::</span></samp>’. |
| |
| <li>Because <span class="sc">gdb</span> implements Rust name-lookup semantics in |
| expressions, it will sometimes prepend the current crate to a name. |
| For example, if <span class="sc">gdb</span> is stopped at a breakpoint in the crate |
| ‘<samp><span class="samp">K</span></samp>’, then <code>print ::x::y</code> will try to find the symbol |
| ‘<samp><span class="samp">K::x::y</span></samp>’. |
| |
| <p>However, since it is useful to be able to refer to other crates when |
| debugging, <span class="sc">gdb</span> provides the <code>extern</code> extension to |
| circumvent this. To use the extension, just put <code>extern</code> before |
| a path expression to refer to the otherwise unavailable “global” |
| scope. |
| |
| <p>In the above example, if you wanted to refer to the symbol ‘<samp><span class="samp">y</span></samp>’ in |
| the crate ‘<samp><span class="samp">x</span></samp>’, you would use <code>print extern x::y</code>. |
| |
| <li>The Rust expression evaluator does not support “statement-like” |
| expressions such as <code>if</code> or <code>match</code>, or lambda expressions. |
| |
| <li>Tuple expressions are not implemented. |
| |
| <li>The Rust expression evaluator does not currently implement the |
| <code>Drop</code> trait. Objects that may be created by the evaluator will |
| never be destroyed. |
| |
| <li><span class="sc">gdb</span> does not implement type inference for generics. In order |
| to call generic functions or otherwise refer to generic items, you |
| will have to specify the type parameters manually. |
| |
| <li><span class="sc">gdb</span> currently uses the C<tt>++</tt> demangler for Rust. In most |
| cases this does not cause any problems. However, in an expression |
| context, completing a generic function name will give syntactically |
| invalid results. This happens because Rust requires the ‘<samp><span class="samp">::</span></samp>’ |
| operator between the function name and its generic arguments. For |
| example, <span class="sc">gdb</span> might provide a completion like |
| <code>crate::f<u32></code>, where the parser would require |
| <code>crate::f::<u32></code>. |
| |
| <li>As of this writing, the Rust compiler (version 1.8) has a few holes in |
| the debugging information it generates. These holes prevent certain |
| features from being implemented by <span class="sc">gdb</span>: |
| <ul> |
| <li>Method calls cannot be made via traits. |
| |
| <li>Operator overloading is not implemented. |
| |
| <li>When debugging in a monomorphized function, you cannot use the generic |
| type names. |
| |
| <li>The type <code>Self</code> is not available. |
| |
| <li><code>use</code> statements are not available, so some names may not be |
| available in the crate. |
| </ul> |
| </ul> |
| |
| </body></html> |
| |