comparison agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java @ 14909:4ca6dc0799b6

Backout jdk9 merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 01 Apr 2014 13:57:07 +0200
parents d7cb88bd7046
children
comparison
equal deleted inserted replaced
14908:8db6e76cb658 14909:4ca6dc0799b6
53 53
54 public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException { 54 public LoadObject loadObjectContainingPC(Address pc) throws DebuggerException {
55 if (pc == null) { 55 if (pc == null) {
56 return null; 56 return null;
57 } 57 }
58 List objs = getLoadObjectList();
59 Object[] arr = objs.toArray();
60 // load objects are sorted by base address, do binary search
61 int mid = -1;
62 int low = 0;
63 int high = arr.length - 1;
58 64
59 /* Typically we have about ten loaded objects here. So no reason to do 65 while (low <= high) {
60 sort/binary search here. Linear search gives us acceptable performance.*/ 66 mid = (low + high) >> 1;
61 67 LoadObject midVal = (LoadObject) arr[mid];
62 List objs = getLoadObjectList(); 68 long cmp = pc.minus(midVal.getBase());
63 69 if (cmp < 0) {
64 for (int i = 0; i < objs.size(); i++) { 70 high = mid - 1;
65 LoadObject ob = (LoadObject) objs.get(i); 71 } else if (cmp > 0) {
66 Address base = ob.getBase(); 72 long size = midVal.getSize();
67 long size = ob.getSize(); 73 if (cmp >= size) {
68 if ( pc.greaterThanOrEqual(base) && pc.lessThan(base.addOffsetTo(size))) { 74 low = mid + 1;
69 return ob; 75 } else {
70 } 76 return (LoadObject) arr[mid];
77 }
78 } else { // match found
79 return (LoadObject) arr[mid];
80 }
71 } 81 }
72 82 // no match found.
73 return null; 83 return null;
74 } 84 }
75 85
76 public CFrame topFrameForThread(ThreadProxy thread) throws DebuggerException { 86 public CFrame topFrameForThread(ThreadProxy thread) throws DebuggerException {
77 String cpu = dbg.getCPU(); 87 String cpu = dbg.getCPU();