OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [doc/] [or32.texinfo] - Blame information for rev 862

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
\input texinfo      @c -*-texinfo-*-
2
@c Copyright (C) 2008 Embecosm Limited
3
@c
4
@c %**start of header
5
@c makeinfo ignores cmds prev to setfilename, so its arg cannot make use
6
@c of @set vars.  However, you can override filename with makeinfo -o.
7 232 jeremybenn
@setfilename or32.info
8 227 jeremybenn
@c
9
@include gdb-cfg.texi
10
@c
11
@settitle Debugging the OpenRISC 1000 with @value{GDBN}
12
@setchapternewpage odd
13
@c %**end of header
14
 
15
@iftex
16
@c @smallbook
17
@c @cropmarks
18
@end iftex
19
 
20
@finalout
21
@syncodeindex ky cp
22
 
23
@c readline appendices use @vindex, @findex and @ftable,
24
@c annotate.texi and gdbmi use @findex.
25
@syncodeindex vr cp
26
@syncodeindex fn cp
27
 
28
@c !!set manual's edition!
29
@set EDITION Second
30
 
31
@c !!set GDB edit command default editor
32
@set EDITOR /bin/ex
33
 
34
@c THIS MANUAL REQUIRES TEXINFO 4.0 OR LATER.
35
 
36
@c This is a dir.info fragment to support semi-automated addition of
37
@c manuals to an info tree.
38
@dircategory Software development
39
@direntry
40 232 jeremybenn
* Gdb for OpenRISC 1000: (gdb for Or32).   The GNU debugger for OpenRISC 1000.
41 227 jeremybenn
@end direntry
42
 
43
@ifinfo
44
This file documents the @sc{gnu} debugger @value{GDBN} when used with
45
OpenRISC 1000 processors.
46
 
47
This is the @value{EDITION} Edition, of @cite{Debugging the OpenRISC 1000
48
@value{GDBN}} for @value{GDBN}
49
Version @value{GDBVN}.
50
 
51
Copyright (C) 2008 Embecosm Limited
52
 
53
Permission is granted to copy, distribute and/or modify this document
54
under the terms of the GNU Free Documentation License, Version 3 or
55
any later version published by the Free Software Foundation; with the
56
Front-Cover Texts being ``Debugging the OpenRISC 1000 with GDB by
57
Jeremy Bennett'' and with the Back-Cover Texts being ``You are free to
58
copy and modify this Manual.''
59
@end ifinfo
60
 
