source: rtems-docs/shell/memory_commands.rst @ 8ca13ed

4.115
Last change on this file since 8ca13ed was 8ca13ed, checked in by Amar Takhar <verm@…>, on 01/16/16 at 20:32:09

Split document.

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