/
index.html
332 lines (230 loc) · 10.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
<!DOCTYPE html>
<html>
<head>
<title>Debugger - Rubinius</title>
<meta content='text/html;charset=utf-8' http-equiv='content-type'>
<meta content='de' http-equiv='content-language'>
<meta content='Rubinius is an implementation of the Ruby programming language. The Rubinius bytecode virtual machine is written in C++. The bytecode compiler is written in pure Ruby. The vast majority of the core library is also written in Ruby, with some supporting primitives that interact with the VM directly.' name='description'>
<meta content='Less Than Three. <3. http://less.thanthree.com' name='author'>
<link href='/' rel='home'>
<link href='/' rel='start'>
<link href='/doc/de/tools' rel='prev' title='Tools'>
<link href='/doc/de/tools/profiler' rel='next' title='Profiler'>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script><![endif]-->
<script src="/javascripts/jquery-1.3.2.js" type="text/javascript"></script>
<script src="/javascripts/paging_keys.js" type="text/javascript"></script>
<script src="/javascripts/application.js" type="text/javascript"></script>
<style>article, aside, dialog, figure, footer, header, hgroup, menu, nav, section { display: block; }</style>
<link href="/stylesheets/blueprint/screen.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/blueprint/print.css" media="print" rel="stylesheet" type="text/css" />
<!--[if IE]><link href="/stylesheets/blueprint/ie.css" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
<!--[if IE]><link href="/stylesheets/ie.css" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
<link href="/stylesheets/pygments.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<div class='container'>
<div class='span-21 doc_menu'>
<header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a id="blog" href="/blog/">Blog</a></li>
<li><a id="documentation" href="/doc/en/">Documentation</a></li>
<li><a href="/projects/">Projects</a></li>
<li><a href="/roadmap/">Roadmap</a></li>
<li><a href="/releases/">Releases</a></li>
</ul>
</nav>
</header>
</div>
<div class='span-3 last'>
<div id='version'>
<a href="/releases/1.2.3">1.2.3</a>
</div>
</div>
</div>
<div class="container languages">
<nav>
<span class="label">Sprachen:</span>
<ul>
<li><a href="/doc/de/tools/debugger/"
class="current"
>de</a></li>
<li><a href="/doc/en/tools/debugger/"
>en</a></li>
<li><a href="/doc/es/tools/debugger/"
>es</a></li>
<li><a href="/doc/fr/tools/debugger/"
>fr</a></li>
<li><a href="/doc/ja/tools/debugger/"
>ja</a></li>
<li><a href="/doc/pl/tools/debugger/"
>pl</a></li>
<li><a href="/doc/pt-br/tools/debugger/"
>pt-br</a></li>
<li><a href="/doc/ru/tools/debugger/"
>ru</a></li>
</ul>
</nav>
</div>
<div class="container doc_page_nav">
<span class="label">Vorherige:</span>
<a href="/doc/de/tools">Tools</a>
<span class="label">Aufwärts:</span>
<a href="/doc/de/">Inhaltsverzeichnis</a>
<span class="label">Nächste:</span>
<a href="/doc/de/tools/profiler">Profiler</a>
</div>
<div class="container documentation">
<h2>Debugger</h2>
<p>Rubinius kommt mit einer eingebauten Ruby Debugger-API auf Quell-Ebene.</p>
<h2 id="aus-aktivem-code-heraus-starten">Aus aktivem Code heraus starten</h2>
<p>Der Rubinius Debugger kann direkt aus aktivem Code heraus mit Hilfe eines
eingebauten Aufrufs gestartet werden.</p>
<p>Angenommen folgender Code befindet sich in app.rb:</p>
<pre><code>class Toaster
attr_accessor :einstellung
def initialize
require 'rubinius/debugger'
Rubinius::Debugger.start
@einstellung = :braun
end
end
p Toaster.new.einstellung
</code></pre>
<p>Bei Ausführung des Codes in Rubinius käme folgende Ausgabe:</p>
<pre><code>$ rbx app.rb
| Breakpoint: Toaster#initialize at app.rb:5 (15)
| 5: Rubinius::Debugger.start
debug> help
help: Show information about debugger commands
b, break, brk: Set a breakpoint at a point in a method
tb, tbreak, tbrk: Set a temporary breakpoint
d, delete: Delete a breakpoint
n, next: Move to the next line or conditional branch
s, step: Step into next method call or to next line
ni, nexti: Move to the next bytecode instruction
f, frame: Make a specific frame in the call stack the current frame
c, cont, continue: Continue running the target thread
bt, backtrace: Show the current call stack
p, eval: Run code in the current context
dis, disassemble: Show the bytecode for the current method
i, info: Show information about things
set: Set a debugger config variable
show: Display the value of a variable or variables
debug> bt
| Backtrace:
| 0 Toaster#initialize at app.rb:5 (15)
| 1 main.__script__ at app.rb:11 (46)
| 2 Rubinius::CodeLoader#load_script(debug) at kernel/delta/codeloader.rb:67 (44)
| 3 Rubinius::CodeLoader.load_script(name) at kernel/delta/codeloader.rb:91 (40)
| 4 Rubinius::Loader#script at kernel/loader.rb:460 (79)
| 5 Rubinius::Loader#main at kernel/loader.rb:571 (64)
| 6 Rubinius::Loader.main at kernel/loader.rb:609 (33)
| 7 Object#__script__ at kernel/loader.rb:621 (60)
debug> n
| Breakpoint: Toaster#initialize at app.rb:6 (16)
| 6: @einstellung = :braun
debug> n
| Breakpoint: Toaster#initialize at app.rb:7 (21)
| 7: @art = :roggen
debug> p @einstellung = :hellbraun
$d0 = :hellbraun
debug> c
:hellbraun
</code></pre>
<p>Wie angegeben, bekommt man bei der Eingabe von <code>help</code> im Debugger eine
englischsprachige Hilfsanzeige für die verfügbaren Befehle.</p>
<h2 id="starten-von-der-kommandozeile">Starten von der Kommandozeile</h2>
<p>Der Rubinius Debugger kann ebenfalls aus der Kommandozeile heraus gestartet
werden und zeigt das Debugger Prompt an, noch bevor das dazu angegebene Skript
geladen wird.</p>
<p>Angenommen folgender Code befindet sich in app.rb:</p>
<pre><code>def problem_code
puts "Ich habe ein Problem"
a = 1 + 2
puts "ein Mathe-Problem" unless a == 4
end
problem_code
</code></pre>
<p>Um diesen Code zu debuggen, kann der Debugger von der Kommandozeile aus mit der
<code>-Xdebug</code> option gestartet werden:</p>
<pre><code>$ rbx -Xdebug bug.rb
| Breakpoint: Rubinius::Loader#debugger at kernel/loader.rb:424 (34)
| 424: Rubinius::Debugger.start
debug> b Object#problem_code:2
* Unable to find method 'problem_code' in Object
| Would you like to defer this breakpoint to later? [y/n] y
| Defered breakpoint created.
debug> c
| Resolved breakpoint for Object#problem_code
| Set breakpoint 2: bug.rb:2 (+0)
| Breakpoint: Object#problem_code at bug.rb:2 (0)
| 2: puts "Ich habe ein Problem"
debug> n
I habe ein Problem
| Breakpoint: Object#problem_code at bug.rb:3 (9)
| 3: a = 1 + 2
debug> n
| Breakpoint: Object#problem_code at bug.rb:4 (16)
| 4: puts "ein Mathe-Problem" unless a == 4
debug> p a = 4
$d0 = 4
debug> n
| Breakpoint: main.__script__ at bug.rb:7 (17)
| 7: problem_code
debug> c
</code></pre>
<p>Wie man sieht, bei der Ausführung von <code>p a = 4</code> im Debugger wird der Wert der
lokalen Variable <code>a</code> geändert und beeinflusst damit auch die weitere Ausführung
des Ruby-Codes.</p>
</div>
<div class="container doc_page_nav">
<span class="label">Vorherige:</span>
<a href="/doc/de/tools">Tools</a>
<span class="label">Aufwärts:</span>
<a href="/doc/de/">Inhaltsverzeichnis</a>
<span class="label">Nächste:</span>
<a href="/doc/de/tools/profiler">Profiler</a>
</div>
<div class="container">
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = 'rubinius';
var disqus_identifier = '/doc/de/tools/debugger/';
var disqus_url = 'http://rubini.us/doc/de/tools/debugger/';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
<footer>
<div class='container'>
<nav>
<ul>
<li><a href="http://twitter.com/rubinius">Follow Rubinius on Twitter</a></li>
<li><a href="http://github.com/evanphx/rubinius">Fork Rubinius on github</a></li>
<li><a href="http://engineyard.com">An Engine Yard project</a></li>
<li id='credit'>
Site design by
<a href="http://less.thanthree.com">Less Than Three</a>
</li>
</ul>
</nav>
</div>
</footer>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-12328521-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>