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

Subversion Repositories or1k

[/] [or1k/] [tags/] [VER_5_3/] [gdb-5.3/] [gdb/] [doc/] [gdb.info-12] - Blame information for rev 1778

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

Line No. Rev Author Line
1 1181 sfurman
This is gdb.info, produced by makeinfo version 4.1 from ./gdb.texinfo.
2
 
3
INFO-DIR-SECTION Programming & development tools.
4
START-INFO-DIR-ENTRY
5
* Gdb: (gdb).                     The GNU debugger.
6
END-INFO-DIR-ENTRY
7
 
8
   This file documents the GNU debugger GDB.
9
 
10
   This is the Ninth Edition, December 2001, of `Debugging with GDB:
11
the GNU Source-Level Debugger' for GDB Version 5.3.
12
 
13
   Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
14
1998,
15
1999, 2000, 2001, 2002 Free Software Foundation, Inc.
16
 
17
   Permission is granted to copy, distribute and/or modify this document
18
under the terms of the GNU Free Documentation License, Version 1.1 or
19
any later version published by the Free Software Foundation; with the
20
Invariant Sections being "Free Software" and "Free Software Needs Free
21
Documentation", with the Front-Cover Texts being "A GNU Manual," and
22
with the Back-Cover Texts as in (a) below.
23
 
24
   (a) The Free Software Foundation's Back-Cover Text is: "You have
25
freedom to copy and modify this GNU Manual, like GNU software.  Copies
26
published by the Free Software Foundation raise funds for GNU
27
development."
28
 
29

30
File: gdb.info,  Node: GDB/MI Thread Commands,  Next: GDB/MI Tracepoint Commands,  Prev: GDB/MI Target Manipulation,  Up: GDB/MI
31
 
32
GDB/MI Thread Commands
33
======================
34
 
35
The `-thread-info' Command
36
--------------------------
37
 
38
Synopsis
39
........
40
 
41
      -thread-info
42
 
43
GDB command
44
...........
45
 
46
   No equivalent.
47
 
48
Example
49
.......
50
 
51
   N.A.
52
 
53
The `-thread-list-all-threads' Command
54
--------------------------------------
55
 
56
Synopsis
57
........
58
 
59
      -thread-list-all-threads
60
 
61
GDB Command
62
...........
63
 
64
   The equivalent GDB command is `info threads'.
65
 
66
Example
67
.......
68
 
69
   N.A.
70
 
71
The `-thread-list-ids' Command
72
------------------------------
73
 
74
Synopsis
75
........
76
 
77
      -thread-list-ids
78
 
79
   Produces a list of the currently known GDB thread ids.  At the end
80
of the list it also prints the total number of such threads.
81
 
82
GDB Command
83
...........
84
 
85
   Part of `info threads' supplies the same information.
86
 
87
Example
88
.......
89
 
90
   No threads present, besides the main process:
91
 
92
     (gdb)
93
     -thread-list-ids
94
     ^done,thread-ids={},number-of-threads="0"
95
     (gdb)
96
 
97
   Several threads:
98
 
99
     (gdb)
100
     -thread-list-ids
101
     ^done,thread-ids={thread-id="3",thread-id="2",thread-id="1"},
102
     number-of-threads="3"
103
     (gdb)
104
 
105
The `-thread-select' Command
106
----------------------------
107
 
108
Synopsis
109
........
110
 
111
      -thread-select THREADNUM
112
 
113
   Make THREADNUM the current thread.  It prints the number of the new
114
current thread, and the topmost frame for that thread.
115
 
116
GDB Command
117
...........
118
 
119
   The corresponding GDB command is `thread'.
120
 
121
Example
122
.......
123
 
124
     (gdb)
125
     -exec-next
126
     ^running
127
     (gdb)
128
     *stopped,reason="end-stepping-range",thread-id="2",line="187",
129
     file="../../../devo/gdb/testsuite/gdb.threads/linux-dp.c"
130
     (gdb)
131
     -thread-list-ids
132
     ^done,
133
     thread-ids={thread-id="3",thread-id="2",thread-id="1"},
134
     number-of-threads="3"
135
     (gdb)
136
     -thread-select 3
137
     ^done,new-thread-id="3",
138
     frame={level="0 ",func="vprintf",
139
     args=[{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""},
140
     {name="arg",value="0x2"}],file="vprintf.c",line="31"}
141
     (gdb)
142
 
143

144
File: gdb.info,  Node: GDB/MI Tracepoint Commands,  Next: GDB/MI Variable Objects,  Prev: GDB/MI Thread Commands,  Up: GDB/MI
145
 
146
GDB/MI Tracepoint Commands
147
==========================
148
 
149
   The tracepoint commands are not yet implemented.
150
 
151

152
File: gdb.info,  Node: GDB/MI Variable Objects,  Prev: GDB/MI Tracepoint Commands,  Up: GDB/MI
153
 
154
GDB/MI Variable Objects
155
=======================
156
 
157
Motivation for Variable Objects in GDB/MI
158
-----------------------------------------
159
 
160
   For the implementation of a variable debugger window (locals, watched
161
expressions, etc.), we are proposing the adaptation of the existing code
162
used by `Insight'.
163
 
164
   The two main reasons for that are:
165
 
166
  1. It has been proven in practice (it is already on its second
167
     generation).
168
 
169
  2. It will shorten development time (needless to say how important it
170
     is now).
171
 
172
   The original interface was designed to be used by Tcl code, so it was
173
slightly changed so it could be used through GDB/MI.  This section
174
describes the GDB/MI operations that will be available and gives some
175
hints about their use.
176
 
177
   _Note_: In addition to the set of operations described here, we
178
expect the GUI implementation of a variable window to require, at
179
least, the following operations:
180
 
181
   * `-gdb-show' `output-radix'
182
 
183
   * `-stack-list-arguments'
184
 
185
   * `-stack-list-locals'
186
 
187
   * `-stack-select-frame'
188
 
189
Introduction to Variable Objects in GDB/MI
190
------------------------------------------
191
 
192
   The basic idea behind variable objects is the creation of a named
193
object to represent a variable, an expression, a memory location or
194
even a CPU register.  For each object created, a set of operations is
195
available for examining or changing its properties.
196
 
197
   Furthermore, complex data types, such as C structures, are
198
represented in a tree format.  For instance, the `struct' type variable
199
is the root and the children will represent the struct members.  If a
200
child is itself of a complex type, it will also have children of its
201
own.  Appropriate language differences are handled for C, C++ and Java.
202
 
