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

4.115
Last change on this file since fabe6d0 was fabe6d0, checked in by Chris Johns <chrisj@…>, on 01/22/16 at 23:14:53

Clean up the memory commands.

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