1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- Copyright (C) 1988-2021 Free Software Foundation, Inc.
4
5Permission is granted to copy, distribute and/or modify this document
6under the terms of the GNU Free Documentation License, Version 1.3 or
7any later version published by the Free Software Foundation; with the
8Invariant Sections being "Free Software" and "Free Software Needs
9Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
10and with the Back-Cover Texts as in (a) below.
11
12(a) The FSF's Back-Cover Text is: "You are free to copy and modify
13this GNU Manual.  Buying copies from GNU Press supports the FSF in
14developing GNU and promoting software freedom." -->
15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
16<head>
17<title>Debugging with GDB: Rust</title>
18
19<meta name="description" content="Debugging with GDB: Rust">
20<meta name="keywords" content="Debugging with GDB: Rust">
21<meta name="resource-type" content="document">
22<meta name="distribution" content="global">
23<meta name="Generator" content="makeinfo">
24<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
25<link href="index.html#Top" rel="start" title="Top">
26<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
28<link href="Supported-Languages.html#Supported-Languages" rel="up" title="Supported Languages">
29<link href="Modula_002d2.html#Modula_002d2" rel="next" title="Modula-2">
30<link href="Pascal.html#Pascal" rel="previous" title="Pascal">
31<style type="text/css">
32<!--
33a.summary-letter {text-decoration: none}
34blockquote.smallquotation {font-size: smaller}
35div.display {margin-left: 3.2em}
36div.example {margin-left: 3.2em}
37div.indentedblock {margin-left: 3.2em}
38div.lisp {margin-left: 3.2em}
39div.smalldisplay {margin-left: 3.2em}
40div.smallexample {margin-left: 3.2em}
41div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
42div.smalllisp {margin-left: 3.2em}
43kbd {font-style:oblique}
44pre.display {font-family: inherit}
45pre.format {font-family: inherit}
46pre.menu-comment {font-family: serif}
47pre.menu-preformatted {font-family: serif}
48pre.smalldisplay {font-family: inherit; font-size: smaller}
49pre.smallexample {font-size: smaller}
50pre.smallformat {font-family: inherit; font-size: smaller}
51pre.smalllisp {font-size: smaller}
52span.nocodebreak {white-space:nowrap}
53span.nolinebreak {white-space:nowrap}
54span.roman {font-family:serif; font-weight:normal}
55span.sansserif {font-family:sans-serif; font-weight:normal}
56ul.no-bullet {list-style: none}
57-->
58</style>
59
60
61</head>
62
63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
64<a name="Rust"></a>
65<div class="header">
66<p>
67Next: <a href="Modula_002d2.html#Modula_002d2" accesskey="n" rel="next">Modula-2</a>, Previous: <a href="Pascal.html#Pascal" accesskey="p" rel="previous">Pascal</a>, Up: <a href="Supported-Languages.html#Supported-Languages" accesskey="u" rel="up">Supported Languages</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
68</div>
69<hr>
70<a name="Rust-1"></a>
71<h4 class="subsection">15.4.8 Rust</h4>
72
73<p><small>GDB</small> supports the <a href="https://www.rust-lang.org/">Rust
74Programming Language</a>.  Type- and value-printing, and expression
75parsing, are reasonably complete.  However, there are a few
76peculiarities and holes to be aware of.
77</p>
78<ul>
79<li> Linespecs (see <a href="Specify-Location.html#Specify-Location">Specify Location</a>) are never relative to the current
80crate.  Instead, they act as if there were a global namespace of
81crates, somewhat similar to the way <code>extern crate</code> behaves.
82
83<p>That is, if <small>GDB</small> is stopped at a breakpoint in a function in
84crate &lsquo;<samp>A</samp>&rsquo;, module &lsquo;<samp>B</samp>&rsquo;, then <code>break B::f</code> will attempt
85to set a breakpoint in a function named &lsquo;<samp>f</samp>&rsquo; in a crate named
86&lsquo;<samp>B</samp>&rsquo;.
87</p>
88<p>As a consequence of this approach, linespecs also cannot refer to
89items using &lsquo;<samp>self::</samp>&rsquo; or &lsquo;<samp>super::</samp>&rsquo;.
90</p>
91</li><li> Because <small>GDB</small> implements Rust name-lookup semantics in
92expressions, it will sometimes prepend the current crate to a name.
93For example, if <small>GDB</small> is stopped at a breakpoint in the crate
94&lsquo;<samp>K</samp>&rsquo;, then <code>print ::x::y</code> will try to find the symbol
95&lsquo;<samp>K::x::y</samp>&rsquo;.
96
97<p>However, since it is useful to be able to refer to other crates when
98debugging, <small>GDB</small> provides the <code>extern</code> extension to
99circumvent this.  To use the extension, just put <code>extern</code> before
100a path expression to refer to the otherwise unavailable &ldquo;global&rdquo;
101scope.
102</p>
103<p>In the above example, if you wanted to refer to the symbol &lsquo;<samp>y</samp>&rsquo; in
104the crate &lsquo;<samp>x</samp>&rsquo;, you would use <code>print extern x::y</code>.
105</p>
106</li><li> The Rust expression evaluator does not support &ldquo;statement-like&rdquo;
107expressions such as <code>if</code> or <code>match</code>, or lambda expressions.
108
109</li><li> Tuple expressions are not implemented.
110
111</li><li> The Rust expression evaluator does not currently implement the
112<code>Drop</code> trait.  Objects that may be created by the evaluator will
113never be destroyed.
114
115</li><li> <small>GDB</small> does not implement type inference for generics.  In order
116to call generic functions or otherwise refer to generic items, you
117will have to specify the type parameters manually.
118
119</li><li> <small>GDB</small> currently uses the C<tt>++</tt> demangler for Rust.  In most
120cases this does not cause any problems.  However, in an expression
121context, completing a generic function name will give syntactically
122invalid results.  This happens because Rust requires the &lsquo;<samp>::</samp>&rsquo;
123operator between the function name and its generic arguments.  For
124example, <small>GDB</small> might provide a completion like
125<code>crate::f&lt;u32&gt;</code>, where the parser would require
126<code>crate::f::&lt;u32&gt;</code>.
127
128</li><li> As of this writing, the Rust compiler (version 1.8) has a few holes in
129the debugging information it generates.  These holes prevent certain
130features from being implemented by <small>GDB</small>:
131<ul>
132<li> Method calls cannot be made via traits.
133
134</li><li> Operator overloading is not implemented.
135
136</li><li> When debugging in a monomorphized function, you cannot use the generic
137type names.
138
139</li><li> The type <code>Self</code> is not available.
140
141</li><li> <code>use</code> statements are not available, so some names may not be
142available in the crate.
143</li></ul>
144</li></ul>
145
146<hr>
147<div class="header">
148<p>
149Next: <a href="Modula_002d2.html#Modula_002d2" accesskey="n" rel="next">Modula-2</a>, Previous: <a href="Pascal.html#Pascal" accesskey="p" rel="previous">Pascal</a>, Up: <a href="Supported-Languages.html#Supported-Languages" accesskey="u" rel="up">Supported Languages</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
150</div>
151
152
153
154</body>
155</html>
156