source: rtems-docs/shell/memory_commands.rst @ f15d607

4.115
Last change on this file since f15d607 was f15d607, checked in by Chris Johns <chrisj@…>, on 11/09/16 at 00:50:31

shell: Fix header levels.

  • Property mode set to 100644
File size: 18.0 KB
Line 
1.. comment SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. COMMENT: COPYRIGHT (c) 1988-2008.
4.. COMMENT: On-Line Applications Research Corporation (OAR).
5.. COMMENT: All rights reserved.
6
7Memory Commands
8***************
9
10Introduction
11============
12
13The RTEMS shell has the following memory commands:
14
15- mdump_ - Display contents of memory
16
17- wdump_ - Display contents of memory (word)
18
19- ldump_ - Display contents of memory (longword)
20
21- medit_ - Modify contents of memory
22
23- mfill_ - File memory with pattern
24
25- mmove_ - Move contents of memory
26
27- malloc_ - Obtain information on C Program Heap
28
29Commands
30========
31
32This section details the Memory Commands available.  A
33subsection is dedicated to each of the commands and
34describes the behavior and configuration of that
35command as well as providing an example usage.
36
37.. raw:: latex
38
39   \clearpage
40
41.. _mdump:
42
43mdump - display contents of memory
44----------------------------------
45.. index:: mdump
46
47SYNOPSYS:
48    .. code-block:: shell
49
50        mdump [address [length [size]]]
51
52DESCRIPTION:
53    This command displays the contents of memory at the ``address`` and
54    ``length`` in ``size`` byte units specified on the command line.
55
56    When ``size`` is not provided, it defaults to ``1`` byte units.  Values of
57    ``1``, ``2``, and ``4`` are valid; all others will cause an error to be
58    reported.
59
60    When ``length`` is not provided, it defaults to ``320`` which is twenty
61    lines of output with sixteen bytes of output per line.
62
63    When ``address`` is not provided, it defaults to ``0x00000000``.
64
65EXIT STATUS:
66    This command always returns 0 to indicate success.
67
68NOTES:
69    Dumping memory from a non-existent address may result in an unrecoverable
70    program fault.
71
72EXAMPLES:
73    The following is an example of how to use ``mdump``:
74
75    .. code-block:: shell
76
77        SHLL [/] $ mdump 0x10000 32
78        0x0001000000 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
79        0x0001001000 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
80        SHLL [/] $ mdump 0x02000000 32
81        0x02000000A1 48 00 00 29 00 80 33-81 C5 22 BC A6 10 21 00 .H..)..3.."...!.
82        0x02000010A1 48 00 00 29 00 80 33-81 C5 22 BC A6 10 21 01 .H..)..3.."...!.
83        SHLL [/] $ mdump 0x02001000 32
84        0x0200100003 00 80 00 82 10 60 00-81 98 40 00 83 48 00 00 ......`.....H..
85        0x0200101084 00 60 01 84 08 A0 07-86 10 20 01 87 28 C0 02 ..`....... ..(..
86
87.. index:: CONFIGURE_SHELL_NO_COMMAND_MDUMP
88.. index:: CONFIGURE_SHELL_COMMAND_MDUMP
89
90CONFIGURATION:
91    This command is included in the default shell command set.  When building a
92    custom command set, define ``CONFIGURE_SHELL_COMMAND_MDUMP`` to have this
93    command included.
94
95    This command can be excluded from the shell command set by defining
96    ``CONFIGURE_SHELL_NO_COMMAND_MDUMP`` when all shell commands have been
97    configured.
98
99.. index:: rtems_shell_rtems_main_mdump
100
101PROGRAMMING INFORMATION:
102    The ``mdump`` is implemented by a C language function which has the
103    following prototype:
104
105    .. code-block:: c
106
107        int rtems_shell_rtems_main_mdump(
108            int    argc,
109            char **argv
110        );
111
112    The configuration structure for the ``mdump`` has the following prototype:
113
114    .. code-block:: c
115
116        extern rtems_shell_cmd_t rtems_shell_MDUMP_Command;
117
118.. raw:: latex
119
120   \clearpage
121
122.. _wdump:
123
124wdump - display contents of memory (word)
125-----------------------------------------
126.. index:: wdump
127
128SYNOPSYS:
129    .. code-block:: shell
130
131        wdump [address [length]]
132
133DESCRIPTION:
134    This command displays the contents of memory at the ``address`` and
135    ``length`` in bytes specified on the command line.
136
137    This command is equivalent to ``mdump address length 2``.
138
139    When ``length`` is not provided, it defaults to ``320`` which is twenty
140    lines of output with eight words of output per line.
141
142    When ``address`` is not provided, it defaults to ``0x00000000``.
143
144EXIT STATUS:
145    This command always returns 0 to indicate success.
146
147NOTES:
148    Dumping memory from a non-existent address may result in an unrecoverable
149    program fault.
150
151EXAMPLES:
152    The following is an example of how to use ``wdump``:
153
154    .. code-block:: shell
155
156        SHLL [/] $ wdump 0x02010000 32
157        0x02010000 0201 08D8 0201 08C0-0201 08AC 0201 0874 ...............t
158        0x02010010 0201 0894 0201 0718-0201 0640 0201 0798 ...............
159
160.. index:: CONFIGURE_SHELL_NO_COMMAND_WDUMP
161.. index:: CONFIGURE_SHELL_COMMAND_WDUMP
162
163CONFIGURATION:
164    This command is included in the default shell command set.  When building a
165    custom command set, define ``CONFIGURE_SHELL_COMMAND_WDUMP`` to have this
166    command included.
167
168    This command can be excluded from the shell command set by defining
169    ``CONFIGURE_SHELL_NO_COMMAND_WDUMP`` when all shell commands have been
170    configured.
171
172.. index:: rtems_shell_rtems_main_wdump
173
174PROGRAMMING INFORMATION:
175    The ``wdump`` is implemented by a C language function which has the
176    following prototype:
177
178    .. code-block:: c
179
180        int rtems_shell_rtems_main_wdump(
181            int    argc,
182            char **argv
183        );
184
185    The configuration structure for the ``wdump`` has the following prototype:
186
187    .. code-block:: c
188
189        extern rtems_shell_cmd_t rtems_shell_WDUMP_Command;
190
191.. raw:: latex
192
193   \clearpage
194
195.. _ldump:
196
197ldump - display contents of memory (longword)
198---------------------------------------------
199.. index:: ldump
200
201SYNOPSYS:
202    .. code-block:: shell
203
204        ldump [address [length]]
205
206DESCRIPTION:
207    This command displays the contents of memory at the ``address`` and
208    ``length`` in bytes specified on the command line.
209
210    This command is equivalent to ``mdump address length 4``.
211
212    When ``length`` is not provided, it defaults to ``320`` which is twenty
213    lines of output with four longwords of output per line.
214
215    When ``address`` is not provided, it defaults to ``0x00000000``.
216
217EXIT STATUS:
218    This command always returns 0 to indicate success.
219
220NOTES:
221    Dumping memory from a non-existent address may result in an unrecoverable
222    program fault.
223
224EXAMPLES:
225    The following is an example of how to use ``ldump``:
226
227    .. code-block:: shell
228
229        SHLL [/] $ ldump 0x02010000 32
230        0x02010000 020108D8 020108C0-020108AC 02010874 ...............t
231        0x02010010 020 0894 02010718-02010640 02010798 ...............
232
233.. index:: CONFIGURE_SHELL_NO_COMMAND_LDUMP
234.. index:: CONFIGURE_SHELL_COMMAND_LDUMP
235
236CONFIGURATION:
237    This command is included in the default shell command set.  When building a
238    custom command set, define ``CONFIGURE_SHELL_COMMAND_LDUMP`` to have this
239    command included.
240
241    This command can be excluded from the shell command set by defining
242    ``CONFIGURE_SHELL_NO_COMMAND_LDUMP`` when all shell commands have been
243    configured.
244
245.. index:: rtems_shell_rtems_main_ldump
246
247PROGRAMMING INFORMATION:
248    The ``ldump`` is implemented by a C language function which has the following
249    prototype:
250
251    .. code-block:: c
252
253        int rtems_shell_rtems_main_ldump(
254            int    argc,
255            char **argv
256        );
257
258    The configuration structure for the ``ldump`` has the following prototype:
259
260    .. code-block:: c
261
262        extern rtems_shell_cmd_t rtems_shell_LDUMP_Command;
263
264.. raw:: latex
265
266   \clearpage
267
268.. _medit:
269
270medit - modify contents of memory
271---------------------------------
272.. index:: medit
273
274SYNOPSYS:
275    .. code-block:: shell
276
277        medit address value1 [value2 ... valueN]
278
279DESCRIPTION:
280    This command is used to modify the contents of the memory starting at
281    ``address`` using the octets specified by the parameters``value1`` through
282    ``valueN``.
283
284EXIT STATUS:
285    This command returns 0 on success and non-zero if an error is encountered.
286
287NOTES:
288    Dumping memory from a non-existent address may result in an unrecoverable
289    program fault.
290
291EXAMPLES:
292    The following is an example of how to use ``medit``:
293
294    .. code-block:: shell
295
296        SHLL [/] $ mdump 0x02000000 32
297        0x02000000 A1 48 00 00 29 00 80 33-81 C5 22 BC A6 10 21 00 .H..)..3.."...!.
298        0x02000010 A1 48 00 00 29 00 80 33-81 C5 22 BC A6 10 21 01 .H..)..3.."...!.
299        SHLL [/] $  medit 0x02000000 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09
300        SHLL [/] $ mdump 0x02000000 32
301        0x02000000 01 02 03 04 05 06 07 08-09 00 22 BC A6 10 21 00 .........."...!.
302        0x02000010 A1 48 00 00 29 00 80 33-81 C5 22 BC A6 10 21 01 .H..)..3.."...!.
303
304.. index:: CONFIGURE_SHELL_NO_COMMAND_MEDIT
305.. index:: CONFIGURE_SHELL_COMMAND_MEDIT
306
307CONFIGURATION:
308    This command is included in the default shell command set.  When building a
309    custom command set, define ``CONFIGURE_SHELL_COMMAND_MEDIT`` to have this
310    command included.
311
312    This command can be excluded from the shell command set by defining
313    ``CONFIGURE_SHELL_NO_COMMAND_MEDIT`` when all shell commands have been
314    configured.
315
316.. index:: rtems_shell_rtems_main_medit
317
318PROGRAMMING INFORMATION:
319    The ``medit`` is implemented by a C language function which has the
320    following prototype:
321
322    .. code-block:: c
323
324        int rtems_shell_rtems_main_medit(
325            int    argc,
326            char **argv
327        );
328
329    The configuration structure for the ``medit`` has the following prototype:
330
331    .. code-block:: c
332
333        extern rtems_shell_cmd_t rtems_shell_MEDIT_Command;
334
335.. raw:: latex
336
337   \clearpage
338
339.. _mfill:
340
341mfill - file memory with pattern
342--------------------------------
343.. index:: mfill
344
345SYNOPSYS:
346    .. code-block:: shell
347
348        mfill address length value
349
350DESCRIPTION:
351    This command is used to fill the memory starting at ``address`` for the
352    specified ``length`` in octets when the specified at``value``.
353
354EXIT STATUS:
355    This command returns 0 on success and non-zero if an error is encountered.
356
357NOTES:
358    Filling a non-existent address range may result in an unrecoverable program
359    fault.  Similarly overwriting interrupt vector tables, code space or
360    critical data areas can be fatal as shown in the example.
361
362EXAMPLES:
363    In this example, the address used (``0x23d89a0``) as the base address of
364    the filled area is the end of the stack for the Idle thread.  This address
365    was determined manually using gdb and is very specific to this application
366    and BSP.  The first command in this example is an ``mdump`` to display the
367    initial contents of this memory.  We see that the first 8 bytes are 0xA5
368    which is the pattern used as a guard by the Stack Checker.  On the first
369    context switch after the pattern is overwritten by the ``mfill`` command,
370    the Stack Checker detect the pattern has been corrupted and generates a
371    fatal error.
372
373    .. code-block:: shell
374
375        SHLL [/] $ mdump 0x23d89a0 16
376        0x023D89A0 A5 A5 A5 A5 A5 A5 A5 A5-FE ED F0 0D 0B AD 0D 06 ................
377        SHLL [/] $ mfill 0x23d89a0 13 0x5a
378        SHLL [/] $ BLOWN STACK!!! Offending task(0x23D4418): id=0x09010001; name=0x0203D908
379        stack covers range 0x23D89A0 - 0x23D99AF (4112 bytes)
380        Damaged pattern begins at 0x023D89A8 and is 16 bytes long
381
382.. index:: CONFIGURE_SHELL_NO_COMMAND_MFILL
383.. index:: CONFIGURE_SHELL_COMMAND_MFILL
384
385CONFIGURATION:
386    This command is included in the default shell command set.  When building a
387    custom command set, define ``CONFIGURE_SHELL_COMMAND_MFILL`` to have this
388    command included.
389
390    This command can be excluded from the shell command set by defining
391    ``CONFIGURE_SHELL_NO_COMMAND_MFILL`` when all shell commands have been
392    configured.
393
394.. index:: rtems_shell_rtems_main_mfill
395
396PROGRAMMING INFORMATION:
397    The ``mfill`` is implemented by a C language function which has the
398    following prototype:
399
400    .. code-block:: c
401
402        int rtems_shell_rtems_main_mfill(
403            int    argc,
404            char **argv
405        );
406
407    The configuration structure for the ``mfill`` has the
408    following prototype:
409
410    .. code-block:: c
411
412        extern rtems_shell_cmd_t rtems_shell_MFILL_Command;
413
414.. raw:: latex
415
416   \clearpage
417
418.. _mmove:
419
420mmove - move contents of memory
421-------------------------------
422.. index:: mmove
423
424SYNOPSYS:
425    .. code-block:: shell
426
427        mmove dst src length
428
429DESCRIPTION:
430    This command is used to copy the contents of the memory starting at ``src``
431    to the memory located at ``dst`` for the specified ``length`` in octets.
432
433EXIT STATUS:
434    This command returns 0 on success and non-zero if an error is encountered.
435
436NOTES:
437    NONE
438
439EXAMPLES:
440    The following is an example of how to use ``mmove``:
441
442    .. code-block:: shell
443
444        SHLL [/] $ mdump 0x023d99a0 16
445        0x023D99A0 A5 A5 A5 A5 A5 A5 A5 A5-A5 A5 A5 A5 A5 A5 A5 A5 ................
446        SHLL [/] $ mdump 0x02000000 16
447        0x02000000 A1 48 00 00 29 00 80 33-81 C5 22 BC A6 10 21 00 .H..)..3.."...!.
448        SHLL [/] $ mmove 0x023d99a0 0x02000000 13
449        SHLL [/] $ mdump 0x023d99a0 16
450        0x023D99A0 A1 48 00 00 29 00 80 33-81 C5 22 BC A6 A5 A5 A5 .H..)..3..".....
451
452.. index:: CONFIGURE_SHELL_NO_COMMAND_MMOVE
453.. index:: CONFIGURE_SHELL_COMMAND_MMOVE
454
455CONFIGURATION:
456    This command is included in the default shell command set.  When building a
457    custom command set, define ``CONFIGURE_SHELL_COMMAND_MMOVE`` to have this
458    command included.
459
460    This command can be excluded from the shell command set by defining
461    ``CONFIGURE_SHELL_NO_COMMAND_MMOVE`` when all shell commands have been
462    configured.
463
464.. index:: rtems_shell_rtems_main_mmove
465
466PROGRAMMING INFORMATION:
467    The ``mmove`` is implemented by a C language function which has the
468    following prototype:
469
470    .. code-block:: c
471
472        int rtems_shell_rtems_main_mmove(
473            int    argc,
474            char **argv
475        );
476
477    The configuration structure for the ``mmove`` has the following prototype:
478
479    .. code-block:: c
480
481        extern rtems_shell_cmd_t rtems_shell_MMOVE_Command;
482
483.. raw:: latex
484
485   \clearpage
486
487.. _malloc:
488
489malloc - obtain information on C program heap
490---------------------------------------------
491.. index:: malloc
492
493SYNOPSYS:
494    .. code-block:: shell
495
496        malloc [walk]
497
498DESCRIPTION:
499    This command prints information about the current state of the C Program
500    Heap used by the ``malloc()`` family of calls if no or invalid options are
501    passed to the command.  This includes the following information:
502
503    - Number of free blocks
504
505    - Largest free block
506
507    - Total bytes free
508
509    - Number of used blocks
510
511    - Largest used block
512
513    - Total bytes used
514
515    - Size of the allocatable area in bytes
516
517    - Minimum free size ever in bytes
518
519    - Maximum number of free blocks ever
520
521    - Maximum number of blocks searched ever
522
523    - Lifetime number of bytes allocated
524
525    - Lifetime number of bytes freed
526
527    - Total number of searches
528
529    - Total number of successful allocations
530
531    - Total number of failed allocations
532
533    - Total number of successful frees
534
535    - Total number of successful resizes
536
537    When the subcommand ``walk`` is specified, then a heap walk will be
538    performed and information about each block is printed out.
539
540EXIT STATUS:
541    This command returns 0 on success and non-zero if an error is encountered.
542
543NOTES:
544    NONE
545
546EXAMPLES:
547    The following is an example of how to use the ``malloc`` command.
548
549    .. code-block:: shell
550
551        SHLL [/] $ malloc
552        C Program Heap and RTEMS Workspace are the same.
553        Number of free blocks:                               2
554        Largest free block:                          266207504
555        Total bytes free:                            266208392
556        Number of used blocks:                             167
557        Largest used block:                              16392
558        Total bytes used:                                83536
559        Size of the allocatable area in bytes:       266291928
560        Minimum free size ever in bytes:             266207360
561        Maximum number of free blocks ever:                  6
562        Maximum number of blocks searched ever:              5
563        Lifetime number of bytes allocated:              91760
564        Lifetime number of bytes freed:                   8224
565        Total number of searches:                          234
566        Total number of successful allocations:            186
567        Total number of failed allocations:                  0
568        Total number of successful frees:                   19
569        Total number of successful resizes:                  0
570        SHLL [/] $ malloc walk
571        malloc walk
572        PASS[0]: page size 8, min block size 48
573        area begin 0x00210210, area end 0x0FFFC000
574        first block 0x00210214, last block 0x0FFFBFDC
575        first free 0x00228084, last free 0x00228354
576        PASS[0]: block 0x00210214: size 88
577        ...
578        PASS[0]: block 0x00220154: size 144
579        PASS[0]: block 0x002201E4: size 168, prev 0x002205BC, next 0x00228354 (= last free)
580        PASS[0]: block 0x0022028C: size 168, prev_size 168
581        ...
582        PASS[0]: block 0x00226E7C: size 4136
583        PASS[0]: block 0x00227EA4: size 408, prev 0x00228084 (= first free), next 0x00226CE4
584        PASS[0]: block 0x0022803C: size 72, prev_size 408
585        PASS[0]: block 0x00228084: size 648, prev 0x0020F75C (= head), next 0x00227EA4
586        PASS[0]: block 0x0022830C: size 72, prev_size 648
587        PASS[0]: block 0x00228354: size 266157192, prev 0x002201E4, next 0x0020F75C (= tail)
588        PASS[0]: block 0x0FFFBFDC: size 4028711480, prev_size 266157192
589
590.. index:: CONFIGURE_SHELL_NO_COMMAND_MALLOC
591.. index:: CONFIGURE_SHELL_COMMAND_MALLOC
592
593CONFIGURATION:
594    This command is included in the default shell command set.  When building a
595    custom command set, define ``CONFIGURE_SHELL_COMMAND_MALLOC`` to have this
596    command included.
597
598    This command can be excluded from the shell command set by defining
599    ``CONFIGURE_SHELL_NO_COMMAND_MALLOC`` when all shell commands have been
600    configured.
601
602.. index:: rtems_shell_rtems_main_malloc
603
604PROGRAMMING INFORMATION:
605    The ``malloc`` is implemented by a C language function which has the
606    following prototype:
607
608    .. code-block:: c
609
610        int rtems_shell_rtems_main_malloc(
611            int    argc,
612            char **argv
613        );
614
615    The configuration structure for the ``malloc`` has the following prototype:
616
617    .. code-block:: c
618
619        extern rtems_shell_cmd_t rtems_shell_MALLOC_Command;
Note: See TracBrowser for help on using the repository browser.