source: rtems-docs/shell/memory_commands.rst @ 633a24f

5
Last change on this file since 633a24f was e52906b, checked in by Sebastian Huber <sebastian.huber@…>, on 01/09/19 at 15:14:06

Simplify SPDX-License-Identifier comment

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