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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [gnu/] [gcj/] [tools/] [gc_analyze/] [ItemList.java] - Blame information for rev 756

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 756 jeremybenn
/* ItemList.java -- Maps all objects keyed by their addresses.
2
   Copyright (C) 2007  Free Software Foundation
3
 
4
   This file is part of libgcj.
5
 
6
This software is copyrighted work licensed under the terms of the
7
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
8
details.  */
9
 
10
package gnu.gcj.tools.gc_analyze;
11
 
12
import java.io.IOException;
13
import java.util.HashMap;
14
import java.util.Map;
15
import java.util.TreeMap;
16
 
17
class ItemList
18
{
19
  public ItemList()
20
  {
21
  }
22
 
23
  private TreeMap<Long, HashMap<ObjectMap.ObjectItem, Integer>> map;
24
 
25
  public void add(ObjectMap.ObjectItem item)
26
  {
27
    if (map == null)
28
      map = new TreeMap<Long, HashMap<ObjectMap.ObjectItem, Integer>>();
29
    Long x = new Long(item.klass);
30
    HashMap<ObjectMap.ObjectItem, Integer> list = map.get(x);
31
    if (list == null)
32
      {
33
        list = new HashMap<ObjectMap.ObjectItem, Integer>();
34
        map.put(x, list);
35
      }
36
    Integer count = list.get(item);
37
    if (count == null)
38
      list.put(item, new Integer(1));
39
    else
40
      list.put(item, new Integer(count.intValue() + 1));
41
  }
42
 
43
  void dump(String title, SymbolLookup lookup) throws IOException
44
  {
45
    if (map == null)
46
      return;
47
    System.out.println(title);
48
    for (Map.Entry<Long, HashMap<ObjectMap.ObjectItem, Integer>> me :
49
           map.entrySet())
50
      {
51
        HashMap<ObjectMap.ObjectItem, Integer> list = me.getValue();
52
        boolean first = true;
53
 
54
        for (Map.Entry<ObjectMap.ObjectItem, Integer> me2 : list.entrySet())
55
          {
56
            ObjectMap.ObjectItem item = me2.getKey();
57
            Integer count = me2.getValue();
58
            if (first)
59
              {
60
                String name =
61
                  MemoryAnalyze.getSymbolPretty(lookup, item, false);
62
                System.out.println("    " + name + ":");
63
                first = false;
64
              }
65
            System.out.print("        0x" + Long.toHexString(item.ptr));
66
            if (count.intValue() != 1)
67
              System.out.print(" * " + count);
68
            System.out.println();
69
          }
70
      }
71
  }
72
}

powered by: WebSVN 2.1.0

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