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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc3/] [gcc/] [ada/] [g-memdum.adb] - Blame information for rev 516

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT RUN-TIME COMPONENTS                         --
4
--                                                                          --
5
--                     G N A T . M E M O R Y _ D U M P                      --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--                     Copyright (C) 2003-2007, AdaCore                     --
10
--                                                                          --
11
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17
-- for  more details.  You should have  received  a copy of the GNU General --
18
-- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20
-- Boston, MA 02110-1301, USA.                                              --
21
--                                                                          --
22
-- As a special exception,  if other files  instantiate  generics from this --
23
-- unit, or you link  this unit with other files  to produce an executable, --
24
-- this  unit  does not  by itself cause  the resulting  executable  to  be --
25
-- covered  by the  GNU  General  Public  License.  This exception does not --
26
-- however invalidate  any other reasons why  the executable file  might be --
27
-- covered by the  GNU Public License.                                      --
28
--                                                                          --
29
-- GNAT was originally developed  by the GNAT team at  New York University. --
30
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
31
--                                                                          --
32
------------------------------------------------------------------------------
33
 
34
with System;                  use System;
35
with System.Storage_Elements; use System.Storage_Elements;
36
 
37
with GNAT.IO;              use GNAT.IO;
38
with GNAT.Debug_Utilities; use GNAT.Debug_Utilities;
39
 
40
with Ada.Unchecked_Conversion;
41
 
42
package body GNAT.Memory_Dump is
43
 
44
   ----------
45
   -- Dump --
46
   ----------
47
 
48
   procedure Dump (Addr : System.Address; Count : Natural) is
49
      Ctr : Natural := Count;
50
      --  Count of bytes left to output
51
 
52
      Adr : Address := Addr;
53
      --  Current address
54
 
55
      N : Natural := 0;
56
      --  Number of bytes output on current line
57
 
58
      C : Character;
59
      --  Character at current storage address
60
 
61
      AIL : constant := Address_Image_Length - 4 + 2;
62
      --  Number of chars in initial address + colon + space
63
 
64
      Line_Len : constant Natural := AIL + 3 * 16 + 2 + 16;
65
      --  Line length for entire line
66
 
67
      Line_Buf : String (1 .. Line_Len);
68
 
69
      Hex : constant array (0 .. 15) of Character := "0123456789ABCDEF";
70
 
71
      type Char_Ptr is access all Character;
72
 
73
      function To_Char_Ptr is new Ada.Unchecked_Conversion (Address, Char_Ptr);
74
 
75
   begin
76
      while Ctr /= 0 loop
77
 
78
         --  Start of line processing
79
 
80
         if N = 0 then
81
            declare
82
               S : constant String := Image (Adr);
83
            begin
84
               Line_Buf (1 .. AIL) := S (4 .. S'Length - 1) & ": ";
85
               Line_Buf (AIL + 1 .. Line_Buf'Last) := (others => ' ');
86
               Line_Buf (AIL + 3 * 16 + 1) := '"';
87
            end;
88
         end if;
89
 
90
         --  Add one character to current line
91
 
92
         C := To_Char_Ptr (Adr).all;
93
         Adr := Adr + 1;
94
         Ctr := Ctr - 1;
95
 
96
         Line_Buf (AIL + 3 * N + 1) := Hex (Character'Pos (C) / 16);
97
         Line_Buf (AIL + 3 * N + 2) := Hex (Character'Pos (C) mod 16);
98
 
99
         if C < ' ' or else C = Character'Val (16#7F#) then
100
            C := '?';
101
         end if;
102
 
103
         Line_Buf (AIL + 3 * 16 + 2 + N) := C;
104
         N := N + 1;
105
 
106
         --  End of line processing
107
 
108
         if N = 16 then
109
            Line_Buf (Line_Buf'Last) := '"';
110
            GNAT.IO.Put_Line (Line_Buf);
111
            N := 0;
112
         end if;
113
      end loop;
114
 
115
      --  Deal with possible last partial line
116
 
117
      if N /= 0 then
118
         Line_Buf (AIL + 3 * 16 + 2 + N) := '"';
119
         GNAT.IO.Put_Line (Line_Buf (1 .. AIL + 3 * 16 + 2 + N));
120
      end if;
121
 
122
      return;
123
   end Dump;
124
 
125
end GNAT.Memory_Dump;

powered by: WebSVN 2.1.0

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