61
@titlepage
62
@title Debugging the OpenRISC 1000 with @value{GDBN}
63
@subtitle Target Processor Manual
64
@sp 1
65
@subtitle @value{EDITION} Edition, for @value{GDBN} version @value{GDBVN}
66
@author Jeremy Bennett, Embecosm Limited
67
@page
68
@tex
69
{\parskip=0pt
70 232 jeremybenn
\hfill Please report bugs using the OpenRISC bug tracker:\par
71
\hfill @uref{http://opencores.org/openrisc,bugtracker}.\par
72 227 jeremybenn
\hfill {\it Debugging the OpenRISC 1000 with @value{GDBN}}\par
73
\hfill \TeX{}info \texinfoversion\par
74
}
75
@end tex
76
 
77
@vskip 0pt plus 1filll
78
Copyright @copyright{} 2008
79
Embecosm Limited.
80
@sp 2
81
Published by Embecosm Limited@*
82 232 jeremybenn
Palamos House #104
83
Lymington SO41 9AL, UK@*
84 227 jeremybenn
 
85
Permission is granted to copy, distribute and/or modify this document
86
under the terms of the GNU Free Documentation License, Version 3 or
87
any later version published by the Free Software Foundation; with the
88
Front-Cover Texts being ``Debugging the OpenRISC 1000 with GDB by
89
Jeremy Bennett'' and with the Back-Cover Texts being ``You are free to
90
copy and modify this Manual.''
91
@end titlepage
92
@page
93
 
94
@ifnottex
95
@node Top, Summary, (dir), (dir)
96
 
97
@top Debugging the OpenRISC 1000 with @value{GDBN}
98
 
99
This file describes @value{GDBN}, the @sc{gnu} symbolic debugger for
100
use with the OpenRISC 1000 processor architecture.
101
 
102
This is the @value{EDITION} Edition, for @value{GDBN} Version
103
@value{GDBVN}.
104
 
105
Copyright (C) 2008 Embecosm Limited
106
 
107
@menu
108
* Summary::                         Summary of @value{GDBN} with OpenRISC 1000
109
* Connecting to the Target::        Connecting to an OpenRISC 1000 Target
110
* OpenRISC 1000 Specific Commands:: Commands just for the OpenRISC 1000
111
* OpenRISC 1000 Example::           A small example
112
* OpenRISC 1000 Limitations::       Known problems
113
 
114
* Copying::                         GNU General Public License says
115
                                    how you can copy and share GDB
116
* GNU Free Documentation License::  The license for this documentation
117
* Index::                           Index
118
@end menu
119
 
120
@end ifnottex
121
 
122
@contents
123
 
124
@node Summary
125 232 jeremybenn
@unnumbered Summary of @value{GDBN} for the OpenRISC 1000
126 227 jeremybenn
@cindex Overview
127
@cindex Summary
128
 
129
@value{GDBN} is described well in its user manual, ``Debugging with GDB: The
130
GNU Source-Level Debugger''.
131
 
132
@cindex RSP
133
@cindex Remote Serial Protocol
134
This manual describes how to use @value{GDBN} to debug C programs cross
135
compiled for and running on processors using the OpenRISC 1000
136
architecture. In general @value{GDBN} does not run on the actual target, but
137
on a separate host processor. It communicates with the target via the
138
@value{GDBN} @dfn{Remote Serial Protocol} (@acronym{RSP}).
139
 
140
@cindex JTAG
141
@cindex jtag, target
142
@cindex target jtag
143 232 jeremybenn
Past releases of @value{GDBN} for OpenRISC supported a custom remote
144
protocol, which drives the JTAG interface on the OpenRISC 1000. This is
145
now obsolete, since all targets support the @dfn{Remote Serial
146
Protocol}, with adapters available to drive JTAG. Support has been
147
dropped from @value{GDBN} release 7.1.
148 227 jeremybenn
 
149 232 jeremybenn
@cindex simulator,
150
@cindex simlator, target
151
@cindex target simulator
152
This release implements a simulator, based on Or1ksim, the OpenRISC
153
architectural simulator. @command{target sim} will connect to a vanilla
154
Or1ksim model with 8MB of RAM starting at address zero.
155
 
156 227 jeremybenn
@cindex SPR
157
@cindex Special Purpose Registers
158
@cindex @command{spr} command
159
@cindex commands, @command{spr}
160
@cindex @command{info spr} command
161
@cindex commands, @command{info spr}
162
@cindex OpenRISC 1000 specific commands
163
@cindex commands, OpenRISC 1000 specific
164
In addition the info command is extended to allow inspection of
165
OpenRISC 1000 Special Purpose registers, and a new command ``spr'' is
166
added to set the value of a Special Purpose Register. @xref{OpenRISC 1000
167
Specific Commands,,OpenRISC 1000 Specific Commands}.
168
 
169
@cindex @command{info registers} command  for OpenRISC 1000
170
@cindex commands, @command{info registers} for OpenRISC 1000
171
All the normal GDB commands should work, although hardware watchpoints are not
172
tested at present. The @command{info registers} command will show the 32 general
173
purpose registers, while the @command{info registers all} command will add the
174
program counter, supervision register and exception program counter register.
175
 
176
@iftex
177
Throughout this document, user input is emphasised like this: @command{input},
178
program output is show like this: @code{Hello World!}.
179
@end iftex
180
 
181
@cindex graphical debugging
182
@cindex graphical debugging, @command{gdbtui}
183
@cindex graphical debugging, @command{ddd}
184
@cindex @command{gdbtui}
185
@cindex @command{ddd}
186
For those who like their debugging graphical, the @command{gdbtui} command is
187 232 jeremybenn
available (typically as @command{or32-elf-gdbtui}). @value{GDBN} for
188 227 jeremybenn
OpenRISC 1000 can also be run under @command{ddd} as follows:
189
 
190
@example
191 232 jeremybenn
@command{ddd --debugger=or32-elf-gdb --gdb}
192 227 jeremybenn
@end example
193
 
194
@menu
195
* Contributors::                Contributors to GDB for the OpenRISC 1000
196
@end menu
197
 
198
@node Contributors
199
@unnumberedsec Contributors to @value{GDBN} for the OpenRISC 1000
200
 
201
The pantheon of contributors to GDB over the years is recorded in the main
202
user manual, `Debugging with GDB: The GNU Source-Level Debugger''.
203
 
204
@cindex contributors, OpenRISC 1000
205
There is no official history of contributors to the OpenRISC 1000
206 232 jeremybenn
version. However the current author believes the original @value{GDBN}
207
5.0 and 5.3 ports were the work of:
208 227 jeremybenn
 
209
@itemize @bullet
210
@item
211
@cindex Ivan Guzvinex
212
@cindex Guzvinex, Ivan
213
@cindex Johan Rydverg
214
@cindex Rydverg, Johan
215
@cindex Binary File Description library
216
@cindex BFD
217
Ivan Guzvinec and Johan Rydverg at OpenCores, who wrote the Binary File
218
Descriptor library;
219
 
220
@item
221
@cindex Alessandro Forin
222
@cindex Forin, Alessandro
223
@cindex Per Bothner
224
@cindex Bothner, Per
225
@cindex GDB interface, OpenRISC 1000
226
Alessandro Forin at Carnegie-Mellon University and Per Bothner at the University
227
of Wisconsin who wrote the main GDB interface; and
228
 
229
@item
230
@cindex Mark Mlinar
231
@cindex Mlinar, Mark
232
@cindex Chris Ziomkowski
233
@cindex Ziomkowski, Chris
234
@cindex OpenRISC 1000 JTAG interface
235
@cindex JTAG, OpenRISC 1000 interface
236 232 jeremybenn
Mark Mlinar at Cygnus Support and Chris Ziomkowski at ASICS.ws, who wrote the
237
OpenRISC JTAG interface (now obsolete).
238 227 jeremybenn
@end itemize
239
 
240
@cindex Jeremy Bennett
241
@cindex Bennett, Jeremy
242
@cindex Embecosm
243
The port to @value{GDBN} @value{GDBVN} is the work of Jeremy Bennett
244
of Embecosm Limited (jeremy.bennett@@embecosm.com).
245
 
246
@quotation Plea
247
@cindex contributors, unknown
248
If you know of anyone who has been omitted from this list, please email the
249
current author, so the omission can be corrected, and credit given where it is
250
due.
251
@end quotation
252
 
253
@node Connecting to the Target
254
@chapter Connecting to an OpenRISC 1000 Target
255
@cindex OpenRISC 1000 target, connecting
256
@cindex target, OpenRISC 1000, connecting
257
@cindex connecting, OpenRISC 1000 target
258
There are two ways to connect to an OpenRISC 1000 target with GDB.
259
 
260
@enumerate
261
@item
262
@cindex @command{target remote} command
263
@cindex commands, @command{target remote}
264
@cindex @command{target extended-remote} command
265
@cindex commands, @command{target extended-remote}
266
@cindex OpenRISC 1000 target, remote connecting via RSP
267
@cindex target, remote, OpenRISC 1000, connecting via RSP
268
@cindex connecting, OpenRISC 1000 target, remote via RSP
269
@cindex remote OpenRISC 1000 target, connecting via RSP
270
Via a TCP/IP socket to a machine which has the hardware connected, or
271
is running the architectural simulator using the standard @value{GDBN}
272
@dfn{Remote Serial Protocol}. This uses the @value{GDBN} commands
273
@command{target remote} or @command{target extended-remote}.
274
 
275
@item
276 232 jeremybenn
@cindex @command{target sim} command
277
@cindex commands, @command{target sim}
278
@cindex OpenRISC 1000 target, simulator
279
@cindex sim, target
280
@cindex target sim
281 227 jeremybenn
@cindex target, remote, OpenRISC 1000, connecting via JTAG
282
@cindex connecting, OpenRISC 1000 target, remote via JTAG
283
@cindex remote OpenRISC 1000 target, connecting via JTAG
284 232 jeremybenn
To the OpenRISC architectural simulator, Or1ksim, integrated as a GDB
285
simulator.  This uses the @value{GDBN} command @command{target sim}.
286 227 jeremybenn
 
287 232 jeremybenn
@end enumerate
288
 
289 227 jeremybenn
@quotation Note
290 232 jeremybenn
Connection via the obsolete proprietary OpenRISC JTAG protocol is no
291
longer supported.
292 227 jeremybenn
@end quotation
293
 
294
@cindex OpenRISC 1000 Architectural Simulator
295
@cindex Or1ksim
296
@quotation Caution
297 232 jeremybenn
This release of GDB requires the latest experimental version of Or1ksim,
298
built from SVN revision 229 or later.
299 227 jeremybenn
@end quotation
300
 
301
@menu
302
* Remote Serial Protocol Connection:: Connection via the @value{GDBN} Remote
303
                                      Serial Protocol Interface
304 232 jeremybenn
* Simulator Connection::              Connection to the built in simulator
305 227 jeremybenn
@end menu
306
 
307
@node Remote Serial Protocol Connection
308
@section Connection via the @value{GDBN} Remote Serial Protocol
309
@cindex OpenRISC 1000 target, remote connecting via RSP
310
@cindex target, remote, OpenRISC 1000, connecting via RSP
311
@cindex connecting, OpenRISC 1000 target, remote via RSP
312
@cindex remote OpenRISC 1000 target, connecting via RSP
313
 
314
The usual mode of operation is through the @value{GDBN} @dfn{Remote Serial
315
Protocol} (@acronym{RSP}). This communicates to the target through a TCP/IP
316
socket. The target must then implement the server side of the interface to
317
drive either physical hardware (for example through a USB/JTAG connector) or a
318
simulation of the hardware (such as the OpenRISC Architectural Simulator).
319
 
320
Although referred to as a @emph{remote} interface, the target may actually
321
be on the same machine, just running in a separate process, with its own
322
terminal window.
323
 
324
For example, to connect to the OpenRISC 1000 Architectural simulator, which is
325
running on machine ``thomas'' and has been configured to talk to @value{GDBN}
326
on port 51000, the following command would be used:
327
 
328
@cindex remote @command{target jtag} command
329
@cindex @command{target jtag} command, remote
330
@cindex commands, @command{target jtag}, remote
331
@cindex remote target specification for RSP
332
@cindex target specification for RSP
333
@example
334
@command{target remote thomas:51000}
335
@end example
336
 
337
The target machine is specified as the machine name and port number. If the
338
architectural simulator was running on the same machine, its name may be
339
omitted, thus:
340
 
341
@cindex remote target specification, same machine for RSP
342
@cindex target specification for RSP, same machine
343
@example
344
@command{target remote :51000}
345
@end example
346
 
347 232 jeremybenn
@node Simulator Connection
348
@section Connection to the Built in Simulator
349
@cindex OpenRISC 1000 target, simulator
350
@cindex target, simulator, OpenRISC 1000, connecting
351
@cindex connecting, OpenRISC 1000 target, simulator
352
@cindex simulator OpenRISC 1000 target, connecting
353 227 jeremybenn
 
354 232 jeremybenn
The simplest way to run programs under @value{GDBN} is to connect to the
355
built in simulator. This is the OpenRISC architectural simulator,
356
Or1ksim, which has been integrated into GDB as a standard simulator.
357 227 jeremybenn
 
358 232 jeremybenn
@cindex @command{target sim} command
359
@cindex commands, @command{target sim}
360 227 jeremybenn
@example
361 232 jeremybenn
@command{target sim}
362 227 jeremybenn
@end example
363
 
364 232 jeremybenn
By default, the simulator is configured with 8MB of RAM running from
365
address 0x0, and the simulator runs with the Or1ksim @command{--quiet}
366
option, to mimize extraneous output.
367 227 jeremybenn
 
368 232 jeremybenn
@cindex @command{target sim}, additional options
369
Additional options may be specified to the underlying Or1ksim engine,
370
exactly as when using Or1ksim standalone, with the entire argument
371
string prefixed by @command{-f}.  For example.
372 227 jeremybenn
 
373
@example
374 232 jeremybenn
@command{target sim "-f --report-memory-errors -f mysim.cfg"}
375 227 jeremybenn
@end example
376
 
377 232 jeremybenn
@quotation Note
378
It is possible to use @command{target sim} many times. However any arguments
379
are only applied the first time. Or1ksim can only be instantiated
380
once. On the completion of a run it is not actually cosed, merely
381
stalled.
382
@end quotation
383 227 jeremybenn
 
384 232 jeremybenn
@quotation Caution
385
Any additional configuration must take account of the existing
386
8MB memory block. At present there is no way to remove that memory
387
block.
388 227 jeremybenn
@end quotation
389
 
390
@node OpenRISC 1000 Specific Commands
391
@chapter Commands just for the OpenRISC 1000
392
@cindex @command{info spr} command
393
@cindex @command{spr} command
394
@cindex commands, @command{info spr}
395
@cindex commands, @command{spr} command
396
@cindex custom commands, OpenRISC 1000
397
@cindex OpenRISC 1000, custom commands
398
The OpenRISC 1000 has one particular feature that is difficult for
399
@value{GDBN}. @value{GDBN} models target processors with a register
400
bank and a block of memory. The internals of @value{GDBN} assume that
401
there are not a huge number of registers in total.
402
 
403
The OpenRISC 1000 Special Purpose Registers (SPR) do not really fit well into
404
this structure. There are too many of them (12 groups each with 2000+ entries
405
so far, with up to 32 groups permitted) to be implemented as ordinary
406
registers in @value{GDBN}. Think what this would mean for the command
407
@command{info registers all}. However they cannot be considered memory, since
408
they do not reside in the main memory map.
409
 
410
The solution is to add two new commands to @value{GDBN} to see the value of a
411
particular SPR and to set the value of a particular SPR.
412
 
413
@enumerate
414
@item
415
@command{info spr} is used to show the value of a SPR or group of SPRs.
416
 
417
@item
418
@command{spr} is used to set the value of an individual SPR.
419
@end enumerate
420
 
421
@menu
422
* Reading SPRs::            Using the ``info spr'' command
423
* Writing SPRs::            Using the spr command
424
@end menu
425
 
426
@node Reading SPRs
427
@section Using the @command{info spr} Command
428
@cindex @command{info spr} command
429
@cindex commands, @command{info spr}
430
@cindex @command{info spr} command, argument specification
431
@cindex @command{info spr} command, single register
432
 
433
The value of an SPR is read by specifying either the unique name of the SPR,
434
or the its group and index in that group. For example the Debug Reason
435
Register (@code{DRR}, register 21 in group 6 (Debug)) can be read using any of
436
the following commands:
437
 
438
@example
439
@command{info spr DRR}
440
@command{info spr debug DRR}
441
@command{info spr debug 21}
442
@command{info spr 6 DRR}
443
@command{info spr 6 21}
444
@end example
445
 
446
In each case the output will be:
447
 
448
@example
449
@code{DEBUG.DRR = SPR6_21 = 0 (0x0)}
450
@end example
451
 
452
@cindex @command{info spr} command, argument specification
453
@cindex @command{info spr} command, complete group
454
It is also possible to inspect all the registers in a group. For example to
455
look at all the Programmable Interrupt Controller registers (group 9), either
456
of the following commands could be used:
457
 
458
@example
459
@command{info spr PIC}
460
@command{info spr 9}
461
@end example
462
 
463
And the output would be:
464
 
465
@example
466
@code{PIC.PICMR = SPR9_0 = 0 (0x9)}
467
@code{PIC.PICSR = SPR9_2 = 0 (0x8)}
468
@end example
469
 
470
Indicating that interrupts 0 and 4 are enabled and interrupt 4 is pending.
471
 
472
@node Writing SPRs
473
@section Using the @command{spr} Command
474
@cindex @command{spr} command
475
@cindex commands, @command{spr} command
476
@cindex @command{spr} command, argument specification
477
 
478
The value of an SPR is written by specifying the unique name of the SPR or its
479
group and index in the same manner as for the @command{info spr} command. An
480
additional argument specifies the value to be written. So for example the
481
Programmable Interrupt Controller mask register could be changed to enable
482
interrupts 5 and 3 only by any of the following commands.
483
 
484
@example
485
@command{spr PICMR 0x24}
486
@command{spr PIC PICMR 0x24}
487
@command{spr PIC 0 0x24}
488
@command{spr 9 PICMR 0x24}
489
@command{spr 9 2 0x24}
490
@end example
491
 
492
@node OpenRISC 1000 Example
493
@chapter A Small Example
494
@cindex examples
495
@cindex examples, Hello World
496
@cindex Hello World example
497
 
498
A simple ``Hello World'' program (what else) is used to show the basics
499
 
500
@cindex examples
501
@cindex examples, Hello World
502
@cindex Hello World example
503
This is the cannonical small program. Here is the main program and its two
504
subprograms (added to demonstrate a meaningful backtrace).
505
 
506
@example
507
void level2() @{
508
  simexit( 0 );
509
@}
510
 
511
void level1() @{
512
  level2();
513
@}
514
 
515
main()
516
@{
517
  int  i;
518
  int  j;
519
 
520
  simputs( "Hello World!\n" );
521
  level1();
522
@}
523
@end example
524
 
525
It is linked with a program providing the utility functions @code{simexit},
526
@code{simputc} and @code{simprints}.
527
 
528
@example
529
void  simexit( int  rc )
530
@{
531
  __asm__ __volatile__ ( "\tl.nop\t%0" : : "K"( NOP_EXIT ));
532
 
533
@}      /* simexit() */
534
 
535
void  simputc( int  c )
536
@{
537
  __asm__ __volatile__ ( "\tl.nop\t%0" : : "K"( NOP_PUTC ));
538
 
539
@}      /* simputc() */
540
 
541
void  simputs( char *str )
542
@{
543
  int  i;
544
 
545
  for( i = 0; str[i] != '\0' ; i++ ) @{
546
    simputc( (int)(str[i]) );
547
  @}
548
@}      /* simputs() */
549
@end example
550
 
551
Finally, a small bootloader is needed, which will be placed at the OpenRISC
552
reset vector location (0x100) to set up a stack and jump to the main program.
553
 
554
@example
555
        .org    0x100           # The reset routine goes at 0x100
556
        .global _start
557
_start:
558
        l.addi  r1,r0,0x7f00    # Set SP to value 0x7f00
559
        l.addi  r2,r1,0x0       # FP and SP are the same
560
        l.mfspr r3,r0,17        # Get SR value
561
        l.ori   r3,r3,0x10      # Set exception enable bit
562
        l.jal   _main           # Jump to main routine
563
        l.mtspr r0,r3,17        # Enable exceptions (DELAY SLOT)
564
 
565
        .org    0xFFC
566
        l.nop                   # Guarantee the exception vector space
567
                                # does not have general purpose code
568
@end example
569
 
570
This is compiled and linked with the OpenRISC 1000 @sc{gnu} toolchain. Note
571
that the linking must specify the bootloader first and use the @code{-Ttext
572
0x0} argument.
573
 
574
@cindex OpenRISC 1000 Architectural Simulator, configuration
575
@cindex configuration, OpenRISC 1000 Architectural Simulator
576
@cindex Or1ksim, configuration
577
@cindex configuration, Or1ksim
578
The Or1ksim architectural simulator is configured with memory starting at
579
location 0x0. The debugging interface is enabled by using a debug section.
580
 
581
@example
582
section debug
583
  enabled         =          1
584 232 jeremybenn
  rsp_enabled     =          1
585 227 jeremybenn
  server_port     =      50000
586
end
587
@end example
588
 
589
The architectural simulator is started in its own terminal window. If the
590
configuration is in @code{rsp.cfg}, then the command might be:
591
 
592
@example
593 232 jeremybenn
@command{or32-elf-sim -f rsp.cfg}
594 227 jeremybenn
Reading script file from 'rsp.cfg'...
595
Building automata... done, num uncovered: 0/213.
596
Parsing operands data... done.
597
Resetting memory controller.
598
Resetting PIC.
599
@end example
600
 
601
Note that no program is specified - that will be loaded from @value{GDBN}.
602
 
603
In a separate window start up @value{GDBN}.
604
 
605
@example
606 232 jeremybenn
@command{or32-elf-gdb}
607 227 jeremybenn
@end example
608
 
609
A local copy of the symbol table is needed, specified with the @command{file}
610
command.
611
 
612
@cindex examples, symbol file loading
613
@cindex symbol file loading
614
@cindex symbols when remote debugging
615
@example
616
Building automata... done, num uncovered: 0/216.
617
Parsing operands data... done.
618
GNU gdb 6.8
619
Copyright (C) 2008 Free Software Foundation, Inc.
620
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
621
This is free software: you are free to change and redistribute it.
622
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
623
and "show warranty" for details.
624 232 jeremybenn
This GDB was configured as "--host=i686-pc-linux-gnu --target=or32-elf".
625 227 jeremybenn
(gdb) @command{file hello}
626
Reading symbols from /home/jeremy/svntrunk/GNU/gdb-6.8/progs_or32/hello...done.
627
(gdb)
628
@end example
629
 
630
@cindex examples, remote @command{target remote} command
631
@cindex remote @command{target remote} command, example
632
@cindex @command{target remote} command, remote, example
633
@cindex commands, @command{target remote}, remote, example
634
@cindex examples, remote target specification via RSP
635
@cindex remote target specification via RSP, example
636
@cindex target specification, remote via RSP, example
637
The connection to the target (the architectural simulator) is then
638
established, using the port number given in the configuration file.
639
 
640
@example
641
(gdb) @command{target remote :51000}
642
Remote debugging using :51000
643
0x00000100 in _start ()
644
(gdb)
645
@end example
646
 
647
@cindex examples, program loading
648
@cindex program loading
649
@cindex program loading, example
650
@cindex program loading, remote
651
@cindex remote program loading, example
652
The program of interest can now be loaded:
653
 
654
@example
655
(gdb) @command{load hello}
656
Loading section .text, size 0x1290 lma 0x0
657
Loading section .rodata, size 0xe lma 0x1290
658
Start address 0x100, load size 4766
659
Transfer rate: 5 KB/sec, 238 bytes/write.
660
(gdb)
661
@end example
662
 
663
The program does not immediately start running, since on opening the
664
connection to the target, Or1ksim stalls.
665
 
666
@cindex examples, @command{bt} command
667
@cindex @command{bt} command example
668
@cindex commands, @command{bt}, example
669
@cindex examples, @command{info spr} command
670
@cindex @command{info spr} command example
671
@cindex commands, @command{info spr}, example
672
All the GDB commands (including the SPR commands are available). For example
673
 
674
@example
675
(gdb) @command{bt}
676
#0  0x00000100 in _start ()
677
(gdb) @command{info spr 0 17}
678
SYS.SR = SPR0_17 = 32769 (0x8001)
679
(gdb)
680
@end example
681
 
682
The Supervision Register shows the target is in Supervisor Mode and that SPRs
683
have User Mode read access.
684
 
685
@emph{Note.} The supervision register is used to provide the value for the
686
@value{GDBN} @code{$ps} processor status variable, so can also be accessed as:
687
 
688
@example
689
(gdb) @command{print $ps}
690
$1 = 32769
691
(gdb)
692
@end example
693
 
694
@cindex examples, @command{breakpoint} command
695
@cindex @command{breakpoint} command example
696
@cindex commands, @command{breakpoint}, example
697
@cindex examples, @command{continue} command
698
@cindex @command{continue} command example
699
@cindex commands, @command{continue}, example
700
@cindex continuening the remote program
701
@cindex examples, continuing a program
702
For this example set a breakpoint at the start of main and then continue the
703
program
704
 
705
@example
706
(gdb) @command{break main}
707
Breakpoint 1 at 0x1264: file hello.c, line 41.
708
(gdb) @command{continue}
709
Continuing.
710
 
711
Breakpoint 1, main () at hello.c:41
712
41        simputs( "Hello World!\n" );
713
(gdb)
714
@end example
715
 
716
@cindex examples, @command{step} command
717
@cindex @command{step} command example
718
@cindex commands, @command{step}, example
719
It is now possible to step through the code:
720
@example
721
(gdb) @command{step}
722
simputs (str=0x1290 "Hello World!\n") at utils.c:90
723
90        for( i = 0; str[i] != '\0' ; i++ ) @{
724
(gdb) @command{step}
725
91          simputc( (int)(str[i]) );
726
(gdb) @command{step}
727
simputc (c=72) at utils.c:58
728
58        __asm__ __volatile__ ( "\tl.nop\t%0" : : "K"( NOP_PUTC ));
729
(gdb)
730
@end example
731
 
732
@cindex examples, @command{bt} command
733
@cindex @command{bt} command example
734
@cindex commands, @command{bt}, example
735
At this point a backtrace will show where the code has reached:
736
 
737
@example
738
(gdb) @command{bt}
739
#0  simputc (c=72) at utils.c:58
740
#1  0x000011cc in simputs (str=0x1290 "Hello World!\n") at utils.c:91
741
#2  0x00001274 in main () at hello.c:41
742
#3  0x00000118 in _start ()
743
(gdb)
744
@end example
745
 
746
One more step completes the call to the character output routine. Inspecting
747
the terminal running the Or1ksim simulation, shows the output appearing:
748
 
749
@example
750
JTAG Proxy server started on port 50000
751
Resetting PIC.
752
H
753
@end example
754
 
755
@cindex examples, @command{continue} command
756
@cindex @command{continue} command example
757
@cindex commands, @command{continue}, example
758
Let the program run to completion by giving @value{GDBN} the continue command:
759
@example
760
(gdb) @command{continue}
761
Continuing.
762
Remote connection closed
763
(gdb)
764
@end example
765
 
766
@cindex remote program termination
767
With completion of the program, the terminal running Or1ksim shows its final
768
output:
769
 
770
@example
771
Resetting PIC.
772
Hello World!
773
exit(0)
774
@@reset : cycles 0, insn #0
775
@@exit  : cycles 215892308, insn #215891696
776
 diff  : cycles 215892308, insn #215891696
777
@end example
778
 
779
 
780
@cindex remote program restart
781
@cindex restart, remote program
782
@cindex examples, @command{set} command
783
@cindex @command{set} command example
784
@cindex commands, @command{set}, example
785
When execution exits (by execution of a @code{l.nop 1}), the connection to the
786
target is automatically broken as the simulator exits.
787
 
788
@node OpenRISC 1000 Limitations
789
@chapter Known Problems
790
@cindex known problems
791
@cindex OpenRISC 1000, known GDB problems
792
@cindex bugs
793
 
794
There are some known problems with the current implementation
795
 
796
@enumerate
797
@item
798
@cindex known problems, watchpoints
799
@cindex bugs, watchpoints
800
If the OpenRISC 1000 Architecture supports hardware watchpoints, @value{GDBN}
801
will use them to implement hardware breakpoints and watchpoints. @value{GDBN}
802
is not perfect in handling of watchpoints. It is possible to allocate hardware
803
watchpoints and not discover until running that sufficient watchpoints are not
804
available. It is also possible that GDB will report watchpoints being hit
805
spuriously. This can be down to the assembly code having additional memory
806
accesses that are not obviously reflected in the source code.
807
 
808
@item
809
@cindex known problems, remote JTAG connection robustness
810
@cindex bugs, remote JTAG connection robustness
811
@cindex JTAG, remote connection robustness
812
@cindex remote JTAG, connection robustness
813
The remote JTAG connection is not robust to being interrupted, or
814
reconnecting. If the connection is lost due to error, then you must restart
815
GDB and the target server (for example the Or1ksim architectural
816
simulator). Moving to the Remote Serial Protocol is intended to remedy this
817
problem in the future.
818
 
819
@item
820
@cindex known problems, architectural compatability
821
@cindex bugs, architectural compatibility
822
@cindex GDB 5.3, differences in port of @value{GDBN} version @value{GDBVN}
823
The OpenRISC 1000 architecture has evolved since the port of GDB 5.3
824
in 2001. In particular the structure of the Unit Present register has
825
changed and the CPU Configuration register has been added. The port of
826
@value{GDBN} version @value{GDBVN} uses the @emph{current}
827
specification of the OpenRISC 1000. This means that old clients that
828
talk to the debugger may not work. In particular the Or1ksim
829
Architectural simulator requires a patch to work.
830
 
831
@item
832
@cindex known problems, Or1ksim architectural simulator
833
@cindex bugs, Or1ksim architectural simulator
834
@cindex Or1ksim, bugs fixed
835
The handling of watchpoints in the Or1ksim architectural simulator was
836
incorrect. To work with @value{GDBN} @value{GDBVN}, a patch is required to fix
837
this problem. This is combined with the patch changing the structure of the
838
Unit Present and CPU Configuration registers.
839
 
840
@item
841
@cindex known problems, Or1ksim architectural simulator
842
@cindex bugs, Or1ksim architectural simulator
843
@cindex Or1ksim, bugs fixed
844
The OpenRISC 1000 architecture uses its General Purpose
845
Register (GPR) 2 as a frame pointer register. However the @command{$fp}
846
variable in @value{GDBN} is not currently implemented, and will return
847
the value of the stack pointer (GPR 1) instead.
848
@end enumerate
849
 
850
@cindex Bugs, reporting
851
@cindex Reporting bugs
852
Reports of bugs are much welcomed. Please report problems through the
853
OpenCORES tracker at @uref{www.opencores.org/ptracker.cgi/list/or1k}.
854
@include gpl.texi
855
 
856
@raisesections
857
@include fdl.texi
858
@lowersections
859
 
860
@node Index
861
@unnumbered Index
862
 
863
@printindex cp
864
 
865
@tex
866
% I think something like @colophon should be in texinfo.  In the
867
% meantime:
868
\long\def\colophon{\hbox to0pt{}\vfill
869
\centerline{The body of this manual is set in}
870
\centerline{\fontname\tenrm,}
871
\centerline{with headings in {\bf\fontname\tenbf}}
872
\centerline{and examples in {\tt\fontname\tentt}.}
873
\centerline{{\it\fontname\tenit\/},}
874
\centerline{{\bf\fontname\tenbf}, and}
875
\centerline{{\sl\fontname\tensl\/}}
876
\centerline{are used for emphasis.}\vfill}
877
\page\colophon
878
% Blame: doc@cygnus.com, 1991.
879
@end tex
880
 
881
@bye

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.