Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
440 lines (319 loc) · 18.8 KB
/
Copy pathindex.html
File metadata and controls
440 lines (319 loc) · 18.8 KB
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="alternate" type="application/rss+xml" title="Eclipse Embedded CDT" href="/feed.xml" />
<title>Debugging</title>
<meta name="description" content="A family of Eclipse CDT extensions and tools for GNU Arm & RISC-V development">
<meta property="og:title" content="Debugging" />
<meta property="og:site_name" content="Eclipse Embedded CDT" />
<meta property="article:published_time" content="2015-09-11">
<meta name="google-site-verification" content="NT_y3tqI_8mrd8gYA_FDWHT2-tkJExOC6KBkSnyZx6c" />
<meta http-equiv="refresh" content="1; url=https://eclipse-embed-cdt.github.io/debug/">
<link href='https://fonts.googleapis.com/css?family=Architects+Daughter' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="/stylesheets/screen.css?201901210928" media="screen">
<link rel="stylesheet" type="text/css" href="/stylesheets/print.css?201901210928" media="print">
<link rel="canonical" href="/debug/">
<link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/assets/icons/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="96x96" href="/assets/icons/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png">
<link rel="manifest" href="/assets/manifest.json">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-16767008-16', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.4";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<header>
<div class="inner">
<h1><a href="https://www.eclipse.org/embed-cdt/">Eclipse Embedded CDT</a></h1>
<h2>A family of Eclipse CDT extensions and tools for GNU Arm & RISC-V development</h2>
<div id="buttons">
<a href="http://github.com/eclipse-embed-cdt" class="button"><small>Follow me on</small> GitHub</a>
</div>
</div>
</header>
<div id="content-wrapper">
<div class="inner clearfix">
<div id="site-body">
<section id="main-content">
<h1 class="page-title">Debugging</h1>
<div id="toc-container">
<table class="toc" id="toc">
<tbody>
<tr>
<td>
<div id="toctitle">
<h2>Contents</h2>
</div>
<ul>
<li class="toc_level-1 toc_section-1">
<a href="#quicklinks"><span class="tocnumber">1</span> <span class="toctext">Quicklinks</span></a>
</li>
<li class="toc_level-1 toc_section-2">
<a href="#overview"><span class="tocnumber">2</span> <span class="toctext">Overview</span></a>
<ul>
<li class="toc_level-2 toc_section-3">
<a href="#manual-stepping"><span class="tocnumber">2.1</span> <span class="toctext">Manual stepping</span></a>
</li>
<li class="toc_level-2 toc_section-4">
<a href="#using-trace-messages"><span class="tocnumber">2.2</span> <span class="toctext">Using trace messages</span></a>
</li>
</ul>
</li>
<li class="toc_level-1 toc_section-5">
<a href="#gdb"><span class="tocnumber">3</span> <span class="toctext">GDB</span></a>
<ul>
<li class="toc_level-2 toc_section-6">
<a href="#no-initialisation-files"><span class="tocnumber">3.1</span> <span class="toctext">No initialisation files</span></a>
</li>
</ul>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>
<h2 id="quicklinks">Quicklinks</h2>
<p>If you know all about debugging, and all you need is how to install/configure/use the debugging plug-ins, the direct links are below.</p>
<p>In short, for bare metal embedded development, we highly recommend solutions that can be used on all major platforms (Windows, macOS and GNU/Linux), with hardware probes that implement the SWD protocol and support tracing via the SWO pin. The preferred probes that match the above requirements are <a href="http://www.segger.com/j-link-edu.html">J-Link EDU</a>/<a href="http://www.segger.com/jlink_base.html">J-Link</a>, from <a href="http://www.segger.com/">SEGGER</a>.</p>
<ul>
<li><a href="/debug/jlink/install/">J-Link install</a></li>
<li><a href="/debug/jlink/">J-Link plug-in usage</a></li>
<li><a href="/openocd/install/">OpenOCD install</a></li>
<li><a href="/debug/openocd/">OpenOCD plug-in usage</a></li>
<li><a href="/qemu/install/">QEMU install</a></li>
<li><a href="/debug/qemu/">QEMU plug-in usage</a></li>
<li><a href="/debug/peripheral-registers/">The Peripherals registers view</a></li>
</ul>
<h2 id="overview">Overview</h2>
<p>Although it varies a lot depending on personal skills and experience, debugging can be one of the most time consuming activities during software development, and any solutions intended to address it are welcome.</p>
<p>Generally there are two approaches:</p>
<ul>
<li>manually stepping through the code to check the program flow and inspect various status variables</li>
<li>letting the program run and automatically collect various tracing messages (like the traditional printf() calls) and/or execution events (enter/exit interrupt handlers, memory location change, etc)</li>
</ul>
<p>To be noted that these approaches are not exclusive, but complement each other, since they better serve different purposes, and have specific advantages and disadvantages.</p>
<h3 id="manual-stepping">Manual stepping</h3>
<p>Manually stepping through the code is great for debugging a standalone linear piece of code, to check if the implementation of an algorithm is correct, to detect off-by-one errors (accessing past the size of an array or collection). It is also useful to get an initial understanding of the functionality of a piece of code written by someone else. Its main drawback is severely distorting the time behaviour of the debugged code, which, if the debugged device is interacting with other external devices, will most likely trigger timeouts. For complex code, with multiple iterations and multiple processes, it is quite tedious, requiring a lot of manual interactions with the debugger to reach the desired point in time, especially when the sessions are expected to be restarted often.</p>
<p>The manual stepping approach generally requires a generic debugger and a specific method to connect it to the application to be debugged. The GNU toolchains provide a standard <strong>gdb</strong> command line tool to interact with the debugged application, and Eclipse provides various plug-ins to integrate the command line tool into the IDE.</p>
<p>The recommended way to connect gdb, running on the development machine, to the application, running on an embedded device, is to use a gdb server. If the debugged application is a GNU/Linux ARM application, running on an embedded device like BeagleBone or Raspberry, the gdb server must be first installed and started on it, then the gdb client needs to be instructed to connect via tcp/ip to it and start the debug session.</p>
<p>If the debugged application runs on a bare metal device, then it is necessary to use a physical probe, to load the device memory and to assist during the debugging session. The standard way is to use a JTAG or SWD probe, paired with a custom gdb server, able to talk to it on one side, and to accept the standard gdb commands on the other side.</p>
<h3 id="using-trace-messages">Using trace messages</h3>
<p>Collecting tracing messages and events, when used wisely, can be a valuable source of information regarding the flow of a complex application, with multiple interacting threads, being especially useful when the debug sessions are restarted often. Once the trace messages are added, the dynamic life of various threads/handlers can be seen with a simple view of the trace log. In addition to classical printf() messages that need to be manually inserted in the code, for embedded applications, modern ARM cores, including those in the Cortex-M families, provide special support for collecting hardware events, like accurate timestamps when an interrupt handler was entered/exited, when a memory location was accessed, and more.</p>
<p>Recognising the importance of these methods, the designers of the ARM families added special support, like the <strong>SWO</strong> (Serial Wire Output) pin in Cortex-M processors, or even more elaborate interfaces for larger ARM processors.</p>
<h2 id="gdb">GDB</h2>
<p>The tool used by GNU MCU Eclipse plug-ins for debugging is the ARM version of GDB, the venerable GNU debugging tool.</p>
<h3 id="no-initialisation-files">No initialisation files</h3>
<p>For having a total control of the debugging session, the debugging plug-ins start the GDB client process with the <code class="language-plaintext highlighter-rouge">--nx</code> option, which prevents the execution of the commands found in any initialization file; none of the standard files (<code class="language-plaintext highlighter-rouge">system.gdbinit</code>, <code class="language-plaintext highlighter-rouge">~/.gdbinit</code>, <code class="language-plaintext highlighter-rouge">./.gdbinit</code>) are loaded.</p>
<p>To add more commands to the GDB initialisation sequence, use the <em>Commands:</em> field in the <em>GDB Client Setup</em> section:</p>
<p>
<img src="/assets/images/2015/launch-jlink-debugger-client.png" alt="Launch J-Link debugger client">
</p>
<p>All commands listed here are passed to the GDB client. By convention, commands prefixed with <code class="language-plaintext highlighter-rouge">mon</code> will be further passed from the GDB client to the GDB server.</p>
<hr class="page-footer">
<p class="page-footer">Last modified on Mon Oct 12 08:58:23 2020 UTC.</p>
<ul class="share-buttons">
<li><div class="tw-share-button"><a href="https://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a></div></li>
<li><div class="fb-share-button" data-href="http://gnu-mcu-eclipse.github.io/debug/" data-layout="button"></div></li>
</ul>
</section>
<aside id="sidebar">
<h4 id="latest-news"><a href="/blog/">Latest News</a></h4>
<ul>
<li><a href="/blog/2020/07/28/plugins-v5.1.1-202007271621-released/">Eclipse Embedded CDT plug-ins v5.1.1-202007271621 released</a></li>
<li><a href="/blog/2020/01/27/plugins-v4.7.2-202001271244-released/">GNU MCU Eclipse plug-ins v4.7.2-202001271244 released</a></li>
<li><a href="/blog/2019/11/06/plugins-v4.7.1-201911052135-released/">GNU MCU Eclipse plug-ins v4.7.1-201911052135 released</a></li>
<li><a href="/blog/2019/09/25/new-forums/">The GNU MCU Eclipse project has new forums</a></li>
<li><a href="/blog/2019/09/23/plugins-v4.6.1-201909231407-released/">GNU MCU Eclipse plug-ins v4.6.1-201909231407 released</a></li>
</ul>
<hr>
<h4 id="gnu-mcu-eclipse-home"><a href="/">GNU MCU Eclipse Home</a></h4>
<h4 id="features"><a href="/plugins/features/">Features</a></h4>
<h4 id="downloads"><a href="/downloads/">Downloads</a></h4>
<ul>
<li><a href="/downloads/">Overview</a></li>
<li>
<a href="/plugins/download/">Plug-ins</a> (<a href="/developer/releases/">releases</a>)</li>
<li>
<a href="/windows-build-tools/download/">Windows Build Tools</a> (<a href="/windows-build-tools/releases/">releases</a>)</li>
<li>
<a href="/qemu/download/">xPack QEMU Arm</a> (<a href="https://xpack.github.io/qemu-arm/releases/">releases</a>)</li>
<li>
<a href="/openocd/download/">xPack OpenOCD</a> (<a href="https://xpack.github.io/openocd/releases/">releases</a>)</li>
</ul>
<h4 id="install"><a href="/install/">Install</a></h4>
<ul>
<li><a href="/install/">Overview</a></li>
<li><a href="/toolchain/arm/install/">Arm Toolchain(s) install</a></li>
<li><a href="/toolchain/riscv/install/">RISC-V Toolchain(s) install</a></li>
<li><a href="/windows-build-tools/install/">Windows build tools (make & rm) install</a></li>
<li>
<a href="/debug/install/">Debugging binaries</a>
<ul>
<li><a href="/debug/install/">Overview</a></li>
<li><a href="/debug/jlink/install/">SEGGER J-Link install</a></li>
<li><a href="https://xpack.github.io/openocd/install/">xPack OpenOCD install</a></li>
<li><a href="https://xpack.github.io/qemu-arm/install/">xPack QEMU Arm install</a></li>
</ul>
</li>
<li><a href="/plugins/install/">Eclipse plug-ins install</a></li>
</ul>
<h4 id="important">Important</h4>
<ul>
<li><a href="/install/">Install order</a></li>
<li><a href="/eclipse/workspace/preferences/">Workspace preferences</a></li>
<li><a href="/toolchain/path/">Toolchain path</a></li>
<li><a href="/eclipse/project/portability/">Project portability</a></li>
</ul>
<h4 id="tutorials">Tutorials</h4>
<ul>
<li><a href="/tutorials/blinky-arm/">Create a Blinky Arm test project</a></li>
<li><a href="/tutorials/hello-arm/">Create a Hello Arm test project</a></li>
</ul>
<h4 id="how-to-use">How to use</h4>
<ul>
<li><a href="/plugins/mbs/">The managed build plug-in</a></li>
<li><a href="/plugins/packs-manager/">The packs manager (CMSIS)</a></li>
<li><a href="/eclipse/project/assign-device/">Assign a device</a></li>
</ul>
<h4 id="templates"><a href="/templates/">Templates</a></h4>
<ul>
<li><a href="/templates/">Overview</a></li>
<li><a href="/templates/cortexm/">Cortex-M template</a></li>
<li><a href="/templates/stm32f/">STM32Fxx template</a></li>
<li><a href="/templates/klxx/">Freescale KLxx templates</a></li>
</ul>
<h4 id="debugging"><a href="/debug/">Debugging</a></h4>
<ul>
<li><a href="/debug/">Overview</a></li>
<li><a href="/debug/jlink/">The SEGGER J-Link plug-in</a></li>
<li><a href="/debug/openocd/">The OpenOCD plug-in</a></li>
<li><a href="/debug/qemu/">The QEMU plug-in</a></li>
<li><a href="/debug/peripheral-registers/">The peripheral registers view (CMSIS)</a></li>
</ul>
<h4 id="xpack-dev-tools">xPack Dev tools</h4>
<ul>
<li><a href="https://xpack.github.io/arm-none-eabi-gcc/">xPack GNU Arm Embedded GCC</a></li>
<li><a href="https://xpack.github.io/riscv-none-embed-gcc/">xPack GNU RISC-V Embedded GCC</a></li>
<li><a href="https://xpack.github.io/qemu-arm/">xPack QEMU Arm</a></li>
<li><a href="https://xpack.github.io/openocd/">xPack OpenOCD</a></li>
</ul>
<h4 id="windows-build-tools-home"><a href="/windows-build-tools/">Windows Build Tools Home</a></h4>
<ul>
<li>
<a href="/windows-build-tools/">Overview</a> (read me first!)</li>
<li><a href="/windows-build-tools/install/">Windows Build Tools Install</a></li>
<li><a href="/windows-build-tools/build-procedure/">How to build</a></li>
<li><a href="/windows-build-tools/publish-procedure/">How to publish</a></li>
<li><a href="/windows-build-tools/releases/">Releases</a></li>
<li>
<a href="https://github.com/xpack-dev-tools/windows-build-tools-xpack/discussions">Support</a> (discuss)</li>
</ul>
<h4 id="the-risc-v-corner"><a href="/arch/riscv/">The RISC-V corner</a></h4>
<ul>
<li><a href="/arch/riscv/">Overview</a></li>
<li><a href="/arch/riscv/arty-reflash/">Flashing the Arty boards</a></li>
<li><a href="/arch/riscv/ftdi-jtag-drivers/">FTDI JTAG drivers</a></li>
</ul>
<h4 id="advanced">Advanced</h4>
<ul>
<li><a href="/advanced/headless-builds/">Headless builds</a></li>
</ul>
<h4 id="support"><a href="/support/">Support</a></h4>
<ul>
<li><a href="/support/">Overview</a></li>
<li><a href="/support/known-issues/">Known issues</a></li>
<li><a href="/support/faq/">FAQ</a></li>
<li><a href="/support/sourceforge/">SourceForge tickets</a></li>
<li><a href="/support/forum/">Forum</a></li>
<li><a href="https://github.com/gnu-mcu-eclipse/eclipse-plugins/issues/1/">Report plug-ins issue</a></li>
</ul>
<h4 id="developer"><a href="/developer/">Developer</a></h4>
<ul>
<li><a href="/developer/">Overview</a></li>
<li><a href="/developer/build-procedure/">How to build</a></li>
<li><a href="/developer/publish-procedure/">How to publish</a></li>
<li><a href="/developer/change-log">Change log</a></li>
<li><a href="/developer/contribute/">Contribute</a></li>
</ul>
<h4 id="hardware">Hardware</h4>
<ul>
<li><a href="/developer/j-link-stm32-boards/">J-Link and STM32 boards</a></li>
</ul>
<h4 id="latest-articles">Latest Articles</h4>
<ul>
<li><a href="/articles/arm-com-2015-12-09/">GNU ARM Eclipse now available from Eclipse Marketplace</a></li>
<li><a href="/articles/arm-com-2015-11/">GNU ARM Eclipse: Cortex-M7 support added</a></li>
<li><a href="/articles/arm-com-2015-09/">GNU ARM Eclipse has a new look and a new home</a></li>
<li><a href="/articles/arm-com-2014-07/">GNU ARM Eclipse: open source tools with (experimental) CMSIS Pack support</a></li>
</ul>
<h4 id="licenses">Licenses</h4>
<ul>
<li><a href="/licenses/plug-ins/">Eclipse plug-ins</a></li>
<li><a href="/licenses/tools/">Tools</a></li>
</ul>
<h4 id="finance">Finance</h4>
<ul>
<li><a href="/finance/sponsorship/">Sponsorship & donations</a></li>
</ul>
<h4 id="about"><a href="/about/">About</a></h4>
<hr>
<p>This site uses the Architect theme by <a href="https://twitter.com/jasonlong">Jason Long</a>.</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="NXKFN7DJH8DJ6">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="Pay Pal" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</aside>
</div>
</div>
<div class="inner clearfix">
<div class="site-footer">
<div class="site-footer-links left">
<ul>
<li>© 2020 Liviu Ionescu</li>
<li><a href="/feed.xml"><img src="/assets/images/feed-20.png" alt="RSS"></a></li>
<li>
<a href="http://twitter.com/gnu_mcu_eclipse" class="twitter-follow-button" data-show-count="false">Follow @gnu_mcu_eclipse</a><script async="" src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
</li>
</ul>
</div>
<a href="http://github.com/eclipse-embed-cdt" aria-label="Homepage">
<span class="mega-octicon octicon-mark-github" title="GitHub"></span>
</a>
<div class="site-footer-links right">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/blog/">News</a></li>
<li><a href="/downloads/">Downloads</a></li>
<li><a href="/support/">Support</a></li>
<li><a href="/about/">About</a></li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>