203
   When returning the actual values of the objects, this facility allows
204
for the individual selection of the display format used in the result
205
creation.  It can be chosen among: binary, decimal, hexadecimal, octal
206
and natural.  Natural refers to a default format automatically chosen
207
based on the variable type (like decimal for an `int', hex for
208
pointers, etc.).
209
 
210
   The following is the complete set of GDB/MI operations defined to
211
access this functionality:
212
 
213
*Operation*                   *Description*
214
`-var-create'                 create a variable object
215
`-var-delete'                 delete the variable object and its children
216
`-var-set-format'             set the display format of this variable
217
`-var-show-format'            show the display format of this variable
218
`-var-info-num-children'      tells how many children this object has
219
`-var-list-children'          return a list of the object's children
220
`-var-info-type'              show the type of this variable object
221
`-var-info-expression'        print what this variable object represents
222
`-var-show-attributes'        is this variable editable? does it exist
223
                              here?
224
`-var-evaluate-expression'    get the value of this variable
225
`-var-assign'                 set the value of this variable
226
`-var-update'                 update the variable and its children
227
 
228
   In the next subsection we describe each operation in detail and
229
suggest how it can be used.
230
 
231
Description And Use of Operations on Variable Objects
232
-----------------------------------------------------
233
 
234
The `-var-create' Command
235
-------------------------
236
 
237
Synopsis
238
........
239
 
240
      -var-create {NAME | "-"}
241
         {FRAME-ADDR | "*"} EXPRESSION
242
 
243
   This operation creates a variable object, which allows the
244
monitoring of a variable, the result of an expression, a memory cell or
245
a CPU register.
246
 
247
   The NAME parameter is the string by which the object can be
248
referenced.  It must be unique.  If `-' is specified, the varobj system
249
will generate a string "varNNNNNN" automatically.  It will be unique
250
provided that one does not specify NAME on that format.  The command
251
fails if a duplicate name is found.
252
 
253
   The frame under which the expression should be evaluated can be
254
specified by FRAME-ADDR.  A `*' indicates that the current frame should
255
be used.
256
 
257
   EXPRESSION is any expression valid on the current language set (must
258
not begin with a `*'), or one of the following:
259
 
260
   * `*ADDR', where ADDR is the address of a memory cell
261
 
262
   * `*ADDR-ADDR' -- a memory address range (TBD)
263
 
264
   * `$REGNAME' -- a CPU register name
265
 
266
Result
267
......
268
 
269
   This operation returns the name, number of children and the type of
270
the object created.  Type is returned as a string as the ones generated
271
by the GDB CLI:
272
 
273
      name="NAME",numchild="N",type="TYPE"
274
 
275
The `-var-delete' Command
276
-------------------------
277
 
278
Synopsis
279
........
280
 
281
      -var-delete NAME
282
 
283
   Deletes a previously created variable object and all of its children.
284
 
285
   Returns an error if the object NAME is not found.
286
 
287
The `-var-set-format' Command
288
-----------------------------
289
 
290
Synopsis
291
........
292
 
293
      -var-set-format NAME FORMAT-SPEC
294
 
295
   Sets the output format for the value of the object NAME to be
296
FORMAT-SPEC.
297
 
298
   The syntax for the FORMAT-SPEC is as follows:
299
 
300
      FORMAT-SPEC ==>
301
      {binary | decimal | hexadecimal | octal | natural}
302
 
303
The `-var-show-format' Command
304
------------------------------
305
 
306
Synopsis
307
........
308
 
309
      -var-show-format NAME
310
 
311
   Returns the format used to display the value of the object NAME.
312
 
313
      FORMAT ==>
314
      FORMAT-SPEC
315
 
316
The `-var-info-num-children' Command
317
------------------------------------
318
 
319
Synopsis
320
........
321
 
322
      -var-info-num-children NAME
323
 
324
   Returns the number of children of a variable object NAME:
325
 
326
      numchild=N
327
 
328
The `-var-list-children' Command
329
--------------------------------
330
 
331
Synopsis
332
........
333
 
334
      -var-list-children NAME
335
 
336
   Returns a list of the children of the specified variable object:
337
 
338
      numchild=N,children={{name=NAME,
339
      numchild=N,type=TYPE},(repeats N times)}
340
 
341
The `-var-info-type' Command
342
----------------------------
343
 
344
Synopsis
345
........
346
 
347
      -var-info-type NAME
348
 
349
   Returns the type of the specified variable NAME.  The type is
350
returned as a string in the same format as it is output by the GDB CLI:
351
 
352
      type=TYPENAME
353
 
354
The `-var-info-expression' Command
355
----------------------------------
356
 
357
Synopsis
358
........
359
 
360
      -var-info-expression NAME
361
 
362
   Returns what is represented by the variable object NAME:
363
 
364
      lang=LANG-SPEC,exp=EXPRESSION
365
 
366
where LANG-SPEC is `{"C" | "C++" | "Java"}'.
367
 
368
The `-var-show-attributes' Command
369
----------------------------------
370
 
371
Synopsis
372
........
373
 
374
      -var-show-attributes NAME
375
 
376
   List attributes of the specified variable object NAME:
377
 
378
      status=ATTR [ ( ,ATTR )* ]
379
 
380
where ATTR is `{ { editable | noneditable } | TBD }'.
381
 
382
The `-var-evaluate-expression' Command
383
--------------------------------------
384
 
385
Synopsis
386
........
387
 
388
      -var-evaluate-expression NAME
389
 
390
   Evaluates the expression that is represented by the specified
391
variable object and returns its value as a string in the current format
392
specified for the object:
393
 
394
      value=VALUE
395
 
396
The `-var-assign' Command
397
-------------------------
398
 
399
Synopsis
400
........
401
 
402
      -var-assign NAME EXPRESSION
403
 
404
   Assigns the value of EXPRESSION to the variable object specified by
405
NAME.  The object must be `editable'.
406
 
407
The `-var-update' Command
408
-------------------------
409
 
410
Synopsis
411
........
412
 
413
      -var-update {NAME | "*"}
414
 
415
   Update the value of the variable object NAME by evaluating its
416
expression after fetching all the new values from memory or registers.
417
A `*' causes all existing variable objects to be updated.
418
 
419

420
File: gdb.info,  Node: GDB Bugs,  Next: Formatting Documentation,  Prev: GDB/MI,  Up: Top
421
 
422
Reporting Bugs in GDB
423
*********************
424
 
425
   Your bug reports play an essential role in making GDB reliable.
426
 
427
   Reporting a bug may help you by bringing a solution to your problem,
428
or it may not.  But in any case the principal function of a bug report
429
is to help the entire community by making the next version of GDB work
430
better.  Bug reports are your contribution to the maintenance of GDB.
431
 
432
   In order for a bug report to serve its purpose, you must include the
433
information that enables us to fix the bug.
434
 
435
* Menu:
436
 
437
* Bug Criteria::                Have you found a bug?
438
* Bug Reporting::               How to report bugs
439
 
440

441
File: gdb.info,  Node: Bug Criteria,  Next: Bug Reporting,  Up: GDB Bugs
442
 
443
Have you found a bug?
444
=====================
445
 
446
   If you are not sure whether you have found a bug, here are some
447
guidelines:
448
 
449
   * If the debugger gets a fatal signal, for any input whatever, that
450
     is a GDB bug.  Reliable debuggers never crash.
451
 
452
   * If GDB produces an error message for valid input, that is a bug.
453
     (Note that if you're cross debugging, the problem may also be
454
     somewhere in the connection to the target.)
455
 
456
   * If GDB does not produce an error message for invalid input, that
457
     is a bug.  However, you should note that your idea of "invalid
458
     input" might be our idea of "an extension" or "support for
459
     traditional practice".
460
 
461
   * If you are an experienced user of debugging tools, your suggestions
462
     for improvement of GDB are welcome in any case.
463
 
464

465
File: gdb.info,  Node: Bug Reporting,  Prev: Bug Criteria,  Up: GDB Bugs
466
 
467
How to report bugs
468
==================
469
 
470
   A number of companies and individuals offer support for GNU products.
471
If you obtained GDB from a support organization, we recommend you
472
contact that organization first.
473
 
474
   You can find contact information for many support companies and
475
individuals in the file `etc/SERVICE' in the GNU Emacs distribution.
476
 
477
   In any event, we also recommend that you submit bug reports for GDB.
478
The prefered method is to submit them directly using GDB's Bugs web
479
page (http://www.gnu.org/software/gdb/bugs/).  Alternatively, the
480
e-mail gateway  can be used.
481
 
482
   *Do not send bug reports to `info-gdb', or to `help-gdb', or to any
483
newsgroups.*  Most users of GDB do not want to receive bug reports.
484
Those that do have arranged to receive `bug-gdb'.
485
 
486
   The mailing list `bug-gdb' has a newsgroup `gnu.gdb.bug' which
487
serves as a repeater.  The mailing list and the newsgroup carry exactly
488
the same messages.  Often people think of posting bug reports to the
489
newsgroup instead of mailing them.  This appears to work, but it has one
490
problem which can be crucial: a newsgroup posting often lacks a mail
491
path back to the sender.  Thus, if we need to ask for more information,
492
we may be unable to reach you.  For this reason, it is better to send
493
bug reports to the mailing list.
494
 
495
   The fundamental principle of reporting bugs usefully is this:
496
*report all the facts*.  If you are not sure whether to state a fact or
497
leave it out, state it!
498
 
499
   Often people omit facts because they think they know what causes the
500
problem and assume that some details do not matter.  Thus, you might
501
assume that the name of the variable you use in an example does not
502
matter.  Well, probably it does not, but one cannot be sure.  Perhaps
503
the bug is a stray memory reference which happens to fetch from the
504
location where that name is stored in memory; perhaps, if the name were
505
different, the contents of that location would fool the debugger into
506
doing the right thing despite the bug.  Play it safe and give a
507
specific, complete example.  That is the easiest thing for you to do,
508
and the most helpful.
509
 
510
   Keep in mind that the purpose of a bug report is to enable us to fix
511
the bug.  It may be that the bug has been reported previously, but
512
neither you nor we can know that unless your bug report is complete and
513
self-contained.
514
 
515
   Sometimes people give a few sketchy facts and ask, "Does this ring a
516
bell?"  Those bug reports are useless, and we urge everyone to _refuse
517
to respond to them_ except to chide the sender to report bugs properly.
518
 
519
   To enable us to fix the bug, you should include all these things:
520
 
521
   * The version of GDB.  GDB announces it if you start with no
522
     arguments; you can also print it at any time using `show version'.
523
 
524
     Without this, we will not know whether there is any point in
525
     looking for the bug in the current version of GDB.
526
 
527
   * The type of machine you are using, and the operating system name
528
     and version number.
529
 
530
   * What compiler (and its version) was used to compile GDB--e.g.
531
     "gcc-2.8.1".
532
 
533
   * What compiler (and its version) was used to compile the program
534
     you are debugging--e.g.  "gcc-2.8.1", or "HP92453-01 A.10.32.03 HP
535
     C Compiler".  For GCC, you can say `gcc --version' to get this
536
     information; for other compilers, see the documentation for those
537
     compilers.
538
 
539
   * The command arguments you gave the compiler to compile your
540
     example and observe the bug.  For example, did you use `-O'?  To
541
     guarantee you will not omit something important, list them all.  A
542
     copy of the Makefile (or the output from make) is sufficient.
543
 
544
     If we were to try to guess the arguments, we would probably guess
545
     wrong and then we might not encounter the bug.
546
 
547
   * A complete input script, and all necessary source files, that will
548
     reproduce the bug.
549
 
550
   * A description of what behavior you observe that you believe is
551
     incorrect.  For example, "It gets a fatal signal."
552
 
553
     Of course, if the bug is that GDB gets a fatal signal, then we
554
     will certainly notice it.  But if the bug is incorrect output, we
555
     might not notice unless it is glaringly wrong.  You might as well
556
     not give us a chance to make a mistake.
557
 
558
     Even if the problem you experience is a fatal signal, you should
559
     still say so explicitly.  Suppose something strange is going on,
560
     such as, your copy of GDB is out of synch, or you have encountered
561
     a bug in the C library on your system.  (This has happened!)  Your
562
     copy might crash and ours would not.  If you told us to expect a
563
     crash, then when ours fails to crash, we would know that the bug
564
     was not happening for us.  If you had not told us to expect a
565
     crash, then we would not be able to draw any conclusion from our
566
     observations.
567
 
568
   * If you wish to suggest changes to the GDB source, send us context
569
     diffs.  If you even discuss something in the GDB source, refer to
570
     it by context, not by line number.
571
 
572
     The line numbers in our development sources will not match those
573
     in your sources.  Your line numbers would convey no useful
574
     information to us.
575
 
576
 
577
   Here are some things that are not necessary:
578
 
579
   * A description of the envelope of the bug.
580
 
581
     Often people who encounter a bug spend a lot of time investigating
582
     which changes to the input file will make the bug go away and which
583
     changes will not affect it.
584
 
585
     This is often time consuming and not very useful, because the way
586
     we will find the bug is by running a single example under the
587
     debugger with breakpoints, not by pure deduction from a series of
588
     examples.  We recommend that you save your time for something else.
589
 
590
     Of course, if you can find a simpler example to report _instead_
591
     of the original one, that is a convenience for us.  Errors in the
592
     output will be easier to spot, running under the debugger will take
593
     less time, and so on.
594
 
595
     However, simplification is not vital; if you do not want to do
596
     this, report the bug anyway and send us the entire test case you
597
     used.
598
 
599
   * A patch for the bug.
600
 
601
     A patch for the bug does help us if it is a good one.  But do not
602
     omit the necessary information, such as the test case, on the
603
     assumption that a patch is all we need.  We might see problems
604
     with your patch and decide to fix the problem another way, or we
605
     might not understand it at all.
606
 
607
     Sometimes with a program as complicated as GDB it is very hard to
608
     construct an example that will make the program follow a certain
609
     path through the code.  If you do not send us the example, we will
610
     not be able to construct one, so we will not be able to verify
611
     that the bug is fixed.
612
 
613
     And if we cannot understand what bug you are trying to fix, or why
614
     your patch should be an improvement, we will not install it.  A
615
     test case will help us to understand.
616
 
617
   * A guess about what the bug is or what it depends on.
618
 
619
     Such guesses are usually wrong.  Even we cannot guess right about
620
     such things without first using the debugger to find the facts.
621
 
622

623
File: gdb.info,  Node: Command Line Editing,  Next: Using History Interactively,  Prev: Formatting Documentation,  Up: Top
624
 
625
Command Line Editing
626
********************
627
 
628
   This chapter describes the basic features of the GNU command line
629
editing interface.
630
 
631
* Menu:
632
 
633
* Introduction and Notation::   Notation used in this text.
634
* Readline Interaction::        The minimum set of commands for editing a line.
635
* Readline Init File::          Customizing Readline from a user's view.
636
* Bindable Readline Commands::  A description of most of the Readline commands
637
                                available for binding
638
* Readline vi Mode::            A short description of how to make Readline
639
                                behave like the vi editor.
640
 
641

642
File: gdb.info,  Node: Introduction and Notation,  Next: Readline Interaction,  Up: Command Line Editing
643
 
644
Introduction to Line Editing
645
============================
646
 
647
   The following paragraphs describe the notation used to represent
648
keystrokes.
649
 
650
   The text  is read as `Control-K' and describes the character
651
produced when the  key is pressed while the Control key is depressed.
652
 
653
   The text  is read as `Meta-K' and describes the character
654
produced when the Meta key (if you have one) is depressed, and the 
655
key is pressed.  The Meta key is labeled  on many keyboards.  On
656
keyboards with two keys labeled  (usually to either side of the
657
space bar), the  on the left side is generally set to work as a
658
Meta key.  The  key on the right may also be configured to work as
659
a Meta key or may be configured as some other modifier, such as a
660
Compose key for typing accented characters.
661
 
662
   If you do not have a Meta or  key, or another key working as a
663
Meta key, the identical keystroke can be generated by typing 
664
first, and then typing .  Either process is known as "metafying" the
665
 key.
666
 
667
   The text  is read as `Meta-Control-k' and describes the
668
character produced by "metafying" .
669
 
670
   In addition, several keys have their own names.  Specifically,
671
, , , , , and  all stand for themselves
672
when seen in this text, or in an init file (*note Readline Init File::).
673
If your keyboard lacks a  key, typing  will produce the
674
desired character.  The  key may be labeled  or  on
675
some keyboards.
676
 
677

678
File: gdb.info,  Node: Readline Interaction,  Next: Readline Init File,  Prev: Introduction and Notation,  Up: Command Line Editing
679
 
680
Readline Interaction
681
====================
682
 
683
   Often during an interactive session you type in a long line of text,
684
only to notice that the first word on the line is misspelled.  The
685
Readline library gives you a set of commands for manipulating the text
686
as you type it in, allowing you to just fix your typo, and not forcing
687
you to retype the majority of the line.  Using these editing commands,
688
you move the cursor to the place that needs correction, and delete or
689
insert the text of the corrections.  Then, when you are satisfied with
690
the line, you simply press .  You do not have to be at the end
691
of the line to press ; the entire line is accepted regardless
692
of the location of the cursor within the line.
693
 
694
* Menu:
695
 
696
* Readline Bare Essentials::    The least you need to know about Readline.
697
* Readline Movement Commands::  Moving about the input line.
698
* Readline Killing Commands::   How to delete text, and how to get it back!
699
* Readline Arguments::          Giving numeric arguments to commands.
700
* Searching::                   Searching through previous lines.
701
 
702

703
File: gdb.info,  Node: Readline Bare Essentials,  Next: Readline Movement Commands,  Up: Readline Interaction
704
 
705
Readline Bare Essentials
706
------------------------
707
 
708
   In order to enter characters into the line, simply type them.  The
709
typed character appears where the cursor was, and then the cursor moves
710
one space to the right.  If you mistype a character, you can use your
711
erase character to back up and delete the mistyped character.
712
 
713
   Sometimes you may mistype a character, and not notice the error
714
until you have typed several other characters.  In that case, you can
715
type  to move the cursor to the left, and then correct your
716
mistake.  Afterwards, you can move the cursor to the right with .
717
 
718
   When you add text in the middle of a line, you will notice that
719
characters to the right of the cursor are `pushed over' to make room
720
for the text that you have inserted.  Likewise, when you delete text
721
behind the cursor, characters to the right of the cursor are `pulled
722
back' to fill in the blank space created by the removal of the text.  A
723
list of the bare essentials for editing the text of an input line
724
follows.
725
 
726
727
     Move back one character.
728
 
729
730
     Move forward one character.
731
 
732
 or 
733
     Delete the character to the left of the cursor.
734
 
735
736
     Delete the character underneath the cursor.
737
 
738
Printing characters
739
     Insert the character into the line at the cursor.
740
 
741
 or 
742
     Undo the last editing command.  You can undo all the way back to an
743
     empty line.
744
 
745
(Depending on your configuration, the  key be set to delete
746
the character to the left of the cursor and the  key set to delete
747
the character underneath the cursor, like , rather than the
748
character to the left of the cursor.)
749
 
750

751
File: gdb.info,  Node: Readline Movement Commands,  Next: Readline Killing Commands,  Prev: Readline Bare Essentials,  Up: Readline Interaction
752
 
753
Readline Movement Commands
754
--------------------------
755
 
756
   The above table describes the most basic keystrokes that you need in
757
order to do editing of the input line.  For your convenience, many
758
other commands have been added in addition to , , , and
759
.  Here are some commands for moving more rapidly about the line.
760
 
761
762
     Move to the start of the line.
763
 
764
765
     Move to the end of the line.
766
 
767
768
     Move forward a word, where a word is composed of letters and
769
     digits.
770
 
771
772
     Move backward a word.
773
 
774
775
     Clear the screen, reprinting the current line at the top.
776
 
777
   Notice how  moves forward a character, while  moves
778
forward a word.  It is a loose convention that control keystrokes
779
operate on characters while meta keystrokes operate on words.
780
 
781

782
File: gdb.info,  Node: Readline Killing Commands,  Next: Readline Arguments,  Prev: Readline Movement Commands,  Up: Readline Interaction
783
 
784
Readline Killing Commands
785
-------------------------
786
 
787
   "Killing" text means to delete the text from the line, but to save
788
it away for later use, usually by "yanking" (re-inserting) it back into
789
the line.  (`Cut' and `paste' are more recent jargon for `kill' and
790
`yank'.)
791
 
792
   If the description for a command says that it `kills' text, then you
793
can be sure that you can get the text back in a different (or the same)
794
place later.
795
 
796
   When you use a kill command, the text is saved in a "kill-ring".
797
Any number of consecutive kills save all of the killed text together, so
798
that when you yank it back, you get it all.  The kill ring is not line
799
specific; the text that you killed on a previously typed line is
800
available to be yanked back later, when you are typing another line.
801
 
802
   Here is the list of commands for killing text.
803
 
804
805
     Kill the text from the current cursor position to the end of the
806
     line.
807
 
808
809
     Kill from the cursor to the end of the current word, or, if between
810
     words, to the end of the next word.  Word boundaries are the same
811
     as those used by .
812
 
813
814
     Kill from the cursor the start of the previous word, or, if between
815
     words, to the start of the previous word.  Word boundaries are the
816
     same as those used by .
817
 
818
819
     Kill from the cursor to the previous whitespace.  This is
820
     different than  because the word boundaries differ.
821
 
822
   Here is how to "yank" the text back into the line.  Yanking means to
823
copy the most-recently-killed text from the kill buffer.
824
 
825
826
     Yank the most recently killed text back into the buffer at the
827
     cursor.
828
 
829
830
     Rotate the kill-ring, and yank the new top.  You can only do this
831
     if the prior command is  or .
832
 
833

834
File: gdb.info,  Node: Readline Arguments,  Next: Searching,  Prev: Readline Killing Commands,  Up: Readline Interaction
835
 
836
Readline Arguments
837
------------------
838
 
839
   You can pass numeric arguments to Readline commands.  Sometimes the
840
argument acts as a repeat count, other times it is the sign of the
841
argument that is significant.  If you pass a negative argument to a
842
command which normally acts in a forward direction, that command will
843
act in a backward direction.  For example, to kill text back to the
844
start of the line, you might type `M-- C-k'.
845
 
846
   The general way to pass numeric arguments to a command is to type
847
meta digits before the command.  If the first `digit' typed is a minus
848
sign (`-'), then the sign of the argument will be negative.  Once you
849
have typed one meta digit to get the argument started, you can type the
850
remainder of the digits, and then the command.  For example, to give
851
the  command an argument of 10, you could type `M-1 0 C-d'.
852
 
853

854
File: gdb.info,  Node: Searching,  Prev: Readline Arguments,  Up: Readline Interaction
855
 
856
Searching for Commands in the History
857
-------------------------------------
858
 
859
   Readline provides commands for searching through the command history
860
for lines containing a specified string.  There are two search modes:
861
INCREMENTAL and NON-INCREMENTAL.
862
 
863
   Incremental searches begin before the user has finished typing the
864
search string.  As each character of the search string is typed,
865
Readline displays the next entry from the history matching the string
866
typed so far.  An incremental search requires only as many characters
867
as needed to find the desired history entry.  To search backward in the
868
history for a particular string, type .  Typing  searches
869
forward through the history.  The characters present in the value of
870
the `isearch-terminators' variable are used to terminate an incremental
871
search.  If that variable has not been assigned a value, the  and
872
 characters will terminate an incremental search.   will
873
abort an incremental search and restore the original line.  When the
874
search is terminated, the history entry containing the search string
875
becomes the current line.
876
 
877
   To find other matching entries in the history list, type  or
878
 as appropriate.  This will search backward or forward in the
879
history for the next entry matching the search string typed so far.
880
Any other key sequence bound to a Readline command will terminate the
881
search and execute that command.  For instance, a  will terminate
882
the search and accept the line, thereby executing the command from the
883
history list.
884
 
885
   Non-incremental searches read the entire search string before
886
starting to search for matching history lines.  The search string may be
887
typed by the user or be part of the contents of the current line.
888
 
889

890
File: gdb.info,  Node: Readline Init File,  Next: Bindable Readline Commands,  Prev: Readline Interaction,  Up: Command Line Editing
891
 
892
Readline Init File
893
==================
894
 
895
   Although the Readline library comes with a set of Emacs-like
896
keybindings installed by default, it is possible to use a different set
897
of keybindings.  Any user can customize programs that use Readline by
898
putting commands in an "inputrc" file, conventionally in his home
899
directory.  The name of this file is taken from the value of the
900
environment variable `INPUTRC'.  If that variable is unset, the default
901
is `~/.inputrc'.
902
 
903
   When a program which uses the Readline library starts up, the init
904
file is read, and the key bindings are set.
905
 
906
   In addition, the `C-x C-r' command re-reads this init file, thus
907
incorporating any changes that you might have made to it.
908
 
909
* Menu:
910
 
911
* Readline Init File Syntax::   Syntax for the commands in the inputrc file.
912
 
913
* Conditional Init Constructs:: Conditional key bindings in the inputrc file.
914
 
915
* Sample Init File::            An example inputrc file.
916
 
917

918
File: gdb.info,  Node: Readline Init File Syntax,  Next: Conditional Init Constructs,  Up: Readline Init File
919
 
920
Readline Init File Syntax
921
-------------------------
922
 
923
   There are only a few basic constructs allowed in the Readline init
924
file.  Blank lines are ignored.  Lines beginning with a `#' are
925
comments.  Lines beginning with a `$' indicate conditional constructs
926
(*note Conditional Init Constructs::).  Other lines denote variable
927
settings and key bindings.
928
 
929
Variable Settings
930
     You can modify the run-time behavior of Readline by altering the
931
     values of variables in Readline using the `set' command within the
932
     init file.  Here is how to change from the default Emacs-like key
933
     binding to use `vi' line editing commands:
934
 
935
          set editing-mode vi
936
 
937
     A great deal of run-time behavior is changeable with the following
938
     variables.
939
 
940
    `bell-style'
941
          Controls what happens when Readline wants to ring the
942
          terminal bell.  If set to `none', Readline never rings the
943
          bell.  If set to `visible', Readline uses a visible bell if
944
          one is available.  If set to `audible' (the default),
945
          Readline attempts to ring the terminal's bell.
946
 
947
    `comment-begin'
948
          The string to insert at the beginning of the line when the
949
          `insert-comment' command is executed.  The default value is
950
          `"#"'.
951
 
952
    `completion-ignore-case'
953
          If set to `on', Readline performs filename matching and
954
          completion in a case-insensitive fashion.  The default value
955
          is `off'.
956
 
957
    `completion-query-items'
958
          The number of possible completions that determines when the
959
          user is asked whether he wants to see the list of
960
          possibilities.  If the number of possible completions is
961
          greater than this value, Readline will ask the user whether
962
          or not he wishes to view them; otherwise, they are simply
963
          listed.  The default limit is `100'.
964
 
965
    `convert-meta'
966
          If set to `on', Readline will convert characters with the
967
          eighth bit set to an ASCII key sequence by stripping the
968
          eighth bit and prefixing an  character, converting them
969
          to a meta-prefixed key sequence.  The default value is `on'.
970
 
971
    `disable-completion'
972
          If set to `On', Readline will inhibit word completion.
973
          Completion  characters will be inserted into the line as if
974
          they had been mapped to `self-insert'.  The default is `off'.
975
 
976
    `editing-mode'
977
          The `editing-mode' variable controls which default set of key
978
          bindings is used.  By default, Readline starts up in Emacs
979
          editing mode, where the keystrokes are most similar to Emacs.
980
          This variable can be set to either `emacs' or `vi'.
981
 
982
    `enable-keypad'
983
          When set to `on', Readline will try to enable the application
984
          keypad when it is called.  Some systems need this to enable
985
          the arrow keys.  The default is `off'.
986
 
987
    `expand-tilde'
988
          If set to `on', tilde expansion is performed when Readline
989
          attempts word completion.  The default is `off'.
990
 
991
    `horizontal-scroll-mode'
992
          This variable can be set to either `on' or `off'.  Setting it
993
          to `on' means that the text of the lines being edited will
994
          scroll horizontally on a single screen line when they are
995
          longer than the width of the screen, instead of wrapping onto
996
          a new screen line.  By default, this variable is set to `off'.
997
 
998
    `input-meta'
999
          If set to `on', Readline will enable eight-bit input (it will
1000
          not strip the eighth bit from the characters it reads),
1001
          regardless of what the terminal claims it can support.  The
1002
          default value is `off'.  The name `meta-flag' is a synonym
1003
          for this variable.
1004
 
1005
    `isearch-terminators'
1006
          The string of characters that should terminate an incremental
1007
          search without subsequently executing the character as a
1008
          command (*note Searching::).  If this variable has not been
1009
          given a value, the characters  and  will terminate
1010
          an incremental search.
1011
 
1012
    `keymap'
1013
          Sets Readline's idea of the current keymap for key binding
1014
          commands.  Acceptable `keymap' names are `emacs',
1015
          `emacs-standard', `emacs-meta', `emacs-ctlx', `vi',
1016
          `vi-command', and `vi-insert'.  `vi' is equivalent to
1017
          `vi-command'; `emacs' is equivalent to `emacs-standard'.  The
1018
          default value is `emacs'.  The value of the `editing-mode'
1019
          variable also affects the default keymap.
1020
 
1021
    `mark-directories'
1022
          If set to `on', completed directory names have a slash
1023
          appended.  The default is `on'.
1024
 
1025
    `mark-modified-lines'
1026
          This variable, when set to `on', causes Readline to display an
1027
          asterisk (`*') at the start of history lines which have been
1028
          modified.  This variable is `off' by default.
1029
 
1030
    `output-meta'
1031
          If set to `on', Readline will display characters with the
1032
          eighth bit set directly rather than as a meta-prefixed escape
1033
          sequence.  The default is `off'.
1034
 
1035
    `print-completions-horizontally'
1036
          If set to `on', Readline will display completions with matches
1037
          sorted horizontally in alphabetical order, rather than down
1038
          the screen.  The default is `off'.
1039
 
1040
    `show-all-if-ambiguous'
1041
          This alters the default behavior of the completion functions.
1042
          If set to `on', words which have more than one possible
1043
          completion cause the matches to be listed immediately instead
1044
          of ringing the bell.  The default value is `off'.
1045
 
1046
    `visible-stats'
1047
          If set to `on', a character denoting a file's type is
1048
          appended to the filename when listing possible completions.
1049
          The default is `off'.
1050
 
1051
Key Bindings
1052
     The syntax for controlling key bindings in the init file is
1053
     simple.  First you need to find the name of the command that you
1054
     want to change.  The following sections contain tables of the
1055
     command name, the default keybinding, if any, and a short
1056
     description of what the command does.
1057
 
1058
     Once you know the name of the command, simply place the name of
1059
     the key you wish to bind the command to, a colon, and then the
1060
     name of the command on a line in the init file.  The name of the
1061
     key can be expressed in different ways, depending on which is most
1062
     comfortable for you.
1063
 
1064
    KEYNAME: FUNCTION-NAME or MACRO
1065
          KEYNAME is the name of a key spelled out in English.  For
1066
          example:
1067
               Control-u: universal-argument
1068
               Meta-Rubout: backward-kill-word
1069
               Control-o: "> output"
1070
 
1071
          In the above example,  is bound to the function
1072
          `universal-argument', and  is bound to run the macro
1073
          expressed on the right hand side (that is, to insert the text
1074
          `> output' into the line).
1075
 
1076
    "KEYSEQ": FUNCTION-NAME or MACRO
1077
          KEYSEQ differs from KEYNAME above in that strings denoting an
1078
          entire key sequence can be specified, by placing the key
1079
          sequence in double quotes.  Some GNU Emacs style key escapes
1080
          can be used, as in the following example, but the special
1081
          character names are not recognized.
1082
 
1083
               "\C-u": universal-argument
1084
               "\C-x\C-r": re-read-init-file
1085
               "\e[11~": "Function Key 1"
1086
 
1087
          In the above example,  is bound to the function
1088
          `universal-argument' (just as it was in the first example),
1089
          ` ' is bound to the function `re-read-init-file',
1090
          and ` <[> <1> <1> <~>' is bound to insert the text
1091
          `Function Key 1'.
1092
 
1093
     The following GNU Emacs style escape sequences are available when
1094
     specifying key sequences:
1095
 
1096
    `\C-'
1097
          control prefix
1098
 
1099
    `\M-'
1100
          meta prefix
1101
 
1102
    `\e'
1103
          an escape character
1104
 
1105
    `\\'
1106
          backslash
1107
 
1108
    `\"'
1109
          <">, a double quotation mark
1110
 
1111
    `\''
1112
          <'>, a single quote or apostrophe
1113
 
1114
     In addition to the GNU Emacs style escape sequences, a second set
1115
     of backslash escapes is available:
1116
 
1117
    `\a'
1118
          alert (bell)
1119
 
1120
    `\b'
1121
          backspace
1122
 
1123
    `\d'
1124
          delete
1125
 
1126
    `\f'
1127
          form feed
1128
 
1129
    `\n'
1130
          newline
1131
 
1132
    `\r'
1133
          carriage return
1134
 
1135
    `\t'
1136
          horizontal tab
1137
 
1138
    `\v'
1139
          vertical tab
1140
 
1141
    `\NNN'
1142
          the character whose `ASCII' code is the octal value NNN (one
1143
          to three digits)
1144
 
1145
    `\xNNN'
1146
          the character whose `ASCII' code is the hexadecimal value NNN
1147
          (one to three digits)
1148
 
1149
     When entering the text of a macro, single or double quotes must be
1150
     used to indicate a macro definition.  Unquoted text is assumed to
1151
     be a function name.  In the macro body, the backslash escapes
1152
     described above are expanded.  Backslash will quote any other
1153
     character in the macro text, including `"' and `''.  For example,
1154
     the following binding will make `C-x \' insert a single `\' into
1155
     the line:
1156
          "\C-x\\": "\\"
1157
 
1158

1159
File: gdb.info,  Node: Conditional Init Constructs,  Next: Sample Init File,  Prev: Readline Init File Syntax,  Up: Readline Init File
1160
 
1161
Conditional Init Constructs
1162
---------------------------
1163
 
1164
   Readline implements a facility similar in spirit to the conditional
1165
compilation features of the C preprocessor which allows key bindings
1166
and variable settings to be performed as the result of tests.  There
1167
are four parser directives used.
1168
 
1169
`$if'
1170
     The `$if' construct allows bindings to be made based on the
1171
     editing mode, the terminal being used, or the application using
1172
     Readline.  The text of the test extends to the end of the line; no
1173
     characters are required to isolate it.
1174
 
1175
    `mode'
1176
          The `mode=' form of the `$if' directive is used to test
1177
          whether Readline is in `emacs' or `vi' mode.  This may be
1178
          used in conjunction with the `set keymap' command, for
1179
          instance, to set bindings in the `emacs-standard' and
1180
          `emacs-ctlx' keymaps only if Readline is starting out in
1181
          `emacs' mode.
1182
 
1183
    `term'
1184
          The `term=' form may be used to include terminal-specific key
1185
          bindings, perhaps to bind the key sequences output by the
1186
          terminal's function keys.  The word on the right side of the
1187
          `=' is tested against both the full name of the terminal and
1188
          the portion of the terminal name before the first `-'.  This
1189
          allows `sun' to match both `sun' and `sun-cmd', for instance.
1190
 
1191
    `application'
1192
          The APPLICATION construct is used to include
1193
          application-specific settings.  Each program using the
1194
          Readline library sets the APPLICATION NAME, and you can test
1195
          for it.  This could be used to bind key sequences to
1196
          functions useful for a specific program.  For instance, the
1197
          following command adds a key sequence that quotes the current
1198
          or previous word in Bash:
1199
               $if Bash
1200
               # Quote the current or previous word
1201
               "\C-xq": "\eb\"\ef\""
1202
               $endif
1203
 
1204
`$endif'
1205
     This command, as seen in the previous example, terminates an `$if'
1206
     command.
1207
 
1208
`$else'
1209
     Commands in this branch of the `$if' directive are executed if the
1210
     test fails.
1211
 
1212
`$include'
1213
     This directive takes a single filename as an argument and reads
1214
     commands and bindings from that file.
1215
          $include /etc/inputrc
1216
 
1217

1218
File: gdb.info,  Node: Sample Init File,  Prev: Conditional Init Constructs,  Up: Readline Init File
1219
 
1220
Sample Init File
1221
----------------
1222
 
1223
   Here is an example of an inputrc file.  This illustrates key
1224
binding, variable assignment, and conditional syntax.
1225
 
1226
 
1227
     # This file controls the behaviour of line input editing for
1228
     # programs that use the Gnu Readline library.  Existing programs
1229
     # include FTP, Bash, and Gdb.
1230
     #
1231
     # You can re-read the inputrc file with C-x C-r.
1232
     # Lines beginning with '#' are comments.
1233
     #
1234
     # First, include any systemwide bindings and variable assignments from
1235
     # /etc/Inputrc
1236
     $include /etc/Inputrc
1237
 
1238
     #
1239
     # Set various bindings for emacs mode.
1240
 
1241
     set editing-mode emacs
1242
 
1243
     $if mode=emacs
1244
 
1245
     Meta-Control-h:    backward-kill-word      Text after the function name is ignored
1246
 
1247
     #
1248
     # Arrow keys in keypad mode
1249
     #
1250
     #"\M-OD":        backward-char
1251
     #"\M-OC":        forward-char
1252
     #"\M-OA":        previous-history
1253
     #"\M-OB":        next-history
1254
     #
1255
     # Arrow keys in ANSI mode
1256
     #
1257
     "\M-[D":        backward-char
1258
     "\M-[C":        forward-char
1259
     "\M-[A":        previous-history
1260
     "\M-[B":        next-history
1261
     #
1262
     # Arrow keys in 8 bit keypad mode
1263
     #
1264
     #"\M-\C-OD":       backward-char
1265
     #"\M-\C-OC":       forward-char
1266
     #"\M-\C-OA":       previous-history
1267
     #"\M-\C-OB":       next-history
1268
     #
1269
     # Arrow keys in 8 bit ANSI mode
1270
     #
1271
     #"\M-\C-[D":       backward-char
1272
     #"\M-\C-[C":       forward-char
1273
     #"\M-\C-[A":       previous-history
1274
     #"\M-\C-[B":       next-history
1275
 
1276
     C-q: quoted-insert
1277
 
1278
     $endif
1279
 
1280
     # An old-style binding.  This happens to be the default.
1281
     TAB: complete
1282
 
1283
     # Macros that are convenient for shell interaction
1284
     $if Bash
1285
     # edit the path
1286
     "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
1287
     # prepare to type a quoted word -- insert open and close
1288
     # double quotes and move to just after the open quote
1289
     "\C-x\"": "\"\"\C-b"
1290
     # insert a backslash (testing backslash escapes in sequences
1291
     # and macros)
1292
     "\C-x\\": "\\"
1293
     # Quote the current or previous word
1294
     "\C-xq": "\eb\"\ef\""
1295
     # Add a binding to refresh the line, which is unbound
1296
     "\C-xr": redraw-current-line
1297
     # Edit variable on current line.
1298
     "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y="
1299
     $endif
1300
 
1301
     # use a visible bell if one is available
1302
     set bell-style visible
1303
 
1304
     # don't strip characters to 7 bits when reading
1305
     set input-meta on
1306
 
1307
     # allow iso-latin1 characters to be inserted rather than converted to
1308
     # prefix-meta sequences
1309
     set convert-meta off
1310
 
1311
     # display characters with the eighth bit set directly rather than
1312
     # as meta-prefixed characters
1313
     set output-meta on
1314
 
1315
     # if there are more than 150 possible completions for a word, ask the
1316
     # user if he wants to see all of them
1317
     set completion-query-items 150
1318
 
1319
     # For FTP
1320
     $if Ftp
1321
     "\C-xg": "get \M-?"
1322
     "\C-xt": "put \M-?"
1323
     "\M-.": yank-last-arg
1324
     $endif
1325
 
1326

1327
File: gdb.info,  Node: Bindable Readline Commands,  Next: Readline vi Mode,  Prev: Readline Init File,  Up: Command Line Editing
1328
 
1329
Bindable Readline Commands
1330
==========================
1331
 
1332
* Menu:
1333
 
1334
* Commands For Moving::         Moving about the line.
1335
* Commands For History::        Getting at previous lines.
1336
* Commands For Text::           Commands for changing text.
1337
* Commands For Killing::        Commands for killing and yanking.
1338
* Numeric Arguments::           Specifying numeric arguments, repeat counts.
1339
* Commands For Completion::     Getting Readline to do the typing for you.
1340
* Keyboard Macros::             Saving and re-executing typed characters
1341
* Miscellaneous Commands::      Other miscellaneous commands.
1342
 
1343
   This section describes Readline commands that may be bound to key
1344
sequences.
1345
 
1346
   Command names without an accompanying key sequence are unbound by
1347
default.  In the following descriptions, POINT refers to the current
1348
cursor position, and MARK refers to a cursor position saved by the
1349
`set-mark' command.  The text between the point and mark is referred to
1350
as the REGION.
1351
 
1352

1353
File: gdb.info,  Node: Commands For Moving,  Next: Commands For History,  Up: Bindable Readline Commands
1354
 
1355
Commands For Moving
1356
-------------------
1357
 
1358
`beginning-of-line (C-a)'
1359
     Move to the start of the current line.
1360
 
1361
`end-of-line (C-e)'
1362
     Move to the end of the line.
1363
 
1364
`forward-char (C-f)'
1365
     Move forward a character.
1366
 
1367
`backward-char (C-b)'
1368
     Move back a character.
1369
 
1370
`forward-word (M-f)'
1371
     Move forward to the end of the next word.  Words are composed of
1372
     letters and digits.
1373
 
1374
`backward-word (M-b)'
1375
     Move back to the start of the current or previous word.  Words are
1376
     composed of letters and digits.
1377
 
1378
`clear-screen (C-l)'
1379
     Clear the screen and redraw the current line, leaving the current
1380
     line at the top of the screen.
1381
 
1382
`redraw-current-line ()'
1383
     Refresh the current line.  By default, this is unbound.
1384
 

powered by: WebSVN 2.1.0

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